Repository navigation
Comparing changes
Open a pull request
base repository: sbrunk/lance
base: combined-fields-bm25f-part2
head repository: sbrunk/lance
compare: combined-fields-python
- 8 commits
- 48 files changed
- 7 contributors
Commits on Sep 29, 2026
-
fix(encoding): skip full-width block bitpacking (lance-format#9598)
## Cause `try_bitpack_for_block` selected out-of-line bitpacking even when the measured width equaled the value width. Negative `Int64` dictionary values produce a 64-bit width, so a runt dictionary tail hit the nonzero-savings assertion in debug builds. ## Fix Skip block bitpacking at full width and allow the existing general or raw compression fallback. This changes codec selection without changing the file format. ## Validation - Reproduced the v2.2 and v2.3 writer panic before the fix; the same round-trip cases pass after it, with v2.1 as a control. - The selector regression covers both a 1600-value runt tail and 2048 complete values. - `cargo test -p lance-encoding --lib test_block_skips_full_width_bitpacking` - `cargo test -p lance-file --lib test_negative_dictionary_values_with_runt_tail` - `cargo fmt --all` - `cargo clippy --all --tests --benches -- -D warnings` Fixes lance-format#9597 <!-- lance-gatekeeper-fix:v1 agent=d47de8967de6eb1c5af9d78844dc98f6 generation=1 --> Co-authored-by: Gatefixer <312823363+lance-gatefixer[bot]@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 0109274 - Browse repository at this point
Copy the full SHA 0109274View commit details -
fix(mem_wal): dedup repeated row positions when training the flushed …
…PK sidecar (lance-format#9595) ## Problem The memtable primary-key index (`BTreeMemIndex`) is a skiplist **multiset**: inserting the same `(value, position)` twice stores it twice. A row *is* indexed twice when a WAL replay (`replay_wal` → `insert_batches_parallel`) re-indexes buffered batches the WAL flusher (`flush_from_batch_store`) already indexed. The flushed generation's PK sidecar (`create_pk_index` / `write_pk_sidecar`) is trained straight from `pk_training_batches()`, so the on-disk BTree page inherits the repeated row id. When `contains_keys` later loads that page, `FlatIndex::try_new` builds a `RowAddrTreeMap` via `RoaringBitmap::from_sorted_iter`, which requires strictly increasing input, and every probe of that generation fails with: ``` RowAddrTreeMap::from_sorted_iter called with non-sorted input ``` Because the block list is built for every LSM scan, one bad generation makes every read of the table fail. Observed in production (lance 9.0.0): a 2-row generation whose sidecar page was `[(item:a, 0), (item:a, 0), (item:b, 1)]` broke `list` on a 54k-row table for weeks, deterministically, for any `limit` large enough to enable the `PkBlockFilterExec`. This is the same failure signature as lance-format#7230 (base-table BTree merge). The fixes proposed there were rejected in favour of fixing the training input; this PR does exactly that for the MemWAL sidecar path. ## Fix In `BTreeMemIndex::to_training_batches`, skip a position equal to the previous one within a value group. Positions within a group are already sorted, so this is a one-comparison dedup at the only place the multiset is turned into training data. The write path is left as a multiset on purpose: `insert_and_check_neighbors` relies on neighbor inspection for the `pk_has_overrides` signal, and deduping there would change its cost profile. ## Verification - `test_btree_index_to_training_batches_dedups_repeated_positions`: indexes a batch twice into both the fixed-int and bytes backends; the training batches carry each position once. Fails without the fix. - `sidecar_from_doubly_indexed_memtable_is_probeable` (block_list): trains a real on-disk sidecar from a doubly-indexed `IndexStore`, opens it with `open_pk_index`, and probes it. On the 9.0.0 read path this is the exact production failure; on `main` the probe path no longer builds a `RowAddrTreeMap` eagerly (lance-format#8924), so the test passes either way there, but it pins the invariant for the `search`/`into_row_addr_set` paths that still do. - `cargo test -p lance --lib mem_wal`: 781 passed. `cargo fmt --check`, `cargo clippy --lib --tests -D warnings` clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5 <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for b94b20c - Browse repository at this point
Copy the full SHA b94b20cView commit details -
fix!: derive merge_columns field ids from the dataset manifest (lance…
…-format#9547) `FileFragment::merge_columns` assigned new schema field ids from the caller-supplied `max_field_id`, while the `Updater` assigned data file field ids from the dataset manifest. When the two differed, the `Merge` commit succeeded but the new columns read back as `null` (or, with dropped columns, could alias stale data). Remove the `max_field_id` parameter and always use the manifest's `max_field_id()`, the same source the `Updater` uses. Every in-tree caller already passed that value, so the Python `LanceFragment.merge` and Java `Fragment.mergeColumns` APIs are unchanged. BREAKING CHANGE: `FileFragment::merge_columns` no longer takes a `max_field_id` argument.
Configuration menu - View commit details
-
Copy full SHA for 08d0440 - Browse repository at this point
Copy the full SHA 08d0440View commit details -
feat(dataset): spill row lineage when updating rows (lance-format#9339)
Part of the §5.3 stack (lance-format#8931, lance-format#9250). lance-format#9253, lance-format#9336, lance-format#9337 and lance-format#9338 are merged; this PR is now based on `main`. Updates on a table that opts into spilling move the lineage of the rows they rewrite out of the manifest, so an update-heavy table no longer regrows its manifest between compactions. It also fixes schema-only commits dropping the file a spilled sequence lives in, which has been reachable since lance-format#9337. ## Stack 1. lance-format#9253 feat(format): define hidden row lineage columns (merged) 2. lance-format#9336 feat(dataset): read and write spilled row lineage columns (merged) 3. lance-format#9337 feat(dataset): spill row lineage at compaction (merged) 4. lance-format#9338 feat(table): load spilled row lineage ahead of a commit (merged) 5. this PR: feat(dataset): spill row lineage when updating rows 6. lance-format#9347 feat(dataset): write compaction's spilled lineage into the fragment's data file 7. lance-format#9340 test(bench): row lineage spill benchmark ## Change **Update places the lineage it carries over, only when it spills.** - `UpdateBuilder` resolves the table's inline budget before any IO. A malformed `lance.row_lineage.inline_max_bytes` now fails the update before anything is written. - Only on a table that can spill (opted in, v2 files, a build that understands the flag) does the scan project `_row_created_at_version` next to `_rowid`. `make_rowid_capture_stream` captures it run-length encoded, so a rewrite of N rows written at a few versions costs a few runs rather than 8 bytes per row. - After the write, each new fragment's row ids and created-at versions are split to its size. They leave the manifest only when one of them is over the budget, into a lineage-only file added to the fragment's `files`. Last-updated-at is never placed by the writer; it is the commit's. - A table that never opted in, or an update whose sequences fit inline, leaves created-at to the commit exactly as `main` does. **Commit contract** (`resolve_update_version_metadata`, `has_writer_placed_lineage`): - A new fragment whose row ids or created-at versions are `Column` is writer-placed. It keeps its created-at and gets last-updated-at stamped with the commit version. - Placed inline created-at must have one value per physical row, or the commit is refused. - Every other fragment is resolved from the existing fragments as before. A caller-supplied inline created-at is still recomputed, which keeps the documented contract for fragments committed from Python. - The commit skips the created-at lookup for writer-placed fragments, and the read-ahead from lance-format#9338 is skipped for an update whose new fragments are all writer-placed. **Spilled lineage survives schema-only commits.** `Operation::Project` (drop, rename, nullability), `DataReplacement` and the cast in `alter_columns` kept only files with a live schema field, so they dropped the only carrier of a spilled sequence and left a `Column` arm pointing at nothing. After cleanup, those row ids and versions were gone. All three now keep a file that carries one of the fragment's spilled ids. `build_manifest` also refuses to commit a fragment whose `Column` arm has no carrier, or a carrier in a v1 file, so a future path cannot commit that state silently. `merge_insert` is unchanged: its rewritten rows still get inline lineage resolved at commit time. ## Validation Run on an x86 build host (r8i.8xlarge): - `cargo fmt --all -- --check`, `cargo clippy --all --tests --benches -- -D warnings` - `cargo test -p lance-table`: 573 passed, including `project_keeps_file_carrying_spilled_row_lineage`, `data_replacement_keeps_lineage_carrier`, `build_manifest_rejects_spilled_arm_without_carrier` and the new `row_version` contract tests. - `cargo test -p lance --lib -- rowids:: row_version stable_row rowid optimize::tests dataset_transactions fragment::tests cleanup::tests feature_flag update::tests merge_insert::tests io::commit dataset_io schema_evolution versions:: write::tests utils::tests`: 1545 passed, including `schema_change_keeps_spilled_lineage` (update or compaction followed by rename, drop or cast), `update_leaves_inline_created_at_to_the_commit`, `update_rejects_malformed_inline_max_bytes_before_writing` and `place_rewritten_lineage_splits_lineage_by_output_fragment`. - `cargo check --manifest-path python/Cargo.toml`, `cargo check --manifest-path java/lance-jni/Cargo.toml` Refs lance-format#8931, lance-format#9250 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for eedd50c - Browse repository at this point
Copy the full SHA eedd50cView commit details -
Configuration menu - View commit details
-
Copy full SHA for c4d5017 - Browse repository at this point
Copy the full SHA c4d5017View commit details -
feat(fts): score unindexed fragments in combined_fields (lance-format…
…#9444) ## TL;DR Follow up to lance-format#7905, which added `combined_fields` (BM25F) but returned an error whenever a query reached a fragment that one of the target columns had not indexed. This PR replaces that error with a flat scan over those fragments, so `combined_fields` also works on rows added since the indexes were built. ## What changes | Commit | Files | + | − | Subject | |---|---:|---:|---:|---| | `a1e707f02` | 15 | 1,717 | 116 | feat(fts): score unindexed and partially indexed fragments in combined_fields | | `a2d980886` | 4 | 2,334 | 5 | test(fts): cover the combined_fields flat scan and overlay corpus statistics | | **Total** | **17** | **4,051** | **121** | about 2,300 lines of it tests | The query API is untouched: `query.rs`, `parser.rs`, `tokenizer.rs` and `traits.rs` are unchanged. `CombinedFieldColumn` gains one field, `stale_rows`, which is public but internal to scoring. Most of the 121 deleted lines are in code from lance-format#7905, mainly the error path that the union plan replaces. One lance-format#7905 test changes meaning: in `test_element_document_nested_lists_use_deepest_boundary`, a normal scan over the appended fragment now returns all four rows instead of the coverage error. Its `fast_search` and post-optimize checks are unchanged. Before, on a dataset with one appended fragment: ``` Invalid user input: combined_fields requires every target column to be indexed over every scanned fragment, but 1 of 2 fragments are not fully covered. Optimize the indexes on body, title and retry. ``` After, the same query returns those rows, ranked correctly against the indexed ones. ## How it works ``` plan_combined_fields_query │ └─ some fragment not covered → union of two children │ ├── CombinedFieldsQueryExec (restricted to the covered fragments) │ └── FlatCombinedFieldsExec (the remaining fragments) • reads the column values and blends dl' and tf' per row • publishes the corpus statistics that both children use │ ▼ UnionExec → SortExec(score DESC, row_id ASC) → fetch(k) ``` Both children score against the same corpus. Only the flat side can see the rows that no index covers, so it measures what they contribute and publishes the combined statistics. The indexed side waits for those rather than using only its own `docCount'`, `docFreq'` and `avgdl'`. Getting this wrong would be hard to spot: the right rows still come back, but with scores that depend on which child happened to produce them. A fragment counts as not covered if any target column's index is missing it, or if a newer data overlay made its entries stale. Coverage stays a per fragment decision, because a row has to be scored either entirely from the index or entirely from the scan. A stale row needs one more step. The index holds its pre-overlay value until the index is optimized, and the flat scan folds in its current one, so counting both inflates `docCount` and `docFreq`. That is enough to reorder results after an overlay that changed no searchable value at all. `InvertedIndex::bm25_row_stats_for_terms` therefore takes the stale rows and subtracts what they still contribute, reading posting membership to do it. Only a column that actually has stale rows pays for that. ## Correctness - Adds 15 test functions and 23 cases to `dataset_fts_combined_fields.rs`, taking it from 13 functions and 16 cases to 28 and 39, plus overlay coverage in `dataset_overlay_index_masking.rs`. 62 tests match the `combined` filter in `lance --lib`, and `scalar::inverted` is at 882 of 882. - Every dataset test checks exact scores against the brute force `oracle` reference, which recomputes every statistic from the raw text and shares no code with the scan. A wrong shared corpus still returns almost the right rows in almost the right order, so a test that only checked which rows came back would pass anyway. - Covered: mixed indexed and flat plans, per column index skew over both row id schemes, partially indexed columns, an unindexed row winning top k, fragments made stale by an overlay, deletions followed by optimize, external row masks, filters, nulls and empty strings on the flat path, list and large list and nested columns, a column under a list, and the plan shape itself, so a query that should union cannot answer from the index alone. - `test_fts_combined_fields_overlay_preserves_every_score` pins the stale row subtraction by comparing score bit patterns across a same-value overlay. Ids alone would not catch it, because the same rows come back either way. - `test_fts_combined_fields_tied_scores_are_deterministic` covers tie ordering for both plan shapes. A fully covered dataset returns the exec with no `SortExec` above it, while a mixed plan gets its order from the sort's second key, so the two shapes need separate checks. ## Stack The branches that build on this one. They live on a fork, and GitHub cannot stack PRs across forks, so each dependent PR also shows this PR's commits. The compare links give the real diff for each. ``` main (includes lance-format#7905) └── combined-fields-bm25f-part2 lance-format#9444 ← this PR (flat scan) ├── fts-builder-doc-order │ └── combined-fields-maxscore │ └── combined-fields-block-skip │ └── combined-fields-bench ├── fts-json-stream-schema ├── combined-fields-python lance-format#8550 └── combined-fields-java lance-format#8549 ``` | Branch (diff) | Base | PR | Cmts | Files | + | − | Description | |---|---|---|---:|---:|---:|---:|---| | `combined-fields-bm25f-part2` | main | lance-format#9444 | 2 | 17 | 4,051 | 121 | flat scan for fragments the indexes do not cover | | [fts-builder-doc-order](combined-fields-bm25f-part2...fts-builder-doc-order) | part 2 | none yet | 1 | 1 | 493 | 0 | order inverted index docs by row_id at build time | | [combined-fields-maxscore](fts-builder-doc-order...combined-fields-maxscore) | builder-doc-order | none yet | 1 | 8 | 903 | 82 | prune candidate scoring with MAXSCORE | | [combined-fields-block-skip](combined-fields-maxscore...combined-fields-block-skip) | maxscore | none yet | 1 | 10 | 1,091 | 106 | skip posting blocks a row id seek jumps past | | [combined-fields-bench](combined-fields-block-skip...combined-fields-bench) | block-skip | none yet | 1 | 4 | 1,191 | 1 | Lance vs Lucene BM25F validation harness | | [fts-json-stream-schema](combined-fields-bm25f-part2...fts-json-stream-schema) | part 2 | none yet | 1 | 1 | 184 | 1 | tests for flat scans over JSON columns (the `JsonTextStream` schema fix itself landed upstream in lance-format#9479) | | [combined-fields-python](combined-fields-bm25f-part2...combined-fields-python) | part 2 | lance-format#8550 | 2 | 5 | 227 | 1 | Python binding for `combined_fields` | | [combined-fields-java](combined-fields-bm25f-part2...combined-fields-java) | part 2 | lance-format#8549 | 1 | 4 | 321 | 24 | Java binding for `combined_fields` |
Configuration menu - View commit details
-
Copy full SHA for 0d89fca - Browse repository at this point
Copy the full SHA 0d89fcaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4d1854e - Browse repository at this point
Copy the full SHA 4d1854eView commit details -
docs(fts): document multi-column full-text search
Adds a quickstart section on searching several text columns: `best_fields` via `MultiMatchQuery`, which scores each column against its own corpus and keeps the best field, and `combined_fields` via `CombinedFieldsQuery`, which blends the columns into one virtual field and scores them as BM25F. Covers when to prefer each, how per-column `boosts` weight the blended term frequency, and the shared-tokenizer and row-granularity requirements.
Configuration menu - View commit details
-
Copy full SHA for 221bafa - Browse repository at this point
Copy the full SHA 221bafaView commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff combined-fields-bm25f-part2...combined-fields-python