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

Function TestFastAggregationsXOR

fastaggregation_test.go:112–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

110}
111
112func TestFastAggregationsXOR(t *testing.T) {
113 rb1 := NewBitmap()
114 rb2 := NewBitmap()
115 rb3 := NewBitmap()
116
117 for i := uint32(0); i < 40000; i++ {
118 rb1.Add(i)
119 }
120 for i := uint32(0); i < 40000; i += 4000 {
121 rb2.Add(i)
122 }
123 for i := uint32(0); i < 40000; i += 5000 {
124 rb3.Add(i)
125 }
126
127 assert.EqualValues(t, 40000, rb1.GetCardinality())
128
129 xor1 := Xor(rb1, rb2)
130 xor1alt := Xor(rb2, rb1)
131 assert.True(t, xor1alt.Equals(xor1))
132 assert.True(t, HeapXor(rb1, rb2).Equals(xor1))
133
134 xor2 := Xor(rb2, rb3)
135 xor2alt := Xor(rb3, rb2)
136 assert.True(t, xor2alt.Equals(xor2))
137 assert.True(t, HeapXor(rb2, rb3).Equals(xor2))
138
139 bigxor := Xor(Xor(rb1, rb2), rb3)
140 bigxoralt1 := Xor(rb1, Xor(rb2, rb3))
141 bigxoralt2 := Xor(rb1, Xor(rb3, rb2))
142 bigxoralt3 := Xor(rb3, Xor(rb1, rb2))
143 bigxoralt4 := Xor(Xor(rb1, rb2), rb3)
144
145 assert.True(t, bigxoralt2.Equals(bigxor))
146 assert.True(t, bigxoralt1.Equals(bigxor))
147 assert.True(t, bigxoralt3.Equals(bigxor))
148 assert.True(t, bigxoralt4.Equals(bigxor))
149
150 assert.True(t, HeapXor(rb1, rb2, rb3).Equals(bigxor))
151}
152
153func TestFastAggregationsXOR_run(t *testing.T) {
154 rb1 := NewBitmap()

Callers

nothing calls this directly

Calls 6

AddMethod · 0.95
GetCardinalityMethod · 0.95
HeapXorFunction · 0.85
NewBitmapFunction · 0.70
XorFunction · 0.70
EqualsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…