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

Function TestRle16RandomAndNot016

runcontainer_test.go:1271–1350  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1269}
1270
1271func TestRle16RandomAndNot016(t *testing.T) {
1272 t.Run("runContainer16 `andNot` operation against other container types should correctly do the and-not operation", func(t *testing.T) {
1273 seed := int64(42)
1274 rand.Seed(seed)
1275
1276 trials := []trial{
1277 {n: 1000, percentFill: .95, ntrial: 2},
1278 }
1279
1280 tester := func(tr trial) {
1281 for j := 0; j < tr.ntrial; j++ {
1282 ma := make(map[int]bool)
1283 mb := make(map[int]bool)
1284
1285 n := tr.n
1286 a := []uint16{}
1287 b := []uint16{}
1288
1289 draw := int(float64(n) * tr.percentFill)
1290 for i := 0; i < draw; i++ {
1291 r0 := rand.Intn(n)
1292 a = append(a, uint16(r0))
1293 ma[r0] = true
1294
1295 r1 := rand.Intn(n)
1296 b = append(b, uint16(r1))
1297 mb[r1] = true
1298 }
1299
1300 // showArray16(a, "a")
1301 // showArray16(b, "b")
1302
1303 // hash version of and-not
1304 hashi := make(map[int]bool)
1305 for k := range ma {
1306 hashi[k] = true
1307 }
1308 for k := range mb {
1309 delete(hashi, k)
1310 }
1311
1312 // RunContainer's and-not
1313 rc := newRunContainer16FromVals(false, a...)
1314
1315 // vs bitmapContainer
1316 bc := newBitmapContainer()
1317 for _, bv := range b {
1318 bc.iadd(bv)
1319 }
1320
1321 // vs arrayContainer
1322 ac := newArrayContainer()
1323 for _, bv := range b {
1324 ac.iadd(bv)
1325 }
1326
1327 // vs runContainer
1328 rcb := newRunContainer16FromVals(false, b...)

Callers

nothing calls this directly

Calls 7

newBitmapContainerFunction · 0.85
newArrayContainerFunction · 0.85
iaddMethod · 0.65
andNotMethod · 0.65
containsMethod · 0.65
getCardinalityMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…