MCPcopy
hub / github.com/RoaringBitmap/roaring / lazyOR

Function lazyOR

fastaggregation.go:8–53  ·  view source on GitHub ↗

Or function that requires repairAfterLazy

(x1, x2 *Bitmap)

Source from the content-addressed store, hash-verified

6
7// Or function that requires repairAfterLazy
8func lazyOR(x1, x2 *Bitmap) *Bitmap {
9 answer := NewBitmap()
10 pos1 := 0
11 pos2 := 0
12 length1 := x1.highlowcontainer.size()
13 length2 := x2.highlowcontainer.size()
14main:
15 for (pos1 < length1) && (pos2 < length2) {
16 s1 := x1.highlowcontainer.getKeyAtIndex(pos1)
17 s2 := x2.highlowcontainer.getKeyAtIndex(pos2)
18
19 for {
20 if s1 < s2 {
21 answer.highlowcontainer.appendCopy(x1.highlowcontainer, pos1)
22 pos1++
23 if pos1 == length1 {
24 break main
25 }
26 s1 = x1.highlowcontainer.getKeyAtIndex(pos1)
27 } else if s1 > s2 {
28 answer.highlowcontainer.appendCopy(x2.highlowcontainer, pos2)
29 pos2++
30 if pos2 == length2 {
31 break main
32 }
33 s2 = x2.highlowcontainer.getKeyAtIndex(pos2)
34 } else {
35 c1 := x1.highlowcontainer.getContainerAtIndex(pos1)
36 answer.highlowcontainer.appendContainer(s1, c1.lazyOR(x2.highlowcontainer.getContainerAtIndex(pos2)), false)
37 pos1++
38 pos2++
39 if (pos1 == length1) || (pos2 == length2) {
40 break main
41 }
42 s1 = x1.highlowcontainer.getKeyAtIndex(pos1)
43 s2 = x2.highlowcontainer.getKeyAtIndex(pos2)
44 }
45 }
46 }
47 if pos1 == length1 {
48 answer.highlowcontainer.appendCopyMany(x2.highlowcontainer, pos2, length2)
49 } else if pos2 == length2 {
50 answer.highlowcontainer.appendCopyMany(x1.highlowcontainer, pos1, length1)
51 }
52 return answer
53}
54
55// In-place Or function that requires repairAfterLazy
56func (x1 *Bitmap) lazyOR(x2 *Bitmap) *Bitmap {

Callers 1

FastOrFunction · 0.85

Calls 8

NewBitmapFunction · 0.70
lazyORMethod · 0.65
sizeMethod · 0.45
getKeyAtIndexMethod · 0.45
appendCopyMethod · 0.45
getContainerAtIndexMethod · 0.45
appendContainerMethod · 0.45
appendCopyManyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…