DecodeToBuffer is the same as Decode but it returns a z.Buffer which is calloc'ed and can be SHOULD be freed up by calling buffer.Release().
(pack *UidPack, seek uint64)
| 419 | // DecodeToBuffer is the same as Decode but it returns a z.Buffer which is |
| 420 | // calloc'ed and can be SHOULD be freed up by calling buffer.Release(). |
| 421 | func DecodeToBuffer(pack *UidPack, seek uint64) *z.Buffer { |
| 422 | buf, err := z.NewBufferWith(256<<20, 32<<30, z.UseCalloc) |
| 423 | Check(err) |
| 424 | buf.AutoMmapAfter(1 << 30) |
| 425 | |
| 426 | var last uint64 |
| 427 | tmp := make([]byte, 16) |
| 428 | dec := Decoder{Pack: pack} |
| 429 | for uids := dec.Seek(seek, SeekStart); len(uids) > 0; uids = dec.Next() { |
| 430 | for _, u := range uids { |
| 431 | n := binary.PutUvarint(tmp, u-last) |
| 432 | Check2(buf.Write(tmp[:n])) |
| 433 | last = u |
| 434 | } |
| 435 | } |
| 436 | return buf |
| 437 | } |
| 438 | |
| 439 | func match32MSB(num1, num2 uint64) bool { |
| 440 | return (num1 & bitMask) == (num2 & bitMask) |