Skip to content

Commit b25cb8b

Browse files
authored
Merge pull request #485 from RoaringBitmap/various_and_issues
fixing various and and or issues
2 parents 0533b39 + 41f25b8 commit b25cb8b

File tree

11 files changed

+66
-29
lines changed

11 files changed

+66
-29
lines changed

.github/workflows/armtests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.17.x]
10+
go-version: [1.22.x]
1111
platform: [ubuntu-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

.github/workflows/basictests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.17.x]
10+
go-version: [1.22.x]
1111
platform: [ubuntu-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

.github/workflows/bigendiantests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.17.x]
10+
go-version: [1.22.x]
1111
platform: [ubuntu-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

.github/workflows/legacytests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.17.x]
10+
go-version: [1.22.x]
1111
platform: [ubuntu-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

.github/workflows/macostests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.17.x]
10+
go-version: [1.22.x]
1111
platform: [macos-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

.github/workflows/windowstests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
test:
88
strategy:
99
matrix:
10-
go-version: [1.17.x]
10+
go-version: [1.22.x]
1111
platform: [windows-latest]
1212
runs-on: ${{ matrix.platform }}
1313
steps:

arraycontainer.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,10 @@ func (ac *arrayContainer) iorArray(value2 *arrayContainer) container {
417417
func (ac *arrayContainer) iorBitmap(bc2 *bitmapContainer) container {
418418
bc1 := ac.toBitmapContainer()
419419
bc1.iorBitmap(bc2)
420-
*ac = *newArrayContainerFromBitmap(bc1)
421-
return ac
420+
// DO NOT DO THIS:
421+
// *ac = *newArrayContainerFromBitmap(bc1)
422+
// This will create gigantic array containers in the case of repeated calls to iorBitmap.
423+
return bc1
422424
}
423425

424426
func (ac *arrayContainer) iorRun16(rc *runContainer16) container {

go.mod

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
module github.com/RoaringBitmap/roaring/v2
22

3-
go 1.15
3+
go 1.22
44

55
require (
6-
github.com/bits-and-blooms/bitset v1.12.0
6+
github.com/bits-and-blooms/bitset v1.24.1
77
github.com/google/uuid v1.6.0
88
github.com/mschoch/smat v0.2.0
9-
github.com/stretchr/testify v1.7.0
9+
github.com/stretchr/testify v1.11.1
1010
)
1111

12-
require gopkg.in/yaml.v3 v3.0.0 // indirect
12+
require (
13+
github.com/davecgh/go-spew v1.1.1 // indirect
14+
github.com/pmezard/go-difflib v1.0.0 // indirect
15+
gopkg.in/yaml.v3 v3.0.1 // indirect
16+
)

go.sum

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
github.com/bits-and-blooms/bitset v1.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZtmFVPHmA=
2-
github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
3-
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
4-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1+
github.com/bits-and-blooms/bitset v1.24.1 h1:hqnfFbjjk3pxGa5E9Ho3hjoU7odtUuNmJ9Ao+Bo8s1c=
2+
github.com/bits-and-blooms/bitset v1.24.1/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
3+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
66
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
77
github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM=
88
github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw=
99
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1010
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
11-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
12-
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
13-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
11+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
12+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
1413
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1514
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
16-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
17-
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
18-
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
15+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
16+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

roaring_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"fmt"
66
"math"
77
"math/rand"
8+
randv2 "math/rand/v2"
9+
810
"strconv"
911
"testing"
1012

@@ -13,6 +15,39 @@ import (
1315
"github.com/stretchr/testify/require"
1416
)
1517

18+
func TestSplitter_BrokeBm(t *testing.T) {
19+
bm1 := NewBitmap()
20+
bm2 := NewBitmap()
21+
bm3 := NewBitmap()
22+
23+
for i := 0; i < 2000; i++ {
24+
bm1.Add(uint32(i))
25+
bm2.Add(uint32(i + 2000))
26+
bm3.Add(uint32(i * 4000))
27+
}
28+
res := FastOr(bm1, bm2, bm3)
29+
30+
require.NoError(t, res.Validate())
31+
32+
return
33+
}
34+
35+
func TestRoaring_AndMask(t *testing.T) {
36+
r := randv2.New(randv2.NewPCG(13, 22)) // reproducible random
37+
38+
rb := NewBitmap()
39+
for j := 0; j < 1_000_000; j++ {
40+
rb.Add(r.Uint32N(10_000_000) + 5_000_000)
41+
}
42+
43+
mask := New()
44+
mask.AddRange(1, 10_000_001)
45+
mask.And(rb)
46+
47+
err := mask.Validate()
48+
require.NoError(t, err) // this fails
49+
}
50+
1651
func TestIssue440(t *testing.T) {
1752
a := NewBitmap()
1853
a.AddMany([]uint32{1, 2, 3})

0 commit comments

Comments
 (0)