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) {
97
97
// If max/min values are set to zero then automatically determine bit array size
98
98
if b .MaxValue == 0 && b .MinValue == 0 {
99
99
minBits := value .BitLen () + 1
100
+ if minBits == 1 {
101
+ minBits = 2
102
+ }
100
103
for len (b .bA ) < minBits {
101
104
b .bA = append (b .bA , Bitmap {})
102
105
}
Original file line number Diff line number Diff line change @@ -112,6 +112,13 @@ func TestSetAndGetBigTimestamp(t *testing.T) {
112
112
assert .Equal (t , 67 , bsi .BitCount ())
113
113
}
114
114
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
+
115
122
func TestRangeBig (t * testing.T ) {
116
123
117
124
bsi := NewDefaultBSI ()
@@ -262,15 +269,11 @@ func TestNewBSI(t *testing.T) {
262
269
bsi = NewDefaultBSI ()
263
270
assert .Equal (t , 0 , bsi .BitCount ())
264
271
bsi .SetValue (1 , int64 (0 ))
265
- assert .Equal (t , 0 , bsi .BitCount ())
272
+ assert .Equal (t , 1 , bsi .BitCount ())
266
273
bsi .SetValue (1 , int64 (- 1 ))
267
274
assert .Equal (t , 1 , bsi .BitCount ())
268
275
}
269
276
270
- func TestStuff (t * testing.T ) {
271
-
272
- }
273
-
274
277
func TestGE (t * testing.T ) {
275
278
276
279
bsi := setup ()
You can’t perform that action at this time.
0 commit comments