Repository navigation
feat(index)!: change ngram, rtree, and minhash lsh scalar indexes to row-address domain - #9858
Conversation
cf543a7 to
350daad
Compare
64ed39c to
52ca5df
Compare
598bfa2 to
f4c2d51
Compare
44ce8bb to
204c961
Compare
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.
| Some(crate::scalar::bitmap::BITMAP_ROW_ID_DOMAIN_VERSION) | ||
| } else if target_details.type_url.ends_with("LabelListIndexDetails") { | ||
| Some(crate::scalar::label_list::LABEL_LIST_ROW_ID_DOMAIN_VERSION) | ||
| } else { |
There was a problem hiding this comment.
I think we also need ngram and rtree here in this list, since these now have row addrs too.
Locally I tried an append followed by optimize_indices and it left the old JSON wrapped NGram segment alongside the new one. The commit failed because the segments mixed row IDs and row addresses.
| // data onto a row-id-domain segment (valid without stable row | ||
| // ids, where a row id already is a row address) must not | ||
| // silently flip it to address domain. | ||
| index_version: minhash_lsh_index_version(self.results_are_row_addresses), |
There was a problem hiding this comment.
I see we're keeping the source version here, but rebuild_from always writes version 1. For a legacy MinHash segment without stable row IDs, that leaves version 0 in the manifest and 1 in the file. Queries still work since the IDs and addresses are the same, but should these match?
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The plugin-loaded version checks and NGram compaction cases pass. MinHash’s dataset-aware merge guard preserves the legacy safety boundary while allowing safe merges when row IDs equal addresses. No blocking items remain.
wjones127
left a comment
There was a problem hiding this comment.
Thanks for turning the last round around so quickly. Every point is addressed: the RTree and NGram tests now load through the plugin at v0 and v1, the description and eager NGram test agree, the MinHash v0 decision sits with the caller, RTreeIndex::load documents its scope, and the v0 FRI case is back.
Approving. Two small follow-ups inline: moving the MinHash guard newly allows a v0 merge on datasets without stable row ids, which has no test yet, and a couple of comments around it are now stale.
| /// segment this old would still exist -- and check the merge is refused | ||
| /// instead. | ||
| #[tokio::test] | ||
| async fn test_merge_rejects_legacy_row_id_domain_segment() { |
There was a problem hiding this comment.
issue(non-blocking): Moving the guard into merge_segments means a v0 segment on a dataset without stable row ids now merges and comes out as v1, where before it was rejected. I agree that's safe, but nothing exercises it. This test already builds the v0 fixture, so could it be parameterized over enable_stable_row_ids? With true, the merge is refused as it is now. With false, the stored ids stay as addresses, the merge succeeds, the merged segment has index_version == 1, and search_ids returns the same rows as before. The doc comment above ("experimental and has no compatibility path ... unconditionally reads") also predates the move and should describe the stable-row-id condition instead.
| ))); | ||
| } | ||
| let segment_refs: Vec<&IndexMetadata> = segments.iter().collect(); | ||
| // MinHash LSH only reads its current format, which stores row addresses. |
There was a problem hiding this comment.
nitpick: Now that a v0 segment can reach this point on a dataset without stable row ids, this comment is no longer accurate. Passing true is still right, since ids equal addresses there.
| // MinHash LSH only reads its current format, which stores row addresses. | |
| // Every segment here stores row addresses, or (without stable row ids) | |
| // row ids that equal them, so the filters are built in the address domain. |
…w ids (#11019) ## Summary This follows up on #9858 and addresses the two review comments posted just before it merged: - `test_merge_rejects_legacy_row_id_domain_segment` is now `test_merge_legacy_row_id_domain_segment`, parametrized over `enable_stable_row_ids` ([comment](#9858 (comment))). - `true`: merging the hand-built v0 segment is still refused with `InvalidInput`, and queries are unchanged. - `false`: the v0 segment's stored ids are addresses, which is what a pre-migration segment holds without stable row ids. The merge succeeds and writes `index_version == MINHASH_LSH_INDEX_VERSION`, and after commit `search_ids` returns the same rows as before. - The test's doc comment now describes the stable-row-id condition instead of the "no compatibility path" wording, which predated moving the guard into `merge_segments`. - The comment on `build_per_segment_filters` in MinHash `merge_segments` now says a v0 segment can reach it without stable row ids, where ids equal addresses ([comment](#9858 (comment))). --- _Generated by [Claude Code](https://claude.ai/code/session_01Y3hhWhSPAggJTKAWR32ivc)_ --------- Co-authored-by: Claude <[email protected]>
Stacked on #9858 (NGram/RTree/MinHash LSH), stacked on #9814 (Bitmap/LabelList), stacked on #9481 (BTree). This completes the scalar-index migration: Inverted was the last builtin scalar index type still in the row-id domain, and now stores physical row addresses (fragment_id << 32 | offset) in docs.lance's identity column (still named `_rowid`) instead of row ids. - New INVERTED_ROW_ADDR_DOMAIN_VERSION (4), orthogonal to the posting-list format axis (tracked separately via file metadata, not index_version). - index_version()/results_are_row_addrs()/can_follow_stable_row_ids() gate on it; build_scalar_index relabels a fresh build back to the legacy version on a non-stable-row-id dataset, matching every other migrated type. - append.rs/scalar/inverted.rs: old-data filters and legacy-domain-mismatch rebuild now use the segment's own domain instead of a hardcoded row-id assumption, fixing a real bug where a stale posting after an in-place update under stable row ids leaked through a merge. - FTS's own deletion/filter/overlay masks (DatasetPreFilter, IndexVisibility) are checked directly against an address-domain index's own stored addresses, before any row-id translation -- they now translate the row-id-domain conventions every other mask follows into that same domain instead of silently comparing unrelated numeric spaces. - create.rs no longer refuses creating an Inverted index under a live fragment reuse index: it applies to Inverted like every other scalar type now. - Updated or replaced tests that assumed Inverted was "the last row-id-domain index" across append.rs, create.rs, frag_reuse_with_stable_row_ids.rs, dataset/optimize/tests, dataset/write/update.rs, and index/tests/lifecycle.rs, largely via the manual legacy-segment-relabel pattern already used for the prior migrations. Added an Inverted case to a few other-type-parametrized tests confirming it now behaves like every other address-domain index. - New Python compat test InvertedRowAddressDomainIndex; format docs updated. Known gap: a latent gap in compaction's eager-remap-vs-unreadable-index path (planning.rs's `unreadable_coverage` hold-back only applies without stable row ids) was exposed by this migration removing the last index type that could dodge it, but predates this PR and affects every address-domain index type, not just Inverted -- flagged separately for follow-up. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Stacked on #9858 (NGram/RTree/MinHash LSH), stacked on #9814 (Bitmap/LabelList), stacked on #9481 (BTree). This completes the scalar-index migration: Inverted was the last builtin scalar index type still in the row-id domain, and now stores physical row addresses (fragment_id << 32 | offset) in docs.lance's identity column (still named `_rowid`) instead of row ids. - New INVERTED_ROW_ADDR_DOMAIN_VERSION (4), orthogonal to the posting-list format axis (tracked separately via file metadata, not index_version). - index_version()/results_are_row_addrs()/can_follow_stable_row_ids() gate on it; build_scalar_index relabels a fresh build back to the legacy version on a non-stable-row-id dataset, matching every other migrated type. - append.rs/scalar/inverted.rs: old-data filters and legacy-domain-mismatch rebuild now use the segment's own domain instead of a hardcoded row-id assumption, fixing a real bug where a stale posting after an in-place update under stable row ids leaked through a merge. - FTS's own deletion/filter/overlay masks (DatasetPreFilter, IndexVisibility) are checked directly against an address-domain index's own stored addresses, before any row-id translation -- they now translate the row-id-domain conventions every other mask follows into that same domain instead of silently comparing unrelated numeric spaces. - create.rs no longer refuses creating an Inverted index under a live fragment reuse index: it applies to Inverted like every other scalar type now. - Updated or replaced tests that assumed Inverted was "the last row-id-domain index" across append.rs, create.rs, frag_reuse_with_stable_row_ids.rs, dataset/optimize/tests, dataset/write/update.rs, and index/tests/lifecycle.rs, largely via the manual legacy-segment-relabel pattern already used for the prior migrations. Added an Inverted case to a few other-type-parametrized tests confirming it now behaves like every other address-domain index. - New Python compat test InvertedRowAddressDomainIndex; format docs updated. Known gap: a latent gap in compaction's eager-remap-vs-unreadable-index path (planning.rs's `unreadable_coverage` hold-back only applies without stable row ids) was exposed by this migration removing the last index type that could dodge it, but predates this PR and affects every address-domain index type, not just Inverted -- flagged separately for follow-up. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ead (#10776) ## Why The scalar index benchmarks should run to completion. Four bench targets panicked in their first benchmark, because each one fed its trainer a stream with column names the trainer does not read. - `lance` `scalar_index`. The fixture trained the B-tree from `values` and `row_ids`, but `train_btree_index` reads `value` and `_rowaddr`. Training has looked up `value` by name since #4584, and #9481 moved the row column from `_rowid` to `_rowaddr`. - `lance-index` `btree` and `bitmap`. The shared generators in `benches/common.rs` wrote `_rowid`. The B-tree trainer has read `_rowaddr` since #9481, and the bitmap trainer has since #9814. - `lance-index` `ngram`. The bench named its text column `doc`, but `NGramIndexBuilder::train` has looked up `value` since #4584. ## What changed - In `scalar_index.rs`, `test_data` takes the value and row column names. The training stream passes `VALUE_COLUMN_NAME` and `ROW_ADDR`. The dataset keeps `values` and `row_ids`, so the baseline benchmarks scan the same data as before. - In `common.rs`, the five generators write `ROW_ADDR` instead of `_rowid`. - In `btree.rs`, the ordered-search benchmark had its own copy of `generate_int_unique_stream` with a `_rowaddr` column. It now calls the shared generator, and the imports that only the copy used are gone. - In `ngram.rs`, the text column is `VALUE_COLUMN_NAME`. The row column stays `ROW_ADDR`, which main already used after #9858 moved NGram to the row-address domain. ## Scope - Only bench files change. The benchmarks, their queries, and their assertions stay the same. - The `zonemap`, `bloomfilter`, `inverted`, `geo`, and `minhash_lsh` benches already write the columns their trainers read, so they do not change. - A missing row column still fails B-tree and bitmap training with the vague error `Expected option to have value`. A schema check with a clear message belongs in the trainers, in a separate change. ## Tradeoffs - The `scalar_index` dataset cannot use the training names, because Lance rejects a stored column named `_rowaddr`. - A second generator for the `scalar_index` training stream would repeat the row and batch counts that every assertion depends on. ## Blast radius The change touches bench code only. Library code, the file format, and tests do not change. ## Verification The branch is merged with `main` at `01036bf80`. Every command below ran in criterion test mode on that merged tree with `--profile ci --locked`, and each benchmark reports `Success`, so this covers the fixture generation and trainer calls rather than compilation alone. - `cargo test --profile ci --locked -p lance-index --bench btree`: 84 `Success`, including `btree_ordered_first_k` and `tuple_planning`. - `cargo test --profile ci --locked -p lance-index --bench bitmap`: 40 `Success`. - `cargo test --profile ci --locked -p lance-index --bench ngram`: 2 `Success` (`ngram_train`, `ngram_search`). - `cargo test --profile ci --locked -p lance --bench scalar_index`: 5 `Success`, including both baseline scans. - `cargo fmt --all -- --check` and `cargo clippy --profile ci --all --tests --benches --locked -- -D warnings` pass. On the original base, before the fix, `--bench btree` and `--bench bitmap` panicked with `Expected option to have value`, and `--bench ngram` panicked with `Unable to get field named "value"`. --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: Xuanwo <[email protected]>
Upgrade the Rust Lance family from beta.18 to the published v15.0.0-beta.21 tag, and align Python test wheels and Java artifacts. This includes the explicit-empty-segment FTS fix in lance-format/lance#11063 needed by lancedb/sophon#10314. Enable Windows Git long paths so Cargo can check out Lance fixtures in the Rust, NPM and Python wheel builds. Beta.21 also contains lance-format/lance#9858: new NGram, RTree and MinHash LSH indexes use row addresses. Legacy row-ID segments remain readable, but index maintenance on stable-row-ID tables can require a rebuild. The NGram documentation now explains the consolidation requirement; NGram/RTree tables without stable row IDs retain their earlier format. The Python lock revision and unrelated dependency entries are unchanged. Validation: - The official Lance release and internal mirror match 80bc45a195279befdec42853dac8d15a37e0504d. The seven official Fury wheels and Maven POM/JAR were verified. - Exact executable/dependency state 7846a15 completed the full Rust, Python, Node, Java and CLI CI, including platform builds and package publication dry runs. Xuanwo approved that head; Gatekeeper recommended approve with a non-blocking qualification risk. - Follow-up a289cb2 only adds the requested seven-line NGram upgrade note. Static whitespace checks passed; new-head CI is running. No local correctness tests or test builds were run by this task owner. - Broader IVF/encoding/Blob/cache workload performance and the beta.21 Sophon composition remain separately qualified. Earlier Blob cancellation and DynamoDB failures on #4967 are retained in their original evidence; this PR does not count those historical failures as fixed. Current-head CI, full feedback and required review still gate merge. SDK publication is a separate action. Sophon adoption follows a published SDK release and mirror through its own dependency PR; its distributed performance acceptance remains in #10314.
Stacked on #9858 (NGram/RTree/MinHash LSH), stacked on #9814 (Bitmap/LabelList), stacked on #9481 (BTree). This completes the scalar-index migration: Inverted was the last builtin scalar index type still in the row-id domain, and now stores physical row addresses (fragment_id << 32 | offset) in docs.lance's identity column (still named `_rowid`) instead of row ids. - New INVERTED_ROW_ADDR_DOMAIN_VERSION (4), orthogonal to the posting-list format axis (tracked separately via file metadata, not index_version). - index_version()/results_are_row_addrs()/can_follow_stable_row_ids() gate on it; build_scalar_index relabels a fresh build back to the legacy version on a non-stable-row-id dataset, matching every other migrated type. - append.rs/scalar/inverted.rs: old-data filters and legacy-domain-mismatch rebuild now use the segment's own domain instead of a hardcoded row-id assumption, fixing a real bug where a stale posting after an in-place update under stable row ids leaked through a merge. - FTS's own deletion/filter/overlay masks (DatasetPreFilter, IndexVisibility) are checked directly against an address-domain index's own stored addresses, before any row-id translation -- they now translate the row-id-domain conventions every other mask follows into that same domain instead of silently comparing unrelated numeric spaces. - create.rs no longer refuses creating an Inverted index under a live fragment reuse index: it applies to Inverted like every other scalar type now. - Updated or replaced tests that assumed Inverted was "the last row-id-domain index" across append.rs, create.rs, frag_reuse_with_stable_row_ids.rs, dataset/optimize/tests, dataset/write/update.rs, and index/tests/lifecycle.rs, largely via the manual legacy-segment-relabel pattern already used for the prior migrations. Added an Inverted case to a few other-type-parametrized tests confirming it now behaves like every other address-domain index. - New Python compat test InvertedRowAddressDomainIndex; format docs updated. Known gap: a latent gap in compaction's eager-remap-vs-unreadable-index path (planning.rs's `unreadable_coverage` hold-back only applies without stable row ids) was exposed by this migration removing the last index type that could dodge it, but predates this PR and affects every address-domain index type, not just Inverted -- flagged separately for follow-up. Co-Authored-By: Claude Sonnet 5 <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Y3hhWk6pkpoQgZywMu49WT
Stacked on #9858 (NGram/RTree/MinHash LSH), stacked on #9814 (Bitmap/LabelList), stacked on #9481 (BTree). This completes the scalar-index migration: Inverted was the last builtin scalar index type still in the row-id domain, and now stores physical row addresses (fragment_id << 32 | offset) in docs.lance's identity column (still named `_rowid`) instead of row ids. - New INVERTED_ROW_ADDR_DOMAIN_VERSION (4), orthogonal to the posting-list format axis (tracked separately via file metadata, not index_version). - index_version()/results_are_row_addrs()/can_follow_stable_row_ids() gate on it; build_scalar_index relabels a fresh build back to the legacy version on a non-stable-row-id dataset, matching every other migrated type. - append.rs/scalar/inverted.rs: old-data filters and legacy-domain-mismatch rebuild now use the segment's own domain instead of a hardcoded row-id assumption, fixing a real bug where a stale posting after an in-place update under stable row ids leaked through a merge. - FTS's own deletion/filter/overlay masks (DatasetPreFilter, IndexVisibility) are checked directly against an address-domain index's own stored addresses, before any row-id translation -- they now translate the row-id-domain conventions every other mask follows into that same domain instead of silently comparing unrelated numeric spaces. - create.rs no longer refuses creating an Inverted index under a live fragment reuse index: it applies to Inverted like every other scalar type now. - Updated or replaced tests that assumed Inverted was "the last row-id-domain index" across append.rs, create.rs, frag_reuse_with_stable_row_ids.rs, dataset/optimize/tests, dataset/write/update.rs, and index/tests/lifecycle.rs, largely via the manual legacy-segment-relabel pattern already used for the prior migrations. Added an Inverted case to a few other-type-parametrized tests confirming it now behaves like every other address-domain index. - New Python compat test InvertedRowAddressDomainIndex; format docs updated. Known gap: a latent gap in compaction's eager-remap-vs-unreadable-index path (planning.rs's `unreadable_coverage` hold-back only applies without stable row ids) was exposed by this migration removing the last index type that could dodge it, but predates this PR and affects every address-domain index type, not just Inverted -- flagged separately for follow-up. Co-Authored-By: Claude Sonnet 5 <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Y3hhWk6pkpoQgZywMu49WT
Stacked on #9858 (NGram/RTree/MinHash LSH), stacked on #9814 (Bitmap/LabelList), stacked on #9481 (BTree). This completes the scalar-index migration: Inverted was the last builtin scalar index type still in the row-id domain, and now stores physical row addresses (fragment_id << 32 | offset) in docs.lance's identity column (still named `_rowid`) instead of row ids. - New INVERTED_ROW_ADDR_DOMAIN_VERSION (4), orthogonal to the posting-list format axis (tracked separately via file metadata, not index_version). - index_version()/results_are_row_addrs()/can_follow_stable_row_ids() gate on it; build_scalar_index relabels a fresh build back to the legacy version on a non-stable-row-id dataset, matching every other migrated type. - append.rs/scalar/inverted.rs: old-data filters and legacy-domain-mismatch rebuild now use the segment's own domain instead of a hardcoded row-id assumption, fixing a real bug where a stale posting after an in-place update under stable row ids leaked through a merge. - FTS's own deletion/filter/overlay masks (DatasetPreFilter, IndexVisibility) are checked directly against an address-domain index's own stored addresses, before any row-id translation -- they now translate the row-id-domain conventions every other mask follows into that same domain instead of silently comparing unrelated numeric spaces. - create.rs no longer refuses creating an Inverted index under a live fragment reuse index: it applies to Inverted like every other scalar type now. - Updated or replaced tests that assumed Inverted was "the last row-id-domain index" across append.rs, create.rs, frag_reuse_with_stable_row_ids.rs, dataset/optimize/tests, dataset/write/update.rs, and index/tests/lifecycle.rs, largely via the manual legacy-segment-relabel pattern already used for the prior migrations. Added an Inverted case to a few other-type-parametrized tests confirming it now behaves like every other address-domain index. - New Python compat test InvertedRowAddressDomainIndex; format docs updated. Known gap: a latent gap in compaction's eager-remap-vs-unreadable-index path (planning.rs's `unreadable_coverage` hold-back only applies without stable row ids) was exposed by this migration removing the last index type that could dodge it, but predates this PR and affects every address-domain index type, not just Inverted -- flagged separately for follow-up. Co-Authored-By: Claude Sonnet 5 <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Y3hhWk6pkpoQgZywMu49WT
Stacked on #9858 (NGram/RTree/MinHash LSH), stacked on #9814 (Bitmap/LabelList), stacked on #9481 (BTree). This completes the scalar-index migration: Inverted was the last builtin scalar index type still in the row-id domain, and now stores physical row addresses (fragment_id << 32 | offset) in docs.lance's identity column (still named `_rowid`) instead of row ids. - New INVERTED_ROW_ADDR_DOMAIN_VERSION (4), orthogonal to the posting-list format axis (tracked separately via file metadata, not index_version). - index_version()/results_are_row_addrs()/can_follow_stable_row_ids() gate on it; build_scalar_index relabels a fresh build back to the legacy version on a non-stable-row-id dataset, matching every other migrated type. - append.rs/scalar/inverted.rs: old-data filters and legacy-domain-mismatch rebuild now use the segment's own domain instead of a hardcoded row-id assumption, fixing a real bug where a stale posting after an in-place update under stable row ids leaked through a merge. - FTS's own deletion/filter/overlay masks (DatasetPreFilter, IndexVisibility) are checked directly against an address-domain index's own stored addresses, before any row-id translation -- they now translate the row-id-domain conventions every other mask follows into that same domain instead of silently comparing unrelated numeric spaces. - create.rs no longer refuses creating an Inverted index under a live fragment reuse index: it applies to Inverted like every other scalar type now. - Updated or replaced tests that assumed Inverted was "the last row-id-domain index" across append.rs, create.rs, frag_reuse_with_stable_row_ids.rs, dataset/optimize/tests, dataset/write/update.rs, and index/tests/lifecycle.rs, largely via the manual legacy-segment-relabel pattern already used for the prior migrations. Added an Inverted case to a few other-type-parametrized tests confirming it now behaves like every other address-domain index. - New Python compat test InvertedRowAddressDomainIndex; format docs updated. Known gap: a latent gap in compaction's eager-remap-vs-unreadable-index path (planning.rs's `unreadable_coverage` hold-back only applies without stable row ids) was exposed by this migration removing the last index type that could dodge it, but predates this PR and affects every address-domain index type, not just Inverted -- flagged separately for follow-up. Co-Authored-By: Claude Sonnet 5 <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Y3hhWk6pkpoQgZywMu49WT
Stacked on #9858 (NGram/RTree/MinHash LSH), stacked on #9814 (Bitmap/LabelList), stacked on #9481 (BTree). This completes the scalar-index migration: Inverted was the last builtin scalar index type still in the row-id domain, and now stores physical row addresses (fragment_id << 32 | offset) in docs.lance's identity column (still named `_rowid`) instead of row ids. - New INVERTED_ROW_ADDR_DOMAIN_VERSION (4), orthogonal to the posting-list format axis (tracked separately via file metadata, not index_version). - index_version()/results_are_row_addrs()/can_follow_stable_row_ids() gate on it; build_scalar_index relabels a fresh build back to the legacy version on a non-stable-row-id dataset, matching every other migrated type. - append.rs/scalar/inverted.rs: old-data filters and legacy-domain-mismatch rebuild now use the segment's own domain instead of a hardcoded row-id assumption, fixing a real bug where a stale posting after an in-place update under stable row ids leaked through a merge. - FTS's own deletion/filter/overlay masks (DatasetPreFilter, IndexVisibility) are checked directly against an address-domain index's own stored addresses, before any row-id translation -- they now translate the row-id-domain conventions every other mask follows into that same domain instead of silently comparing unrelated numeric spaces. - create.rs no longer refuses creating an Inverted index under a live fragment reuse index: it applies to Inverted like every other scalar type now. - Updated or replaced tests that assumed Inverted was "the last row-id-domain index" across append.rs, create.rs, frag_reuse_with_stable_row_ids.rs, dataset/optimize/tests, dataset/write/update.rs, and index/tests/lifecycle.rs, largely via the manual legacy-segment-relabel pattern already used for the prior migrations. Added an Inverted case to a few other-type-parametrized tests confirming it now behaves like every other address-domain index. - New Python compat test InvertedRowAddressDomainIndex; format docs updated. Known gap: a latent gap in compaction's eager-remap-vs-unreadable-index path (planning.rs's `unreadable_coverage` hold-back only applies without stable row ids) was exposed by this migration removing the last index type that could dodge it, but predates this PR and affects every address-domain index type, not just Inverted -- flagged separately for follow-up. Co-Authored-By: Claude Sonnet 5 <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Y3hhWk6pkpoQgZywMu49WT
Stacked on #9858 (NGram/RTree/MinHash LSH), stacked on #9814 (Bitmap/LabelList), stacked on #9481 (BTree). This completes the scalar-index migration: Inverted was the last builtin scalar index type still in the row-id domain, and now stores physical row addresses (fragment_id << 32 | offset) in docs.lance's identity column (still named `_rowid`) instead of row ids. - New INVERTED_ROW_ADDR_DOMAIN_VERSION (4), orthogonal to the posting-list format axis (tracked separately via file metadata, not index_version). - index_version()/results_are_row_addrs()/can_follow_stable_row_ids() gate on it; build_scalar_index relabels a fresh build back to the legacy version on a non-stable-row-id dataset, matching every other migrated type. - append.rs/scalar/inverted.rs: old-data filters and legacy-domain-mismatch rebuild now use the segment's own domain instead of a hardcoded row-id assumption, fixing a real bug where a stale posting after an in-place update under stable row ids leaked through a merge. - FTS's own deletion/filter/overlay masks (DatasetPreFilter, IndexVisibility) are checked directly against an address-domain index's own stored addresses, before any row-id translation -- they now translate the row-id-domain conventions every other mask follows into that same domain instead of silently comparing unrelated numeric spaces. - create.rs no longer refuses creating an Inverted index under a live fragment reuse index: it applies to Inverted like every other scalar type now. - Updated or replaced tests that assumed Inverted was "the last row-id-domain index" across append.rs, create.rs, frag_reuse_with_stable_row_ids.rs, dataset/optimize/tests, dataset/write/update.rs, and index/tests/lifecycle.rs, largely via the manual legacy-segment-relabel pattern already used for the prior migrations. Added an Inverted case to a few other-type-parametrized tests confirming it now behaves like every other address-domain index. - New Python compat test InvertedRowAddressDomainIndex; format docs updated. Known gap: a latent gap in compaction's eager-remap-vs-unreadable-index path (planning.rs's `unreadable_coverage` hold-back only applies without stable row ids) was exposed by this migration removing the last index type that could dodge it, but predates this PR and affects every address-domain index type, not just Inverted -- flagged separately for follow-up. Co-Authored-By: Claude Sonnet 5 <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Y3hhWk6pkpoQgZywMu49WT
Stacked on #9858 (NGram/RTree/MinHash LSH), stacked on #9814 (Bitmap/LabelList), stacked on #9481 (BTree). This completes the scalar-index migration: Inverted was the last builtin scalar index type still in the row-id domain, and now stores physical row addresses (fragment_id << 32 | offset) in docs.lance's identity column (still named `_rowid`) instead of row ids. - New INVERTED_ROW_ADDR_DOMAIN_VERSION (4), orthogonal to the posting-list format axis (tracked separately via file metadata, not index_version). - index_version()/results_are_row_addrs()/can_follow_stable_row_ids() gate on it; build_scalar_index relabels a fresh build back to the legacy version on a non-stable-row-id dataset, matching every other migrated type. - append.rs/scalar/inverted.rs: old-data filters and legacy-domain-mismatch rebuild now use the segment's own domain instead of a hardcoded row-id assumption, fixing a real bug where a stale posting after an in-place update under stable row ids leaked through a merge. - FTS's own deletion/filter/overlay masks (DatasetPreFilter, IndexVisibility) are checked directly against an address-domain index's own stored addresses, before any row-id translation -- they now translate the row-id-domain conventions every other mask follows into that same domain instead of silently comparing unrelated numeric spaces. - create.rs no longer refuses creating an Inverted index under a live fragment reuse index: it applies to Inverted like every other scalar type now. - Updated or replaced tests that assumed Inverted was "the last row-id-domain index" across append.rs, create.rs, frag_reuse_with_stable_row_ids.rs, dataset/optimize/tests, dataset/write/update.rs, and index/tests/lifecycle.rs, largely via the manual legacy-segment-relabel pattern already used for the prior migrations. Added an Inverted case to a few other-type-parametrized tests confirming it now behaves like every other address-domain index. - New Python compat test InvertedRowAddressDomainIndex; format docs updated. Known gap: a latent gap in compaction's eager-remap-vs-unreadable-index path (planning.rs's `unreadable_coverage` hold-back only applies without stable row ids) was exposed by this migration removing the last index type that could dodge it, but predates this PR and affects every address-domain index type, not just Inverted -- flagged separately for follow-up. Co-Authored-By: Claude Sonnet 5 <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Y3hhWk6pkpoQgZywMu49WT
#11018) ## Summary Completes the scalar-index row-address migration (#9481 BTree → #9814 Bitmap/LabelList → #9858 NGram/RTree/MinHash LSH, all merged): **Inverted (FTS)** was the last builtin scalar index type still in the row-id domain. It now stores physical row addresses (`fragment_id << 32 | offset`) for each document instead of the dataset's logical row id. ### Format and domain tracking - New `INVERTED_ROW_ADDR_DOMAIN_VERSION` (4), orthogonal to the posting-list format axis (`INVERTED_INDEX_VERSION_V1/V2/V3`, tracked via file metadata rather than `index_version`): a row-address-domain segment can pair with any posting format. - `index_version()`, `results_are_row_addrs()` and `can_follow_stable_row_ids()` version-gate on it, matching the earlier migrations. - `build_scalar_index` relabels a fresh build's `index_version` back down to the legacy posting-format version on a dataset *without* stable row ids (where row id == row address, so an older reader still reads it correctly) — the same relabeling every other migrated type does. - **The document identity column in `docs.lance` is named for its domain**: `_rowaddr` from version 4, `_rowid` in versions 1–3. This follows MinHash LSH, the only other migrated type that had an identity column literally named `_rowid` (see `docs/src/format/index/scalar/minhash_lsh.md` and `minhash_lsh/mod.rs`, which renames the same way and resolves the name from the file schema on read). The remaining migrated types — BTree `ids`, Bitmap/LabelList `bitmaps`, NGram `posting_list`, RTree `id` — use domain-neutral column names and had nothing to rename, so no migrated scalar index now leaves a column named `_rowid` holding addresses. The name tracking the version is worth more than tidiness: a reader that ignores `index_version` finds no such column rather than silently reading one domain's values as the other's. Because `build_scalar_index` relabels down for older readers, the name is chosen *before* the file is written, from the version the segment will be committed with — `TrainingRequest` gains a defaulted `set_stable_row_ids` hook so only FTS implements it. Rewrites keep their source's version and therefore its column: a loaded `DocSet` records the name it read and derived builders inherit it, so no merge, remap or consolidation path has to remember. Readers resolve the name from the file's own schema (`docs_identity_column`), so one reader serves both. ### Changes the migration requires These are hazards the migration *introduces* and this PR handles — not fixes to pre-existing defects. **None of them can fail on the base commit**, because before this PR there was no address-domain FTS segment for them to go wrong on; the applicable test is "fails with the hunk reverted on this branch", which is what the coverage below was measured against. - `append.rs` / `index/scalar/inverted.rs`: the old-data filters used during a segment merge now use the segment's actual domain instead of a hardcoded `false`. Reverting this fails `stale_posting_after_in_place_update_with_stable_row_ids` and `test_optimize_fts_consolidates_single_row_appends::stable_ids`. - `append.rs`: `legacy_domain_mismatch` forces a full rebuild rather than merging a legacy row-id-domain segment alongside a fresh address-domain one. Pinned by `test_optimize_append_rebuilds_stray_legacy_fts_segment_with_stable_row_ids` (previously uncovered — reverting it changed nothing in the suite). - FTS pushes its deletion/filter/overlay masks straight into the index's own search as a live prefilter, checked against physical postings before any row-id translation — unlike other scalar types, which translate an index's address-domain results into row ids *before* any mask check (`ScalarIndexExec`'s convention). Forcing only the deletion mask into address domain was not enough: the externally supplied `filtered_ids`/`external_mask` and the overlay-staleness block mask follow the same row-id-domain convention and needed the same translation (`io/exec/utils.rs`'s `row_id_mask_to_row_addr_domain`/`translate_treemap_to_row_addr_domain`, applied at every FTS prefilter boundary). Reverting it fails 46 tests. - `create.rs` no longer refuses creating a *new* Inverted index while a live fragment-reuse index exists: that guard assumed Inverted always stored row ids. ### Addressed from review - **Mixed identity domains across columns.** A multi-column FTS query merges several *named indexes*' postings on the stored identifier alone, so rebuilding one column's index after an upgrade left its sibling on the older domain and an AND query silently returned nothing. `fts_segments_are_address_domain` now resolves the one domain every segment agrees on and errors naming both offenders; the callers already pass every segment a query reads, so the same check covers the cross-column and within-index cases. - **Row-address segment coverage.** Opening a multi-segment FTS index under stable row ids failed outright (`segment coverage of row-address hits has no live row ids`): `open_fts_segment` asked for a stable-row-id allow-list unconditionally. `SegmentCoverage::allowed_row_mask` now serves both restrictions, allowing each covered fragment whole for address-domain hits. - **Tied-result pagination.** Top-k selection ranks ties by the stored identifier, which is now an address, while the plan above sorts by `_rowid`; paging a tie skipped and repeated rows. Selection cannot be re-keyed — `combined_maxscore` discovers candidates in ascending stored-id order and its pruning depends on that — so the order is reconciled after selection: searches retain extra candidates, and a tie at the cutoff larger than that margin is completed exactly (the escape hatch the WAND tie certificate already had). Applied to combined fields, both compound paths, Match and Phrase. - Spec text stated normatively (reader/writer rules rather than library behaviour); `translate_treemap_to_row_addr_domain` reports a whole-fragment entry instead of silently passing it through untranslated; the repeated relabel-to-row-id-domain test snippet extracted as `utils::test::as_legacy_row_id_segment`, documenting that its segment still holds addresses while claiming row ids; comment/nit fixes. ### Tests - Updated or replaced tests whose premise was "Inverted is the last row-id-domain scalar index type" across `append.rs`, `create.rs`, `frag_reuse_with_stable_row_ids.rs`, `dataset/optimize/tests*`, `dataset/write/update.rs`, `dataset/mem_wal/index/tests.rs` and `index/tests/lifecycle.rs`. - `index/tests/lifecycle.rs`'s `test_compaction_survives_an_unsupported_index` renamed to `test_compaction_drops_coverage_of_an_unsupported_index_it_rewrites`: its premise no longer holds for *any* scalar index type. - New: mixed-domain rejection (cross-column and within-index), `docs.lance` identity column asserted for both domains and across a merge, tie pagination within and beyond the re-rank margin and across four query shapes, `translate_treemap_to_row_addr_domain` unit tests, and a Python compat test `InvertedRowAddressDomainIndex` mirroring `NgramRowAddressDomainIndex`. ### Known gaps - **Compaction's eager-remap vs. unreadable-index gap.** `plan_groups_with_budget`'s `unreadable_coverage` hold-back only runs without stable row ids; under stable row ids it relies on `supports_eager_remap`, a type-level capability check that does not account for a *specific* index instance being unreadable. Predates this PR and affects every address-domain scalar type — it was only ever hidden because Inverted was the last type that could dodge it in tests. Flagged as a follow-up. - Tie ordering is reconciled above the collectors, in each exec. Teaching the collectors to retain ties at the k-th score in one pass would remove both the retained margin and the exact-completion replay. - `build_prefilter` / `build_prefilter_restricted_to_fragments` still have `_in_domain` siblings. Collapsing them needs the overlay-block translation made lazy first, since the merged function would otherwise be `async` while three vector `execute()` bodies are sync. ## Test plan - [x] Rebased onto `main` (was 11 commits behind; picked up `cd45844c9`, which fixes the `HnswQueryParams` compile error that was failing clippy/builds/MSRV) - [x] `cargo test -p lance --lib` — 11459 passed, 1 failed (`test_only_proven_address_indices_are_compatible::case_10_rtree_address_domain`, which also fails on `origin/main`; unrelated to this PR) - [x] `cargo test -p lance-index --lib` — 4185 passed - [x] `cargo clippy -p lance -p lance-index --lib --tests` and `cargo fmt` clean - [x] Full CI green (41/41 excluding the format-spec vote) as of `01da7a07e` - [ ] CI for the identity-column rename (`99d810578`, `87935eb6e`) — still running - [ ] Python compat suite — relies on CI. Schema-driven reading should let an existing version-4 fixture written before the rename still open, but that is reasoning rather than evidence; worth watching that job specifically. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 <[email protected]>
Summary
Stacked on #9814 (Bitmap/LabelList → row-address domain), which is stacked on #9481 (BTree). This applies the same migration to the NGram, RTree, and MinHash LSH indexes. These indexes now store physical row addresses (
_rowaddr) instead of row ids. FM was already address-domain, so after this PR Inverted (FTS) is the only scalar index still in the row-id domain.NGram and RTree (stable formats)
_rowaddr. The format version goes from 0 to 1 (NGRAM_/RTREE_ROW_{ID,ADDR}_DOMAIN_VERSION).IndexMetadata::index_version(results_are_row_addresses). It is preserved through merge, remap, and update, so a row-id-domain segment is never silently relabelled.build_scalar_index's per-type override is now a smallrow_id_domain_versionlookup; the RTree entry is behind thegeofeature.IndexMetadata::results_are_row_addrsnow version-gates both types.append.rs"fold stray legacy segment / rebuild instead of merge" guards now cover both types.has_legacy_row_id_domainis derived fromrow_id_domain_version(plus MinHash), so there is one less list of migrated types to keep in sync.shared_segment_domainhelper is used by the NGram and RTreemerge_segmentspaths. It refuses mixed-domain segments, and refuses legacy segments on stable-row-id datasets.merge_rtree_indicesindependently rejects mixed-domain sources too, since it's a public function direct callers could invoke without going through that helper.updatearm inmerge_scalar_indicesnow passes the reference segment's own domain. It replaces the hardcodedfalseand the LabelList-specific arm that duplicated this. ZoneMap, BloomFilter, and FM ignore the old-data filter, and Inverted is still row-id domain, so behaviour for other types is unchanged.RTreeIndex::loadis public, so its signature is kept. It loads the current (address-domain) format only, and its docs say so: a pre-migration segment must be loaded throughRTreeIndexPlugin'sload_indexwith the manifest'sindex_version.MinHash LSH (experimental/unstable format)
Per AGENTS.md, this format gets no compatibility path for writing, but reading a pre-migration segment is still supported:
MINHASH_LSH_INDEX_VERSIONgoes from 0 to 1. The stored column is renamed_rowid→_rowaddrfor anything this build writes.signature_id_col) that works out which domain a given segment is in without that case being passed down separately.rebuild_from(behind remap, update and merge) is the sole writer. It always produces the current (address-domain) layout and copies each source's identifiers as-is, andcreated_index()always reportsMINHASH_LSH_INDEX_VERSIONto match. That is only correct for a v0 source when row ids equal row addresses, so the caller, which knows whether the dataset uses stable row ids, decides:lance's MinHashmerge_segmentsrejects a v0 segment on a stable-row-id dataset with a rebuild-required error. Without stable row ids, a v0 merge is safe and allowed.update/remapnever reach a v0 segment on a stable-row-id dataset:optimize_indicesfolds it into a rebuild, and compaction skips it (supports_eager_remapis false).merge_minhash_indicesdocuments this contract for direct callers.MinHashSearchExecnow gives each segment a synchronous live address → row-id lookup (live_row_addr_to_row_id_lookup). The lookup skips deleted slots, so an updated row's stale entry can't resolve to its moved stable id.MinHashLshIndex::search_signature_as_row_ids.search_signatureis unchanged.JSON-wrapped indexes
legacy_target_index_version(and sowraps_row_addr_domain_target) now also recognizes NGram and RTree as targets whose format moved from row ids to row addresses, alongside BTree/Bitmap/LabelList. Without this, a pre-migration JSON-wrapped-NGram/RTree segment was never folded into anoptimize_indicesrebuild on a stable-row-id dataset, and a stray row-id-domain segment surviving alongside a fresh address-domain one made the commit fail.Tests and docs
test_compact_ngram_with_stable_row_idsfor NGram on a stable-row-id dataset, with both eager and deferred compaction. The eager case checks that the index is remapped in place and keeps full coverage. The deferred case checks answers through the FRI and after draining it.lance-table.RTreeIndexPlugin::load_indexandNGramIndexPlugin::load_indexat v0 and v1. The RTree test also covers how merge handles the domain.optimize_indicesfailure above.translate_addr_mask_to_row_idsunit test for the empty vs. non-empty block-list branches.NgramRowAddressDomainIndex. The existingNgramIndextest already covers the case without stable row ids.Known gaps
can_remap() == false), so a normal (non-deferred) compaction drops its coverage of the rewritten fragments untiloptimize_indicesor a rebuild. Before this PR, the row-id domain survived compaction. NGram, BTree, Bitmap, and LabelList remap in place and keep coverage. RTree index should support remap so compaction keeps coverage on stable-row-id datasets #10969 tracks adding RTree remap support (likely reusingremap_rtree_data).Test plan
cargo test -p lance-index --features geo --lib -- scalar::ngram scalar::rtree scalar::minhash_lshcargo test -p lance-geo --lib(including the plugin-backed version/domain/merge test)cargo test -p lance --librun: MinHash, NGram compaction (eager + deferred), FRI/stable-row-id, addr-domain compaction, JSON-wrapped NGram, and legacy-segment tests (256 passed)cargo test -p lance-table --lib -- results_are_row_addrscargo clippy -p lance-geo -p lance-index -p lance --tests -- -D warnings,cargo fmt --all --check,ruff check/ruff format --checkcargo test --workspace(not run here because of disk limits; relying on CI)🤖 Generated with Claude Code
https://claude.ai/code/session_01Y3hhWhSPAggJTKAWR32ivc