MCPcopy Index your code
hub / github.com/dgraph-io/dgraph-benchmarks / EncodeFromBuffer

Function EncodeFromBuffer

bitmap/codec.go:367–379  ·  view source on GitHub ↗

EncodeFromBuffer is the same as Encode but it accepts a byte slice instead of a uint64 slice.

(buf []byte, blockSize int)

Source from the content-addressed store, hash-verified

365
366// EncodeFromBuffer is the same as Encode but it accepts a byte slice instead of a uint64 slice.
367func EncodeFromBuffer(buf []byte, blockSize int) *UidPack {
368 enc := Encoder{BlockSize: blockSize}
369 var prev uint64
370 for len(buf) > 0 {
371 uid, n := binary.Uvarint(buf)
372 buf = buf[n:]
373
374 next := prev + uid
375 enc.Add(next)
376 prev = next
377 }
378 return enc.Done()
379}
380
381// ApproxLen would indicate the total number of UIDs in the pack. Can be used for int slice
382// allocations.

Callers

nothing calls this directly

Calls 2

AddMethod · 0.95
DoneMethod · 0.95

Tested by

no test coverage detected