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

Method Add

codec/codec.go:107–127  ·  view source on GitHub ↗

Add takes an uid and adds it to the list of UIDs to be encoded.

(uid uint64)

Source from the content-addressed store, hash-verified

105
106// Add takes an uid and adds it to the list of UIDs to be encoded.
107func (e *Encoder) Add(uid uint64) {
108 if e.pack == nil {
109 e.pack = &pb.UidPack{BlockSize: uint32(e.BlockSize)}
110 e.buf = new(bytes.Buffer)
111 }
112 if e.Alloc == nil {
113 e.Alloc = z.NewAllocator(1024, tagEncoder)
114 }
115
116 size := len(e.uids)
117 if size > 0 && !match32MSB(e.uids[size-1], uid) {
118 e.packBlock()
119 e.uids = e.uids[:0]
120 }
121
122 e.uids = append(e.uids, uid)
123 if len(e.uids) >= e.BlockSize {
124 e.packBlock()
125 e.uids = e.uids[:0]
126 }
127}
128
129// Done returns the final output of the encoder. This UidPack MUST BE FREED via a call to FreePack.
130func (e *Encoder) Done() *pb.UidPack {

Callers 15

toListMethod · 0.95
writeIndexMethod · 0.95
EncodeFunction · 0.95
EncodeFromBufferFunction · 0.95
TestSeekFunction · 0.95
TestLinearSeekFunction · 0.95
TestDecoderFunction · 0.95
newUidPackFunction · 0.95
encodeMethod · 0.95
newUidPackFunction · 0.95
TestIndexOfPacked1Function · 0.95
TestIndexOfPacked2Function · 0.95

Calls 2

packBlockMethod · 0.95
match32MSBFunction · 0.85

Tested by 15

TestSeekFunction · 0.76
TestLinearSeekFunction · 0.76
TestDecoderFunction · 0.76
newUidPackFunction · 0.76
newUidPackFunction · 0.76
TestIndexOfPacked1Function · 0.76
TestIndexOfPacked2Function · 0.76
FuzzTestParserFunction · 0.36
TestProposalFunction · 0.36