Skip to content

feat(index): support distributed optimize for MinHash LSH - #10884

Merged
zhangyue19921010 merged 1 commit into
lance-format:mainfrom
ddupg:feat/minhash-lsh-distributed-optimize
Nov 20, 2026
Merged

zhangyue19921010 merged 1 commit into
lance-format:mainfrom
ddupg:feat/minhash-lsh-distributed-optimize

Conversation

@ddupg

@ddupg ddupg commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enable bounded distributed optimize for MinHash LSH when max_rows_per_task or max_rows_per_segment is set.

Part of #10847.

  • When a single build task absorbs existing segments, it writes their stored signatures and the signatures computed from new rows into one output segment.
  • When a group has multiple build tasks, the existing physical merge combines their outputs with the selected segments. It preserves the oldest source dataset_version so ordinary queries can mask stale signatures and score current overlay values. Single-task optimize refreshes stale signatures during the build.
  • Bounded planning follows the existing rules for tagged fragment reuse, pending compaction remaps, and segments backed by a shallow clone’s base dataset.

Testing

91 focused Rust tests passed. Workspace Clippy on macOS arm64 stopped on existing unreachable-code diagnostics in lance-encoding.

@github-actions github-actions Bot added A-index Vector index, linalg, tokenizer enhancement New feature or request labels Nov 10, 2026
@ddupg
ddupg marked this pull request as ready for review November 10, 2026 10:43

@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 10, 2026
@ddupg ddupg changed the title feat(index): support distributed optimize for MinHash LSH feat(index)!: support distributed optimize for MinHash LSH Nov 10, 2026
@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 10, 2026
@ddupg

ddupg commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Could @zhangyue19921010 help review this when you have chance.

@zhangyue19921010 zhangyue19921010 self-assigned this Nov 10, 2026
@ddupg
ddupg force-pushed the feat/minhash-lsh-distributed-optimize branch from 40f607c to 3bae158 Compare November 12, 2026 03:40
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 12, 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 12, 2026
|| segment_has_btree_details(segment)
|| segment_has_bitmap_details(segment)
|| segment_has_ngram_details(segment)
|| segment_has_minhashlsh_details(segment)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

With stable row IDs on a shallow clone, bounded optimize retains the old segment while indexing the updated row, allowing its stale signature to pass the shared row-ID mask and match the old text again. Please fall back to unsplit optimization or filter the stale entry before publishing the new segment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this. This is fixed after rebasing onto #9858, which switched MinHash LSH segments from _rowid to _rowaddr. Even when a shallow clone retains the original segment, search now drops the deleted row address before resolving it to a stable row ID. That prevents the old signature from matching the updated row.

For legacy v0 segments on datasets with stable row IDs, optimize now uses a single task to rebuild them from live rows in the v1 format.

if single_task {
plan.read_version
} else {
source_version

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Taking the minimum source dataset_version can incorrectly mask a freshly indexed overlay row: a merge-only repro changes fast_search from [12] to [] without any data update. Please preserve source freshness or refresh stale rows before advancing the merged segment’s version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@zhangyue19921010 Thanks for pointing this out. Taking the minimum source version can indeed hide an overlay row that a newer segment has already indexed.

Scalar filtering re-evaluates stale rows even with fast_search, whereas FTS, vector, and MinHash searches skip that fallback. MinHash is closer to FTS in its ranked-search semantics, so I’d prefer to keep their behavior aligned.

MinHash’s previous optimize path updated or rebuilt the index using current data, incorporating overlay changes. The physical-merge path used by bounded optimize instead reuses stored entries without refreshing overlays and retains the oldest source version. The current FTS and vector merge paths use the same policy.

I’ve opened #11180 to track this shared limitation. I propose keeping this PR consistent with the existing FTS merge behavior and addressing overlay freshness across all three index types together in that follow-up.

@ddupg
ddupg force-pushed the feat/minhash-lsh-distributed-optimize branch from 3bae158 to ed8fcf6 Compare November 13, 2026 05:09
@ddupg ddupg changed the title feat(index)!: support distributed optimize for MinHash LSH feat(index): support distributed optimize for MinHash LSH Nov 13, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 13, 2026
@ddupg
ddupg force-pushed the feat/minhash-lsh-distributed-optimize branch from ed8fcf6 to bccc4c7 Compare November 13, 2026 05:16
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 13, 2026
Xuanwo added a commit that referenced this pull request Nov 16, 2026
Part of #10847.

A bounded `optimize_indices` (`max_rows_per_task` /
`max_rows_per_segment`) now splits a BloomFilter index into tasks and
merges its segments by their zones; before, the whole index stayed in
one task, and the single-process `merge(N >= 2)` rebuilt the segments by
rescanning the column. The new
`merge_bloomfilter_indices_with_new_data`, next to the unchanged
`merge_bloomfilter_indices`, keeps each segment's zones and null rows
over its live fragments and trains zones for the new rows with the
trainer `update` uses. `merge_scalar_indices` takes this path for two or
more segments, and the planner adds BloomFilter to
`segment_has_merge_primitive`.

Segments merge by zones only when each records its null rows and shares
the build parameters (read from the file metadata without loading
zones), when none holds zones of a fragment that an in-place column
rewrite took out of its coverage (read from the zones' fragment ids,
including fragments a deferred compaction has since moved), and when the
table has no tagged fragment reuse history, no compaction remap pending
on them and no segment in a shallow clone's base; otherwise the index
stays one task, as before.

Out of scope, since `main` has them too: #10986 (the default optimize
keeps a rewritten fragment's old null rows through `update`) and #10987
(a segment outside the merge keeps answering for a rewritten fragment
once another segment indexes it). This PR is independent of #10884
(MinHashLSH): both touch `segment_has_merge_primitive` and the module
docs, so whichever lands second rebases mechanically.

---------

Co-authored-by: Xuanwo <[email protected]>
@ddupg
ddupg force-pushed the feat/minhash-lsh-distributed-optimize branch from bccc4c7 to a3f4e1b Compare November 17, 2026 12:41
@lance-gatekeeper lance-gatekeeper Bot removed the K-risk Latest Gatekeeper recommendation includes a non-blocking risk. label Nov 17, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 17, 2026
@ddupg
ddupg force-pushed the feat/minhash-lsh-distributed-optimize branch from a3f4e1b to 633a1b5 Compare November 17, 2026 12:57

@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 with a non-blocking risk.

The current physical row address handling from merged #9858 fixes the stale shallow-clone match. The rebased planner also retains the rebuild in one task for legacy segments on datasets with stable row IDs.

The freshness concern remains: split merges of segments with different dataset versions can hide freshly indexed overlay rows from fast_search. This is confined to the weak consistency search mode; ordinary searches still rescore these rows correctly. Use ordinary search when updated-row visibility is required.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 17, 2026

@zhangyue19921010 zhangyue19921010 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM Thanks for this change!

@zhangyue19921010
zhangyue19921010 merged commit 8d3ed96 into lance-format:main Nov 20, 2026
41 of 42 checks passed
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 breaking-change enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants