feat(python): add Bitmap binding for RoaringBitmap#7837
Draft
wjones127 wants to merge 1 commit into
Draft
Conversation
Two sites in python/src/transaction.rs (Index.fragment_ids, and DataOverlayFile.offsets added in lance-format#7540) copy a RoaringBitmap through a Python set/list on every Rust<->Python crossing. This adds a Bitmap type wrapping Arc<RoaringBitmap>, constructible from a Python iterable, range, or pyarrow integer Array/ChunkedArray, with copy-on-write mutation. Both sites now emit/accept Bitmap directly (falling back to plain sets/lists on input for backward compatibility), and the same fix is applied to the two IndexSegment(Description) getters in indices.rs that had the identical set-expansion pattern. Fixes lance-format#7695
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: QUIET Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
Two sites in
python/src/transaction.rscopy aRoaringBitmapthrough a Pythonset/liston every Rust↔Python crossing:IndexMetadata.fragment_bitmap↔Index.fragment_idsDataOverlayFile'sOverlayCoverage↔offsets(added in feat(python): expose DataOverlay commit operation #7540), whosebitmap_from_sorted_offsetshelper has a comment pointing straight at this issueThis adds a
Bitmaptype (lance.bitmap.bitmap) wrappingArc<RoaringBitmap>:range, or an integer pyarrowArray/ChunkedArray(read via a zero-copy buffer, not per-value Python objects).__len__/__contains__/__iter__/__eq__,add/discard/update(copy-on-write viaArc::make_mut), and pickling.Both
transaction.rssites now emitBitmapon output and accept it directly on input (anArcclone instead of a Python-set round trip), while still accepting a plainset/liston input for backward compatibility. The same set-expansion pattern existed in two more places —IndexSegment.fragment_idsandIndexSegmentDescription.fragment_idsinindices.rs(used bylist_indices()/describe_indices()) — so those were switched toBitmaptoo.FragmentMetadata.to_json()normalizesBitmap/List[Bitmap]offsets back to plain (nested) lists of ints for JSON serialization.Fixes #7695
Test plan
python/tests/test_bitmap.py: construction (list/range/pyarrow array of various int widths/chunked array),len/iter/in, equality, pickle round-trip, copy-on-write mutation isolation, error cases (negative values, out-of-range values, nulls).test_dataset.pyoverlay tests to coverBitmap-typedoffsets(dense + sparse) and assert the output type; updated the invalid-offsets error-message assertion.test_indices.py/test_scalar_index.pyto assertIndex.fragment_ids/IndexInformation.fragment_idsareBitmap.cargo fmt --all,cargo clippy -p pylance --lib --tests -- -D warnings,uv run ruff format/ruff check,uv run pyrightall clean.