refactor(index)!: move distributed BTree build to segmented index framework#7013
Open
zhangyue19921010 wants to merge 3 commits into
Open
refactor(index)!: move distributed BTree build to segmented index framework#7013zhangyue19921010 wants to merge 3 commits into
zhangyue19921010 wants to merge 3 commits into
Conversation
24 tasks
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Overview
This is a refactor PR that wires the BTree scalar index's distributed build flow into
Lance's existing segmented-index framework, and retires the legacy BTree
range_idsharding +merge_index_metadatapath.The new distributed build flow: each worker builds one canonical segment for its assigned
fragment_idswithout committing it, and the driver publishes them all at once viacommit_existing_index_segments(...). Passingfragment_idsis what triggers the skip-commitsegment build; the per-language entry points are:
create_index_uncommitted(column, "BTREE", fragment_ids=[...])— returns the uncommittedsegment
Index. (create_scalar_index(..., "BTREE", fragment_ids=...)is no longer the distributed entry — see below.)createIndex(IndexOptions.builder(...).withFragmentIds([...]).build())— returns thesegment
Index.CreateIndexBuilder::new(...).fragments(vec![...]).execute_uncommitted().The old "distributed write of
part_*shards + a finalmerge_index_metadata" path is gone.Compatibility Impact (Review Focus)
API soft-break:
merge_index_metadata(BTree)Dataset::merge_index_metadata(..., IndexType::BTree)(and JavaDataset.mergeIndexMetadata(BTREE),Python
merge_index_metadata(index_type="BTREE")) now returns an error directly, withmigration guidance. Callers that previously relied on "distributed write of
part_*+merge_index_metadatato commit" are broken explicitly (rather than silently producing wrongresults).
Migration: build one segment per fragment group with
create_index_uncommitted(..., "BTREE", fragment_ids=...)and publish them withcommit_existing_index_segments(...); to consolidatemultiple segments into fewer/one, use
merge_existing_index_segments(...)(BTree support comes inPR2).
Distributed BTree builds move to
create_index_uncommitted(Python)Distributed BTree segments are now built through
create_index_uncommitted(column, "BTREE", fragment_ids=[...]).create_scalar_index(..., "BTREE", fragment_ids=...)(and theIndexConfigequivalent) is now rejected with an error pointing tocreate_index_uncommitted. Non-distributedcreate_scalar_index("BTREE")(nofragment_ids) isunchanged and still commits a single canonical index. Java has no separate scalar entry, so its
distributed entry stays
createIndex(...withFragmentIds...).range_iddeprecatedBTree
range_id(RustBTreeParameters::range_id, JavaBTreeIndexParams.rangeId) isdeprecated: if
Some(..)is detected at build time, awarn!migration hint is logged and thevalue is then ignored, still producing a canonical segment (lossless, no error). The field is
retained (not physically removed) so that stale inputs are flagged loudly rather than silently
dropped by serde; it will be removed in a future release.
A pre-sorted data stream is still supported via Rust
preprocessed_data/ JavawithPreprocessedData(the Python API does not take a reader). Pass it together withfragment_idsso the resulting segment is uncommitted and scoped to those fragments.
Behavior change: distributed semantics change
In the segmented case, distributed builds move from "a single index written in a distributed
fashion, then a final merge" to "creating multiple independent segments in a distributed
fashion" — each worker produces one canonical segment with exactly one
page_lookup.lance+one
page_data.lanceper segment, and no more internalpart_*shards. At query time thesegments of one logical index are unioned automatically.
Historical compatibility: old layouts remain readable and remappable
The read and compaction remap paths for already-persisted range /
part_*legacy indexlayouts are fully preserved, to maintain backward compatibility.
Example