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

Function testAggregations

roaring64/aggregation64_test.go:11–219  ·  view source on GitHub ↗
(t *testing.T,
	and func(bitmaps ...*Bitmap) *Bitmap,
	or func(bitmaps ...*Bitmap) *Bitmap,
	xor func(bitmaps ...*Bitmap) *Bitmap)

Source from the content-addressed store, hash-verified

9)
10
11func testAggregations(t *testing.T,
12 and func(bitmaps ...*Bitmap) *Bitmap,
13 or func(bitmaps ...*Bitmap) *Bitmap,
14 xor func(bitmaps ...*Bitmap) *Bitmap) {
15
16 t.Run("simple case", func(t *testing.T) {
17 rb1 := NewBitmap()
18 rb2 := NewBitmap()
19 rb1.Add(uint64(1))
20 rb2.Add(uint64(2))
21
22 assertAggregation(t, 0, and, rb1, rb2)
23 assertAggregation(t, 2, or, rb1, rb2)
24 assertAggregation(t, 2, xor, rb1, rb2)
25 })
26
27 t.Run("aggregate nothing", func(t *testing.T) {
28 assertAggregation(t, 0, and)
29 assertAggregation(t, 0, or)
30 assertAggregation(t, 0, xor)
31 })
32
33 t.Run("single bitmap", func(t *testing.T) {
34 rb := BitmapOf(1, 2, 3)
35
36 assertAggregation(t, 3, and, rb)
37 assertAggregation(t, 3, or, rb)
38 assertAggregation(t, 3, xor, rb)
39 })
40
41 t.Run("empty and single elem bitmaps", func(t *testing.T) {
42 rb1 := NewBitmap()
43 rb2 := BitmapOf(1)
44
45 assertAggregation(t, 0, and, rb1, rb2)
46 assertAggregation(t, 1, or, rb1, rb2)
47 assertAggregation(t, 1, xor, rb1, rb2)
48 })
49
50 t.Run("two single elem disjoint sets", func(t *testing.T) {
51 rb1 := BitmapOf(1)
52 rb2 := BitmapOf(2)
53
54 assertAggregation(t, 0, and, rb1, rb2)
55 assertAggregation(t, 2, or, rb1, rb2)
56 })
57
58 t.Run("3 bitmaps with CoW set (not in order of definition)", func(t *testing.T) {
59 rb1 := NewBitmap()
60 rb2 := NewBitmap()
61 rb3 := NewBitmap()
62 rb1.SetCopyOnWrite(true)
63 rb2.SetCopyOnWrite(true)
64 rb3.SetCopyOnWrite(true)
65 rb1.Add(uint64(1))
66 rb1.Add(uint64(100000))
67 rb2.Add(uint64(200000))
68 rb3.Add(uint64(1))

Callers 3

TestParAggregationsFunction · 0.70
TestParAggregations2Function · 0.70
TestFastAggregationsFunction · 0.70

Calls 10

AddMethod · 0.95
SetCopyOnWriteMethod · 0.95
OrMethod · 0.95
RunOptimizeMethod · 0.95
NewBitmapFunction · 0.70
assertAggregationFunction · 0.70
BitmapOfFunction · 0.70
AndFunction · 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…