MCPcopy Create free account
hub / github.com/RoaringBitmap/roaring / appendCopiesUntil

Method appendCopiesUntil

roaring64/roaringarray64.go:71–91  ·  view source on GitHub ↗
(sa roaringArray64, stoppingKey uint32)

Source from the content-addressed store, hash-verified

69}
70
71func (ra *roaringArray64) appendCopiesUntil(sa roaringArray64, stoppingKey uint32) {
72 // cow only if the two request it, or if we already have a lightweight copy
73 copyonwrite := ra.copyOnWrite && sa.copyOnWrite
74
75 for i := 0; i < sa.size(); i++ {
76 if sa.keys[i] >= stoppingKey {
77 break
78 }
79 thiscopyonewrite := copyonwrite || sa.needsCopyOnWrite(i)
80 if thiscopyonewrite {
81 ra.appendContainer(sa.keys[i], sa.containers[i], thiscopyonewrite)
82 if !sa.needsCopyOnWrite(i) {
83 sa.setNeedsCopyOnWrite(i)
84 }
85
86 } else {
87 // since there is no copy-on-write, we need to clone the container (this is important)
88 ra.appendContainer(sa.keys[i], sa.containers[i].Clone(), thiscopyonewrite)
89 }
90 }
91}
92
93func (ra *roaringArray64) appendCopiesAfter(sa roaringArray64, beforeStart uint32) {
94 // cow only if the two request it, or if we already have a lightweight copy

Callers 2

FlipFunction · 0.45
TestCopiesFunction · 0.45

Calls 5

appendContainerMethod · 0.95
sizeMethod · 0.45
needsCopyOnWriteMethod · 0.45
setNeedsCopyOnWriteMethod · 0.45
CloneMethod · 0.45

Tested by 1

TestCopiesFunction · 0.36