feat(scanner): add external row-address mask prefilter#7288
Draft
JulianYG wants to merge 1 commit into
Draft
Conversation
Lets callers pass a serialized RowAddrMask as an allow/block prefilter into vector and plain scans, reusing the scanner's retrieval plan. The mask feeds the KNN prefilter source on the ANN branch and FilteredReadExec as the row source for non-vector scans; a new RowAddrMaskFilterExec honors the mask on the flat/unindexed-fragment branch. Addresses lance-format#6852. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #6852.
What
Adds
Scanner::with_row_addr_prefilter(RowAddrMask), letting callers pass aprecomputed row-address allow/block mask as a prefilter into vector and plain
scans, reusing the scanner's existing retrieval plan rather than re-deriving it.
Motivation
Some pipelines precompute a set of eligible rows out-of-band (e.g. a stored
bitmap of rows belonging to a logical subset / dataset) and want to run KNN or a
plain scan restricted to that set -- without expressing it as a SQL filter. A
multi-hundred-thousand-element
IN (...)is impractical to build and parse;passing the row set directly is far cheaper.
How
The mask threads into the existing prefilter machinery at three points:
PreFilterSourceintonew_knn_exec, ANDed withany deletion/SQL prefilter via a
MaskAndLoader.RowAddrMaskFilterExecfiltersscan output by
_rowid, so rows appended after the index build are honored.FilteredReadExecindex input, so only masked rows are read; a SQL filter becomes a refine on top.
Deletions are still applied by
DatasetPreFilter; illegal addresses are ignored.Status
Draft, pending API agreement on #6852. Behavior is exercised by an out-of-tree
PyO3 binding's test suite (based on v7.0.0, this PR is rebased);
cargo check -p lanceandcargo fmtare clean. I'dappreciate guidance on the public API shape before finalizing in-tree tests.