MCPcopy
hub / github.com/dgraph-io/dgraph / EncodeFromBuffer

Function EncodeFromBuffer

codec/codec.go:402–414  ·  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

400
401// EncodeFromBuffer is the same as Encode but it accepts a byte slice instead of a uint64 slice.
402func EncodeFromBuffer(buf []byte, blockSize int) *pb.UidPack {
403 enc := Encoder{BlockSize: blockSize}
404 var prev uint64
405 for len(buf) > 0 {
406 uid, n := binary.Uvarint(buf)
407 buf = buf[n:]
408
409 next := prev + uid
410 enc.Add(next)
411 prev = next
412 }
413 return enc.Done()
414}
415
416// ApproxLen would indicate the total number of UIDs in the pack. Can be used for int slice
417// allocations.

Callers 2

FromBackupPostingListFunction · 0.92
TestBufferUidPackFunction · 0.85

Calls 2

AddMethod · 0.95
DoneMethod · 0.95

Tested by 1

TestBufferUidPackFunction · 0.68