Skip to content

refactor: rework scalar index loading, training, and parsing into a plugin trait - #4584

Merged
westonpace merged 10 commits into
lance-format:mainfrom
westonpace:refactor/scalar-index-plugins
Sep 2, 2025
Merged

westonpace merged 10 commits into
lance-format:mainfrom
westonpace:refactor/scalar-index-plugins

Conversation

@westonpace

Copy link
Copy Markdown
Member

These operations were previously all done via match statements. This made it difficult to create new index types.

@wjones127 wjones127 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.

Cool to see the index types behind a trait.

Approved pending CI.

@westonpace
westonpace force-pushed the refactor/scalar-index-plugins branch 2 times, most recently from 9ec646b to 28c3e0c Compare August 28, 2025 22:47
@github-actions github-actions Bot added the A-python Python bindings label Aug 29, 2025
@westonpace
westonpace force-pushed the refactor/scalar-index-plugins branch from 1d8599d to d34c875 Compare August 29, 2025 12:15
@codecov-commenter

codecov-commenter commented Aug 29, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.91842% with 422 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.82%. Comparing base (0b82c81) to head (b86b246).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
rust/lance-index/src/scalar/zonemap.rs 61.66% 64 Missing and 5 partials ⚠️
rust/lance/src/index/scalar.rs 75.11% 43 Missing and 11 partials ⚠️
rust/lance-index/src/scalar/label_list.rs 48.42% 46 Missing and 3 partials ⚠️
rust/lance-index/src/scalar/inverted.rs 41.77% 43 Missing and 3 partials ⚠️
rust/lance-index/src/scalar/bitmap.rs 78.72% 23 Missing and 17 partials ⚠️
rust/lance/src/dataset/index.rs 42.30% 28 Missing and 2 partials ⚠️
rust/lance-index/src/scalar/ngram.rs 75.53% 12 Missing and 11 partials ⚠️
rust/lance-index/src/scalar/btree.rs 88.82% 6 Missing and 14 partials ⚠️
rust/lance-index/src/scalar.rs 60.46% 17 Missing ⚠️
rust/lance/src/index.rs 70.00% 11 Missing and 4 partials ⚠️
... and 11 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4584      +/-   ##
==========================================
- Coverage   80.93%   80.82%   -0.11%     
==========================================
  Files         314      315       +1     
  Lines      117064   117713     +649     
  Branches   117064   117713     +649     
==========================================
+ Hits        94749    95146     +397     
- Misses      18931    19154     +223     
- Partials     3384     3413      +29     
Flag Coverage Δ
unittests 80.82% <73.91%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added the A-java Java bindings + JNI label Aug 29, 2025
@westonpace
westonpace merged commit a40c17a into lance-format:main Sep 2, 2025
@HaochengLIU

Copy link
Copy Markdown
Member

I like the PR, great simplification

jackye1995 pushed a commit to jackye1995/lance that referenced this pull request Jan 21, 2026
…lugin trait (lance-format#4584)

These operations were previously all done via match statements. This
made it difficult to create new index types.
Xuanwo added a commit that referenced this pull request Nov 13, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-java Java bindings + JNI A-python Python bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants