Skip to content

fix(index): align row_range with partition_size for absent partitions - #9013

Open
LuciferYang wants to merge 2 commits into
lance-format:mainfrom
LuciferYang:fix/ivf-rq-ivf-row-range-oob
Open

fix(index): align row_range with partition_size for absent partitions#9013
LuciferYang wants to merge 2 commits into
lance-format:mainfrom
LuciferYang:fix/ivf-rq-ivf-row-range-oob

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Problem

IvfModel::row_range indexed offsets and lengths directly, so a partition the model does not carry panicked. partition_size answers the same question for the same input and returns 0.

Fixes #9012.

What this changes

row_range returns an empty range where partition_size returns 0.

Worth stating plainly: I could not construct the panic through the public API. User-supplied partition ids are range-checked at load_partition, search-path ids come from find_partitions over the centroids, and neither the builder nor the distributed merger can emit a model whose num_partitions() exceeds its offsets. So this is a contract alignment between two neighbouring methods rather than a fix for a reachable failure, and it is fine to close as not worth it on those grounds.

Test plan

test_row_range_out_of_range_is_empty builds a one-partition model and checks that partition 1 and usize::MAX give an empty range and that partition_size agrees, then adds a zero-length partition to show a present-but-empty partition keeps its own offset and is still distinguishable from an absent one. Restoring the direct indexing makes it panic.

  • cargo test -p lance-index --lib 1231 passed, 3 ignored
  • cargo clippy --all --tests --benches -- -D warnings clean
  • cargo fmt --all --check clean

IvfModel::row_range indexed offsets and lengths directly, so a partition the model does not carry panicked. partition_size answers the same question for the same input and returns 0. Align row_range with it.

I could not construct the panic through the public API: user-supplied partition ids are range-checked at load_partition, and the builder cannot emit a model whose num_partitions exceeds its offsets. This is a contract alignment between two neighbouring methods rather than a fix for a reachable failure.
@github-actions github-actions Bot added A-index Vector index, linalg, tokenizer bug Something isn't working labels Sep 4, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Sep 4, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Sep 5, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate recommendation: approve.

The prior finding is addressed: absent layout entries now produce a contextual error through the fallible range lookup, every production caller propagates it, and explicitly stored zero-length partitions retain their own offsets.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index Vector index, linalg, tokenizer bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: row_range panics where partition_size returns 0 for an absent partition

1 participant