File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,9 @@ func (b *BSI) SetBigValue(columnID uint64, value *big.Int) {
9797 // If max/min values are set to zero then automatically determine bit array size
9898 if b .MaxValue == 0 && b .MinValue == 0 {
9999 minBits := value .BitLen () + 1
100+ if minBits == 1 {
101+ minBits = 2
102+ }
100103 for len (b .bA ) < minBits {
101104 b .bA = append (b .bA , Bitmap {})
102105 }
Original file line number Diff line number Diff line change @@ -112,6 +112,13 @@ func TestSetAndGetBigTimestamp(t *testing.T) {
112112 assert .Equal (t , 67 , bsi .BitCount ())
113113}
114114
115+ // This tests a corner case where a zero value is set on an empty BSI. The bit count should never be zero.
116+ func TestSetInitialValueZero (t * testing.T ) {
117+ bsi := NewDefaultBSI ()
118+ bsi .SetBigValue (1 , big .NewInt (0 ))
119+ assert .Equal (t , 1 , bsi .BitCount ())
120+ }
121+
115122func TestRangeBig (t * testing.T ) {
116123
117124 bsi := NewDefaultBSI ()
@@ -262,15 +269,11 @@ func TestNewBSI(t *testing.T) {
262269 bsi = NewDefaultBSI ()
263270 assert .Equal (t , 0 , bsi .BitCount ())
264271 bsi .SetValue (1 , int64 (0 ))
265- assert .Equal (t , 0 , bsi .BitCount ())
272+ assert .Equal (t , 1 , bsi .BitCount ())
266273 bsi .SetValue (1 , int64 (- 1 ))
267274 assert .Equal (t , 1 , bsi .BitCount ())
268275}
269276
270- func TestStuff (t * testing.T ) {
271-
272- }
273-
274277func TestGE (t * testing.T ) {
275278
276279 bsi := setup ()
You can’t perform that action at this time.
0 commit comments