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

Function setupRandom

BitSliceIndexing/bsi_test.go:97–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95}
96
97func setupRandom() *BSI {
98 bsi := NewBSI(99, -1)
99 rg := rand.New(rand.NewSource(time.Now().UnixNano()))
100 // Setup values
101 for i := 0; bsi.GetExistenceBitmap().GetCardinality() < 100; {
102 rv := rg.Int63n(bsi.MaxValue) - 50
103 _, ok := bsi.GetValue(uint64(i))
104 if ok {
105 continue
106 }
107 bsi.SetValue(uint64(i), rv)
108 i++
109 }
110 batch := make([]uint32, 100)
111 iter := bsi.GetExistenceBitmap().ManyIterator()
112 iter.NextMany(batch)
113 var min, max int64
114 min = Max64BitSigned
115 max = Min64BitSigned
116 for i := 0; i < len(batch); i++ {
117 v, _ := bsi.GetValue(uint64(batch[i]))
118 if v > max {
119 max = v
120 }
121 if v < min {
122 min = v
123 }
124 }
125 bsi.MinValue = min
126 bsi.MaxValue = max
127 return bsi
128}
129
130func TestEQ(t *testing.T) {
131 bsi := setup()

Callers 2

TestMinMaxWithRandomFunction · 0.70
TestMinMaxWithNilFunction · 0.70

Calls 7

GetExistenceBitmapMethod · 0.95
GetValueMethod · 0.95
SetValueMethod · 0.95
NewBSIFunction · 0.70
NextManyMethod · 0.65
GetCardinalityMethod · 0.45
ManyIteratorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…