Repository navigation
refactor(index): share scalar segment merge scaffolding - #11402
Merged
Merged
Conversation
Move the inputs and output shape every scalar segment merge repeats into one module: field and declaration checks, the row-domain guard, per-segment filters, source opening, index store allocation, and metadata assembly. Bitmap no longer builds its empty stream through btree, and the append merge path builds filters once for all simple merge primitives.
Only a stable-row-id table must reject a pre-migration v0 segment: without stable row ids its stored ids are addresses, so a v0 and a v1 segment with disjoint coverage merge into one v1 segment. Restore that admission rule so explicit staged merges and distributed optimize keep working. Keep the stable-row-id rejection in the per-type guard for Bitmap, BTree, LabelList and MinHash, so their bottom-level mixed-domain checks retain the existing error class. Drop the synthetic Bitmap relabeling test and extend the MinHash legacy test through merge, commit, reopen and fast_search for both source fragments. Simplify open_sources through open_source, and remove ensure_details now that the only caller dispatches by details first.
The explicit index name now belongs to the committed v0 segment, so the disjoint current v1 builder must opt into replacing that name before its uncommitted segment can be merged.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
BubbleCal
approved these changes
Nov 24, 2026
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.
Problem
Every scalar index merge repeated the same field and declaration validation, row-domain guard, per-segment filters, destination store allocation, source opening/downcast, and
IndexMetadataassembly. Bitmap also depended on btree for its empty new-data stream, and append's merge dispatch rebuilt the same filters per arm.Change
Add
scalar/segment_merge.rsto own the shared merge inputs and output:All scalar merge modules now use it; Bitmap no longer reaches into btree.
append.rsconstructs filters once for the simple merge primitives. MinHash keeps its historical admission rule: non-stable tables can merge disjoint v0 and v1 segments into v1, while stable tables still reject legacy input.No public API, persisted format, or Python wrapper changes. #11273, #11231 and #11280 are complementary and not dependencies; their behaviors are not pulled in here. Overlap is mechanical in the same scalar modules and append dispatch. Current main's #11290 only changes tagged FRI retention bookkeeping and #11391 changes commit configuration; neither changes a caller contract used by this change.
Validation
cargo fmt --all -- --check: passcargo clippy --all --tests --benches --profile ci -j 4 -- -D warnings: pass (only existing lance-linalg build-script notices)d23cbafd5, one test executable, 49 unique tests:fast_searchfor both stable and non-stable datasets, plus the historical-layout legacy regressionindex::tests::merge: 8 passedNo released MinHash v0 fixture exists; the v0 layout is reconstructed from a current segment (
_rowid, version 0) by the test helper. The test exercises real merge, commit, reopen and search rather than mocked metadata.Remaining coverage: the full workspace test matrix and a Python wheel were not run. The Python wrapper is unchanged, and the mixed historical layout is not constructible through it.
Clean merge tree with current main
e90fe4b8e7c8c819bb51171a43fc94d01b40e2c7:bdbb1029cd3e7ab3a54ac3036d258cd4e6dcbcaa.