feat: add segmented BTree index planning and merge support#6889
Open
zhangyue19921010 wants to merge 10 commits into
Open
feat: add segmented BTree index planning and merge support#6889zhangyue19921010 wants to merge 10 commits into
zhangyue19921010 wants to merge 10 commits into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
6 tasks
24 tasks
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.
Closes: #6979
PAY ATTENTION
Refactored scalar index optimize logic in
append.rs:Extracted
merge_scalar_indicesunified function — consolidates all scalar index merge logic frommerge_indices_with_unindexed_fragsinto a reusable function with explicit segment selection.Added
BTreeIndex::merge_segments— k-way segment merge for BTree, enabling multi-segment consolidation without re-reading the dataset.BTree append mode now creates delta segments —
num_indices_to_merge=0builds an index only for unindexed fragments, preserving existing segments (reduces write amplification).Non-BTree types (like Bitmap/LabelList) behavior preserved — On main, these types always maintain a single segment: every optimize call (regardless of
num_indices_to_merge) merges old index + new data into one segment viaupdate(). This PR preserves that exact behavior. Additionally, a safety guard rejects multi-segment state for these types with a clear error, since they lack merge N primitives and should never accumulate multiple segments.Compatibility Testing
Context
Main branch ignores
num_indices_to_mergefor scalar indices — all modes behave identically (always merge the single old segment + new data → 1 segment). Multi-segment scalar index is a state that cannot exist on main.Test Results (single-segment starting state, which is the only state main can produce)
PR-only new behavior: multi-segment BTree scenarios (unreachable on main)
After accumulating N segments via repeated append-mode optimizes:
Query correctness: All combinations verified — no data loss or incorrect results.