Repository navigation
Fix BSI CompareValue for negative values and for foundSet columns without a value - #598
Open
Assertive-xxh wants to merge 1 commit into
Open
Assertive-xxh wants to merge 1 commit into
Assertive-xxh wants to merge 1 commit into
Conversation
Three results of CompareValue were wrong (RoaringBitmap#583): - RANGE left the bit loop as soon as one bound was decided and treated the other bound as equal, so with negative values it could return every column. - A stored value and a bound of opposite signs and equal magnitude compared as equal, because the bound was negated before the bitwise comparison: EQ -100 also matched 100, and GT -100 missed it. - Columns of foundSet that hold no value were compared as if they held zero. The per-column comparison now orders values of opposite signs by sign alone and compares the remaining bits as unsigned, so no bound is negated, and RANGE follows both bounds in one pass. foundSet is intersected with the existence bitmap. roaring64 only had the foundSet problem, on the big-value path. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes the two
CompareValueproblems reported in #583, and a third one that the test for them turned up.Type of Change
Changes Made
What was changed?
BitSliceIndexing: rewrote the per-column comparison incompareValue.BitSliceIndexingandroaring64:CompareValueintersectsfoundSetwith the existence bitmap.bsi_edgecases_test.goandroaring64/bsi64_test.go.Why was it changed?
-5, 3, -100stored,RANGE [-10, 0]returned all three columns.foundSetthat holds no value was compared as if it held zero, soGE 0,LT 15andRANGE [0, 100]returned it.100and-100stored,EQ -100returned both columns andGT -100missed100.How was it changed?
MinInt64).roaring64had problem 2 only, on the big-value path (a BSI with 64 planes). The int64 path already intersected.Testing
TestBSICompareValueIssue583has the cases from the issue plus the opposite-sign case.TestBSICompareValueMatchesNaive(both packages) checks all six operations against a plain comparison of the stored values, over mixed-sign values includingMinInt64andMaxInt64, with and without afoundSetthat contains columns holding no value.go test,go test ./roaring64andgo test ./BitSliceIndexingpass on Windows amd64 with Go 1.24.4 and 1.25, and withGOARCH=386. Thearmandarm64builds pass. The ppc64 test binaries compile; I could not run them.Formatting
gofmt -s -landgo tool unconvert ./...report nothing.Fuzzing
go test -run='^$' -fuzz=FuzzSmatreports "no fuzz tests to fuzz" for me on master, so I ran what I could find:go test -tags=gofuzz -run Smatpasses, andFuzzBsiStreamingran for 60s without a failure. Neither of them callsCompareValue.Performance Impact
The number of
Containscalls per column is unchanged. A non-nilfoundSetcosts one extraAnd.Before:
After: