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

Method Or

roaring64/roaring64.go:676–717  ·  view source on GitHub ↗

Or computes the union between two bitmaps and stores the result in the current bitmap

(x2 *Bitmap)

Source from the content-addressed store, hash-verified

674
675// Or computes the union between two bitmaps and stores the result in the current bitmap
676func (rb *Bitmap) Or(x2 *Bitmap) {
677 pos1 := 0
678 pos2 := 0
679 length1 := rb.highlowcontainer.size()
680 length2 := x2.highlowcontainer.size()
681main:
682 for (pos1 < length1) && (pos2 < length2) {
683 s1 := rb.highlowcontainer.getKeyAtIndex(pos1)
684 s2 := x2.highlowcontainer.getKeyAtIndex(pos2)
685
686 for {
687 if s1 < s2 {
688 pos1++
689 if pos1 == length1 {
690 break main
691 }
692 s1 = rb.highlowcontainer.getKeyAtIndex(pos1)
693 } else if s1 > s2 {
694 rb.highlowcontainer.insertNewKeyValueAt(pos1, s2, x2.highlowcontainer.getContainerAtIndex(pos2).Clone())
695 pos1++
696 length1++
697 pos2++
698 if pos2 == length2 {
699 break main
700 }
701 s2 = x2.highlowcontainer.getKeyAtIndex(pos2)
702 } else {
703 rb.highlowcontainer.getWritableContainerAtIndex(pos1).Or(x2.highlowcontainer.getContainerAtIndex(pos2))
704 pos1++
705 pos2++
706 if (pos1 == length1) || (pos2 == length2) {
707 break main
708 }
709 s1 = rb.highlowcontainer.getKeyAtIndex(pos1)
710 s2 = x2.highlowcontainer.getKeyAtIndex(pos2)
711 }
712 }
713 }
714 if pos1 == length1 {
715 rb.highlowcontainer.appendCopyMany(x2.highlowcontainer, pos2, length2)
716 }
717}
718
719// AndNot computes the difference between two bitmaps and stores the result in the current bitmap
720func (rb *Bitmap) AndNot(x2 *Bitmap) {

Callers 15

TestIssue386Function · 0.95
TestBitmapCOWFunction · 0.95
TestOrCOWSharedContainerFunction · 0.95
testAggregationsFunction · 0.95
TestBitmapFunction · 0.95
OrCardinalityMethod · 0.45
OrFunction · 0.45
SetBigValueMethod · 0.45
SetBigManyMethod · 0.45
GetBigValueMethod · 0.45
minOrMaxMethod · 0.45

Calls 7

sizeMethod · 0.45
getKeyAtIndexMethod · 0.45
insertNewKeyValueAtMethod · 0.45
CloneMethod · 0.45
getContainerAtIndexMethod · 0.45
appendCopyManyMethod · 0.45

Tested by 6

TestIssue386Function · 0.76
TestBitmapCOWFunction · 0.76
TestOrCOWSharedContainerFunction · 0.76
testAggregationsFunction · 0.76
TestBitmapFunction · 0.76