Skip to content

Commit 84c242d

Browse files
authored
Merge pull request #460 from RoaringBitmap/fix-459
Fix 459
2 parents b32ae1a + c1e731e commit 84c242d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

roaring64/bsi64.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func (b *BSI) CompareBigValue(parallelism int, op Operation, valueOrStart, end *
318318
if valueOrStart == nil {
319319
valueOrStart = b.MinMaxBig(parallelism, MIN, &b.eBM)
320320
}
321-
if end == nil {
321+
if end == nil && op == RANGE {
322322
end = b.MinMaxBig(parallelism, MAX, &b.eBM)
323323
}
324324

@@ -386,7 +386,10 @@ func compareValue(e *task, batch []uint64, resultsChan chan *Bitmap, wg *sync.Wa
386386
}
387387

388388
startIsNegative := e.valueOrStart.Sign() == -1
389-
endIsNegative := e.end.Sign() == -1
389+
endIsNegative := true
390+
if e.end != nil {
391+
endIsNegative = e.end.Sign() == -1
392+
}
390393

391394
for i := 0; i < len(batch); i++ {
392395
cID := batch[i]
@@ -399,7 +402,7 @@ func compareValue(e *task, batch []uint64, resultsChan chan *Bitmap, wg *sync.Wa
399402
if isNegative != startIsNegative {
400403
compStartValue = twosComplement(e.valueOrStart, e.bsi.BitCount()+1)
401404
}
402-
if isNegative != endIsNegative {
405+
if isNegative != endIsNegative && e.end != nil {
403406
compEndValue = twosComplement(e.end, e.bsi.BitCount()+1)
404407
}
405408

@@ -735,12 +738,12 @@ func (b *BSI) ParOr(parallelism int, bsis ...*BSI) {
735738
bits := len(b.bA)
736739
for i := 0; i < len(bsis); i++ {
737740
if len(bsis[i].bA) > bits {
738-
bits = bsis[i].BitCount()
741+
bits = len(bsis[i].bA )
739742
}
740743
}
741744

742745
// Make sure we have enough bit slices
743-
for bits > b.BitCount() {
746+
for bits > len(b.bA) {
744747
bm := Bitmap{}
745748
bm.RunOptimize()
746749
b.bA = append(b.bA, bm)

0 commit comments

Comments
 (0)