Improve roaring64 BSI value access and min/max - #544
Merged
Conversation
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
This PR adds a typed batch value-read API for
roaring64.BSIand optimizes BSI min/max selection. It keeps existing public method signatures intact while adding an int64-oriented read path and replacing row-by-rowMinMaxBigvalue reconstruction with bitmap plane pruning.Type of Change
Changes Made
What was changed?
GetValues(columnIDs []uint64) ([]int64, []bool)for aligned batch reads from int64-width BSIs.GetBigValues.MinMaxBigto prune candidate rows by sign and value bit planes, then decode one surviving value, instead of reconstructing every candidate row value.GetValues, duplicate/missing reads, subset min/max, and large-value min/max.Why was it changed?
Both paths avoid common row-by-row BSI value loops.
GetValueslets int64 callers avoid allocatingbig.Intvalues for every row. TheMinMaxBigchange keeps the existing API but changes the implementation to use bitmap algebra directly, which is much cheaper for large found sets.How was it changed?
GetValuesuses the same aligned found-set/position map used byGetBigValues, then fills primitiveint64andboolslices from intersected bit planes.MinMaxBigfirst intersects the requested found set with the BSI existence bitmap. It then narrows candidates by sign plane and descending value planes according to the requestedMINorMAX, and finally callsGetBigValueon one remaining candidate.Testing
Formatting
gofmtwas run on the touched Go files.Fuzzing
Not run for this change. The touched code is covered by deterministic correctness tests over signed values, missing values, duplicate inputs, subset found sets, and wider-than-int64 BSI values.
Performance Impact
Environment: linux/amd64, Go toolchain from local development machine, Intel Core i7-1255U.
BenchmarkBSI64MinMaxBiguses 1,000,000 rows with low-cardinality int64 values and computes both min and max per operation.Before, at current
master(438e356) with only the benchmark fixture copied in:After:
Candidate value-read benchmarks on a 100,000-row fixture:
Breaking Changes
None.
Compatibility
GetValuesis additive.GetBigValuesremains available for callers that need arbitrary-widthbig.Intvalues.MinMaxBigpreserves the existing API and result type.MinMaxBigpreserves the previous sentinel behavior.Related Issues
None.
Additional Notes
The PR is intentionally split into two commits so the additive typed read API and the min/max implementation change can be reviewed independently.