Repository navigation
refactor(index): pass index_version into ScalarIndexPlugin::load_index - #9518
Conversation
There was a problem hiding this comment.
❌ Gate recommendation: request changes.
Passing each segment's persisted version to its scalar loader is a sound way to support format-aware reads without changing ordinary index storage. Please complete the in-tree trait migration so the crate builds. The JSON wrapper also needs the target's actual format version before the stacked BTree format change relies on it.
Please mark this PR with the breaking-change label.
| &self, | ||
| index_store: Arc<dyn IndexStore>, | ||
| index_details: &prost_types::Any, | ||
| index_version: u32, |
There was a problem hiding this comment.
This new argument leaves MinHashLshIndexPlugin::load_index at the old signature, so lance-index cannot build. The call in rust/lance-index/benches/btree.rs:203 also still omits the version; please update both sites. Reproducer run on this head: cargo check -p lance-index --tests --benches. It should complete, but fails with E0050: method load_index has 5 parameters but ... trait ... has 6 in the MinHash LSH plugin.
There was a problem hiding this comment.
The migration still prevents lance-index from building at e51388c. The new load_index_with_remapping argument also needs to be added to the Bitmap, BloomFilter, BTree, Inverted, LabelList, NGram, and ZoneMap overrides. The geo-gated RTree override has the same old signature. MinHash LSH and the BTree benchmark call noted above remain unchanged.
Reproducer run on this head with Rust 1.98.1: cargo check -p lance-index --tests --benches. Expected: success. Observed: eight E0050 errors in the default build, covering MinHash LSH and the seven remapping overrides. Complete both loader signature migrations and the remaining call site.
There was a problem hiding this comment.
Fixed in d06342c: the reported loader signatures, including the remapping overrides, and the BTree benchmark call are updated. cargo check -p lance-index --tests --benches now completes successfully with Rust 1.98.1.
| .load_index( | ||
| index_store, | ||
| target_details, | ||
| target_plugin.version(), |
There was a problem hiding this comment.
version() is the target plugin's maximum supported format, not the format persisted for this nested index. Those already differ for default Inverted indexes (written as V2 while the plugin advertises V3). Current loaders ignore the new argument, but the stacked BTree change uses it to distinguish stored row IDs from addresses: an existing JSON/BTree target written as V0 would be passed V1. Preserve or infer the target's own version before that change begins using this value.
5f1254c to
fab0ebc
Compare
fab0ebc to
e60702c
Compare
e60702c to
e51388c
Compare
Thread the segment's own persisted IndexMetadata::index_version through load_index (the only caller, open_scalar_index, already has it). Every plugin ignores the new parameter for now -- none has more than one on-disk format yet -- except JsonIndexPlugin, which forwards its target plugin's own current version rather than its own (JsonIndexDetails does not yet record the target's actual version; every target it builds comes from a fresh training pass in this codebase, so this is accurate today). Pure plumbing: no plugin's behavior changes. Lays the groundwork for a plugin whose on-disk format has changed over time (e.g. which domain a stored row identifier is in) to read an older segment correctly instead of reinterpreting it under the newest format.
Several load_index/load_index_with_remapping overrides were not updated for the new index_version parameter added to the trait, breaking the build. Also applies cargo fmt to the affected call sites. Co-Authored-By: Claude Sonnet 5 <[email protected]>
A test literal still used the old conflicting_frag_reuse_indices field name after it was renamed to frag_reuse_base in #9620, breaking the build for every PR rebased onto main. Co-Authored-By: Claude Sonnet 5 <[email protected]>
d06342c to
b54470b
Compare
There was a problem hiding this comment.
The loader migration remains complete after rebasing onto the current base. Passing each segment's persisted version to both loader entry points provides the needed format context without changing current readers' behavior.
The JSON target-version risk remains non-blocking here because current readers ignore the argument. For dependent #9481, preserve or infer the nested target's stored version before using it to distinguish row IDs from addresses.
Another in-flight PR added this call site against the pre-#9518 load_index signature; the squash-merge landed it without the new index_version parameter, breaking main's build. Co-Authored-By: Claude Sonnet 5 <[email protected]>
## Summary - Follow-up to #9518 (merged). Addresses the non-blocking risk the gatekeeper flagged there: `JsonIndexPlugin::load_index` passed `target_plugin.version()` (the target plugin's current max format version) instead of the version the target index was actually persisted at, since `JsonIndexDetails` never recorded it. - Adds an optional `target_index_version` field (field 4) to `JsonIndexDetails`, populated from `CreatedIndex::index_version` whenever the wrapper trains, remaps, or updates its target. `load_index` now reads it, falling back to the target plugin's current version only for details written before this field existed (matching the previous, safe-for-now behavior for old data). - Drops the now-stale note in the `target_data_type` docs saying these details do not record the target's format version. - This matters for the stacked [BTree format change](#9481), which will use the passed-in version to distinguish stored row IDs from row addresses. ## Test plan - `cargo clippy -p lance-index -p lance --tests -- -D warnings` clean - `cargo fmt --all -- --check` clean - `cargo test -p lance-index --lib scalar::json::` — 27 passed 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018BsnoP9ZPMX6vhJSygzdnN --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
The load_index method had no visibility into the index version. This made it impossible
to change index behavior based on the version when opening an index. This could be worked
around by always modifying the proto when you modify the version. However, that leads to
some redundancy and it seems easier to just let the load_index method see the version.
BREAKING CHANGE: This is technically a minor breaking change since a public trait (the index trait) is being modified and so any downstream implementers (none that I know of) would be affected.
Stack created with GitHub Stacks CLI • Give Feedback 💬