Skip to content

Commit

Permalink
Merge pull request #458 from RoaringBitmap/fix-457
Browse files Browse the repository at this point in the history
Fix issue 457.
  • Loading branch information
lemire authored Nov 5, 2024
2 parents 1b5ad6c + 3d16864 commit 3bff4ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions roaring64/bsi64.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ func (b *BSI) SetBigValue(columnID uint64, value *big.Int) {
// If max/min values are set to zero then automatically determine bit array size
if b.MaxValue == 0 && b.MinValue == 0 {
minBits := value.BitLen() + 1
if minBits == 1 {
minBits = 2
}
for len(b.bA) < minBits {
b.bA = append(b.bA, Bitmap{})
}
Expand Down
13 changes: 8 additions & 5 deletions roaring64/bsi64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ func TestSetAndGetBigTimestamp(t *testing.T) {
assert.Equal(t, 67, bsi.BitCount())
}

// This tests a corner case where a zero value is set on an empty BSI. The bit count should never be zero.
func TestSetInitialValueZero(t *testing.T) {
bsi := NewDefaultBSI()
bsi.SetBigValue(1, big.NewInt(0))
assert.Equal(t, 1, bsi.BitCount())
}

func TestRangeBig(t *testing.T) {

bsi := NewDefaultBSI()
Expand Down Expand Up @@ -262,15 +269,11 @@ func TestNewBSI(t *testing.T) {
bsi = NewDefaultBSI()
assert.Equal(t, 0, bsi.BitCount())
bsi.SetValue(1, int64(0))
assert.Equal(t, 0, bsi.BitCount())
assert.Equal(t, 1, bsi.BitCount())
bsi.SetValue(1, int64(-1))
assert.Equal(t, 1, bsi.BitCount())
}

func TestStuff(t *testing.T) {

}

func TestGE(t *testing.T) {

bsi := setup()
Expand Down

0 comments on commit 3bff4ad

Please sign in to comment.