Skip to content

Exclude foundSet columns without a value from BSI CompareValue - #614

Merged
lemire merged 2 commits into
masterfrom
bsi-comparevalue-foundset
Dec 5, 2026
Merged

lemire merged 2 commits into
masterfrom
bsi-comparevalue-foundset

Conversation

@lemire

@lemire lemire commented Dec 4, 2026

Copy link
Copy Markdown
Member

This carries over the part of #598, by @Assertive-xxh, that master still needs. The commit is authored by them.

Bug (#583, problem 2)

A column of foundSet that holds no value was compared as if it held zero:

b := NewDefaultBSI()
b.SetValue(1, 10)
b.SetValue(2, 20)
fs := roaring.BitmapOf(1, 2, 99)
b.CompareValue(0, GE, 0, 0, fs)      // [1 2 99], expected [1 2]
b.CompareValue(0, LT, 15, 0, fs)     // [1 99],   expected [1]
b.CompareValue(0, RANGE, 0, 100, fs) // [1 2 99], expected [1 2]

Fix

Intersect foundSet with the existence bitmap in BitSliceIndexing CompareValue and in roaring64 CompareBigValue (the path for BSIs with 64 or more planes). The int64 path of roaring64 already did this.

Relation to #598

#598 also rewrote the per-column comparison in BitSliceIndexing to fix RANGE with negative values and the comparison of values with opposite signs (#583 problems 1 and 3). #606 has since fixed those on master with a different rewrite, so this PR keeps only:

On master, the tests fail only on the foundSet cases, and only because of this bug. Their sign cases, including MinInt64 and MaxInt64, already pass there, so they now also guard the #606 fix.

Testing

go test ./BitSliceIndexing ./roaring64, go vet and gofmt pass.

Fixes #583

Assertive-xxh and others added 2 commits December 4, 2026 18:48
A column of foundSet that holds no value was compared as if it held
zero, so GE 0, LT 15 and RANGE [0, 100] returned it. Intersect foundSet
with the existence bitmap in BitSliceIndexing CompareValue and in
roaring64 CompareBigValue. The int64 path of roaring64 already did.

Add TestBSICompareValueIssue583 and TestBSICompareValueMatchesNaive, which
check all six operations against a plain comparison of the stored values,
over mixed-sign values including MinInt64 and MaxInt64, with and without
a foundSet that has columns holding no value.

This is the part of #598 that #606 did not already fix.

Fixes #583
@lemire
lemire merged commit a673f61 into master Dec 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BSI CompareValue: RANGE is wrong with negative values, and foundSet columns absent from the BSI are returned

2 participants