Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 457. #458

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading