Skip to content

Commit

Permalink
Merge pull request #442 from RoaringBitmap/issue440
Browse files Browse the repository at this point in the history
further fix for issue 440
  • Loading branch information
lemire authored Aug 5, 2024
2 parents bbff6e9 + ac91af2 commit add9cb0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions roaring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ func TestIssue440(t *testing.T) {
require.Equal(t, b1, b2)
}

func TestIssue440_2(t *testing.T) {
a := NewBitmap()
a.AddMany([]uint32{1, 2, 3, 4})
a.RunOptimize()
b1, err := a.MarshalBinary()
require.NoError(t, err)
a.RunOptimize()
b2, err := a.MarshalBinary()
require.NoError(t, err)
require.Equal(t, b1, b2)
}

func TestIssue440_3(t *testing.T) {
a := NewBitmap()
a.AddMany([]uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13})
a.RunOptimize()
b1, err := a.MarshalBinary()
require.NoError(t, err)
a.RunOptimize()
b2, err := a.MarshalBinary()
require.NoError(t, err)
require.Equal(t, b1, b2)
}

func checkValidity(t *testing.T, rb *Bitmap) {
t.Helper()

Expand Down
2 changes: 1 addition & 1 deletion runcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2521,7 +2521,7 @@ func (rc *runContainer16) toEfficientContainer() container {
sizeAsBitmapContainer := bitmapContainerSizeInBytes()
card := rc.getCardinality()
sizeAsArrayContainer := arrayContainerSizeInBytes(card)
if sizeAsRunContainer <= minOfInt(sizeAsBitmapContainer, sizeAsArrayContainer) {
if sizeAsRunContainer > minOfInt(sizeAsBitmapContainer, sizeAsArrayContainer) {
return rc
}
if card <= arrayDefaultMaxSize {
Expand Down

0 comments on commit add9cb0

Please sign in to comment.