Skip to content

Commit

Permalink
fix use nil parameter, the MinMaxBig func will throw panic's problem
Browse files Browse the repository at this point in the history
  • Loading branch information
ChicChip committed Oct 31, 2024
1 parent bd799d0 commit 32dbf71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions roaring64/bsi64.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,10 @@ func (b *BSI) MinMaxBig(parallelism int, op Operation, foundSet *Bitmap) *big.In

resultsChan := make(chan *big.Int, n)

if foundSet == nil {
foundSet = &b.eBM
}

card := foundSet.GetCardinality()
x := card / uint64(n)

Expand Down
6 changes: 6 additions & 0 deletions roaring64/bsi64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,12 @@ func TestMinMaxWithRandom(t *testing.T) {
assert.Equal(t, max, bsi.MinMax(0, MAX, bsi.GetExistenceBitmap()))
}

func TestMinMaxWithNilFoundSet(t *testing.T) {
bsi, min, max := setupRandom()
assert.Equal(t, min, bsi.MinMax(0, MIN, nil))
assert.Equal(t, max, bsi.MinMax(0, MAX, nil))
}

func TestBSIWriteToReadFrom(t *testing.T) {
file, err := ioutil.TempFile("./testdata", "bsi-test")
if err != nil {
Expand Down

0 comments on commit 32dbf71

Please sign in to comment.