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

Method Add

bitmap/codec.go:129–150  ·  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

127
128// Add takes an uid and adds it to the list of UIDs to be encoded.
129func (e *Encoder) Add(uid uint64) {
130 if e.pack == nil {
131 e.pack = &UidPack{BlockSize: uint32(e.BlockSize)}
132 e.buf = new(bytes.Buffer)
133 }
134 if e.Alloc == nil {
135 e.Alloc = z.NewAllocator(1024)
136 e.Alloc.Tag = tagEncoder
137 }
138
139 size := len(e.uids)
140 if size > 0 && !match32MSB(e.uids[size-1], uid) {
141 e.packBlock()
142 e.uids = e.uids[:0]
143 }
144
145 e.uids = append(e.uids, uid)
146 if len(e.uids) >= e.BlockSize {
147 e.packBlock()
148 e.uids = e.uids[:0]
149 }
150}
151
152// Done returns the final output of the encoder. This UidPack MUST BE FREED via a call to FreePack.
153func (e *Encoder) Done() *UidPack {

Callers 15

EncodeFunction · 0.95
EncodeFromBufferFunction · 0.95
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
SetMethod · 0.80
SetMethod · 0.80
HandleRdfReaderFunction · 0.80
BenchmarkRoaringFunction · 0.80

Calls 2

packBlockMethod · 0.95
match32MSBFunction · 0.85

Tested by 6

SetMethod · 0.64
BenchmarkRoaringFunction · 0.64
BenchmarkRoaring32Function · 0.64
BenchmarkCopyOnWriteFunction · 0.64
BenchmarkContainsFunction · 0.64
newBitmapFunction · 0.64