Skip to content

feat(index): merge LabelList segments with new rows during optimize - #11231

Merged
Xuanwo merged 1 commit into
lance-format:mainfrom
ddupg:feat/label-list-merge-new-data
Nov 30, 2026
Merged

Xuanwo merged 1 commit into
lance-format:mainfrom
ddupg:feat/label-list-merge-new-data

Conversation

@ddupg

@ddupg ddupg commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Part of #10847. Follow-up to #10954.

#10954 added bounded optimize for LabelList and kept existing segments in the merge stage, even when a merge group had only one build task.

This PR lets a lone build task merge the selected old segments with new rows and write the final segment directly. That saves an intermediate index write and a separate merge pass. The merge applies each source segment's filter to both label postings and list-level NULLs. Incompatible legacy segments use the existing rebuild path.

Tests cover single-task and multi-task plans, partial deletions, and overlay updates. The single-task regression also checks that the task reads the new fragment's data files without rescanning the old fragments' data files.

@github-actions github-actions Bot added A-index Vector index, linalg, tokenizer A-java Java bindings + JNI enhancement New feature or request labels Nov 18, 2026
@ddupg
ddupg marked this pull request as ready for review November 18, 2026 14:28

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 18, 2026
@ddupg
ddupg force-pushed the feat/label-list-merge-new-data branch from fa568bb to b490574 Compare November 19, 2026 05:08
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 19, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 19, 2026
@ddupg
ddupg force-pushed the feat/label-list-merge-new-data branch from b490574 to 4cf5942 Compare November 20, 2026 02:59
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 20, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 20, 2026
Xuanwo added a commit that referenced this pull request Nov 24, 2026
## Problem

Every scalar index merge repeated the same field and declaration
validation, row-domain guard, per-segment filters, destination store
allocation, source opening/downcast, and `IndexMetadata` assembly.
Bitmap also depended on btree for its empty new-data stream, and
append's merge dispatch rebuilt the same filters per arm.

## Change

Add `scalar/segment_merge.rs` to own the shared merge inputs and output:

- empty groups, keyed field/path and same-declaration checks
- per-type stable-row-id legacy guard, preserving
Bitmap/BTree/LabelList/MinHash bottom-level mixed-domain errors;
RTree/NGram keep the shared-domain guard
- per-segment filters and coverage unions
- typed source opening/downcast
- UUID/store allocation and one metadata constructor
- the empty value/address stream used by pure consolidation

All scalar merge modules now use it; Bitmap no longer reaches into
btree. `append.rs` constructs filters once for the simple merge
primitives. MinHash keeps its historical admission rule: non-stable
tables can merge disjoint v0 and v1 segments into v1, while stable
tables still reject legacy input.

No public API, persisted format, or Python wrapper changes. #11273,
#11231 and #11280 are complementary and not dependencies; their
behaviors are not pulled in here. Overlap is mechanical in the same
scalar modules and append dispatch. Current main's #11290 only changes
tagged FRI retention bookkeeping and #11391 changes commit
configuration; neither changes a caller contract used by this change.

## Validation

- `cargo fmt --all -- --check`: pass
- `cargo clippy --all --tests --benches --profile ci -j 4 -- -D
warnings`: pass (only existing lance-linalg build-script notices)
- Runtime on head `d23cbafd5`, one test executable, 49 unique tests:
- scalar MinHash module: 16 passed, including mixed v0-layout/v1
disjoint merge, commit, reopen and `fast_search` for both stable and
non-stable datasets, plus the historical-layout legacy regression
  - `index::tests::merge`: 8 passed
- append/optimize: BTree 9, Bitmap 7, NGram 1, BloomFilter 4, FTS 3,
scalar stale-row 1

No released MinHash v0 fixture exists; the v0 layout is reconstructed
from a current segment (`_rowid`, version 0) by the test helper. The
test exercises real merge, commit, reopen and search rather than mocked
metadata.

Remaining coverage: the full workspace test matrix and a Python wheel
were not run. The Python wrapper is unchanged, and the mixed historical
layout is not constructible through it.

Clean merge tree with current main
`e90fe4b8e7c8c819bb51171a43fc94d01b40e2c7`:
`bdbb1029cd3e7ab3a54ac3036d258cd4e6dcbcaa`.
@ddupg
ddupg force-pushed the feat/label-list-merge-new-data branch from 4cf5942 to 0088d3f Compare November 25, 2026 06:11
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 25, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 25, 2026

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ddupg I verified single-task optimize at 0088d3f33a after compaction with deferred remapping, deletes, and an append. It reused the old index and read only the appended data file. After reopening, both membership and negated membership queries matched a full scan.

There’s one blocker when integrating this with #11283. The new merge_segments wrote a posting for label 99 beneath a NULL Arrow list. The NULL bitmap masked it in query results. In either merge order, merge_segments still calls helpers removed by #11283 outside the marked conflict. In the second PR to land, please route new rows through unnest_labels(new_data, new_nulls.clone(), ROW_ADDR)?. A regression on the reopened index should check that a NULL parent contributes no child posting and that a null element in a valid list keeps its posting.

@ddupg

ddupg commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@ddupg I verified single-task optimize at 0088d3f33a after compaction with deferred remapping, deletes, and an append. It reused the old index and read only the appended data file. After reopening, both membership and negated membership queries matched a full scan.

There’s one blocker when integrating this with #11283. The new merge_segments wrote a posting for label 99 beneath a NULL Arrow list. The NULL bitmap masked it in query results. In either merge order, merge_segments still calls helpers removed by #11283 outside the marked conflict. In the second PR to land, please route new rows through unnest_labels(new_data, new_nulls.clone(), ROW_ADDR)?. A regression on the reopened index should check that a NULL parent contributes no child posting and that a null element in a valid list keeps its posting.

@Xuanwo Thanks for verifying and reviewing! Feel free to merge either PR first. Once one lands, I’ll rebase the other.

@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 25, 2026
@Xuanwo

Xuanwo commented Nov 25, 2026

Copy link
Copy Markdown
Member

Thanks @ddupg. #11283 landed first on main in b014d78b, with the stored-posting regression passing for both List and LargeList. Please rebase #11231, route the new rows in merge_segments through unnest_labels, and check after reopening that a NULL list contributes no child posting while a null element in a valid list keeps its posting.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 25, 2026
@ddupg
ddupg force-pushed the feat/label-list-merge-new-data branch from 0088d3f to 17e980b Compare November 25, 2026 11:39
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 25, 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 rebase correctly applies #11283’s parent-validity expansion to new rows in merge_segments. Reopened stored-index regressions cover both List and LargeList, preserving null-element postings while excluding children of NULL lists. The direct merge preserves per-source filtering, overlays, and the legacy rebuild path while avoiding the intermediate write and merge pass, without changing the storage format.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 25, 2026
@ddupg

ddupg commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @ddupg. #11283 landed first on main in b014d78b, with the stored-posting regression passing for both List and LargeList. Please rebase #11231, route the new rows in merge_segments through unnest_labels, and check after reopening that a NULL list contributes no child posting while a null element in a valid list keeps its posting.

Thanks, @Xuanwo! I’ve rebased #11231 onto main after #11283 landed.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 25, 2026

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the rebase. I verified 17e980b5 on top of b014d78b. All four stored-posting cases passed across List and LargeList, for training and merging new rows. A NULL list contributed only to the list-null bitmap, and a null element inside a valid list kept its posting. All 13 public label_list_optimize cases passed.

In a local deferred-remap, delete and append test with stable row IDs disabled, optimize read the appended data file once and neither compacted data file. After reopening, the stored postings matched the expected live rows, and both positive and negated indexed queries agreed with full scans.

@Xuanwo
Xuanwo merged commit 43d4084 into lance-format:main Nov 30, 2026
44 checks passed
@ddupg
ddupg deleted the feat/label-list-merge-new-data branch November 30, 2026 12:31
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 A-java Java bindings + JNI enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants