[Vector Upsert 1/5] Support allowed-document filtering in exact vector scan - #19297
[Vector Upsert 1/5] Support allowed-document filtering in exact vector scan#19297xiangfu0 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds allowed-document filtering groundwork for exact vector scans, supporting future FULL-upsert candidate scoping.
Changes:
- Adds immutable
VectorCandidateScope. - Unifies filtered top-K and threshold exact scans.
- Adds exact-scan and filtered HNSW tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
ExactVectorScanFilterOperator.java |
Implements bitmap-restricted exact scanning and explain attributes. |
VectorCandidateScope.java |
Adds immutable query-scoped document constraints. |
ExactVectorScanFilterOperatorTest.java |
Tests filtered exact-scan behavior and boundaries. |
HnswVectorIndexCreatorTest.java |
Tests filtered HNSW retrieval. |
Suppressed comments (1)
pinot-core/src/main/java/org/apache/pinot/core/operator/filter/ExactVectorScanFilterOperator.java:293
- This reports the unbounded input bitmap cardinality rather than the effective set actually scanned. For the new
{2, 99}/numDocs = 3case, the operator scores one document but reports two effective allowed IDs. Count only IDs in[0, _numDocs)so explain output matches the watermark behavior.
private int getEffectiveAllowedDocIdsCardinality() {
return getRequiredUpsertCandidateCardinality();
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| attributeBuilder.putLongIdempotent("upsertCandidateFilterCardinality", getRequiredUpsertCandidateCardinality()); | ||
| attributeBuilder.putLongIdempotent("effectiveAllowedDocIdsCardinality", | ||
| getEffectiveAllowedDocIdsCardinality()); |
| if ((allowedDocIds != null && allowedDocIds.isEmpty()) || (distanceThreshold == null && topK <= 0)) { | ||
| return new MutableRoaringBitmap(); |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #19297 +/- ##
============================================
- Coverage 67.20% 67.20% -0.01%
Complexity 1424 1424
============================================
Files 3462 3463 +1
Lines 220361 220388 +27
Branches 35147 35156 +9
============================================
+ Hits 148087 148103 +16
- Misses 60467 60474 +7
- Partials 11807 11811 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…r scan Extract a shared computeExactMatches helper that unifies the exact top-K and threshold scan paths and can restrict scoring to an allowed-document bitmap. Introduce VectorCandidateScope, an immutable set of document IDs a vector predicate is allowed to consider as candidates. Vector top-K is not monotonic, so unlike an ordinary predicate -- which is correct to intersect with the result afterwards -- a document set that defines what the query may see has to be applied before candidate generation. The type carries that contract and says nothing about where the restriction came from; callers decide that. ExactVectorScanFilterOperator accepts one via a new constructor overload, and no production caller passes one yet. Also let the operator record its own exact-scan search and fallback metrics, which were previously invisible to VectorSearchMetrics, and report the applied candidate-filter cardinality in explain output. Add filtered-reader coverage for HnswVectorIndexReader.
5796c1c to
0edb57b
Compare
Part 1/5 of the split of #19287 (Fix FULL-upsert vector candidate generation).
Summary
Groundwork for constraining vector candidate generation to the documents a query may
actually see (wired up in part 4/5):
computeExactMatcheshelper inExactVectorScanFilterOperatorthatunifies the exact top-K and threshold scan paths and can restrict scoring to an
allowed-document bitmap. Only allowed document IDs are read from the forward index, and
IDs beyond the
numDocswatermark are ignored.VectorCandidateScope, an immutable set of document IDs a vector predicateis allowed to consider as candidates. Vector top-K is not monotonic: unlike an ordinary
predicate — which is correct to intersect with the result afterwards — a document set
that defines what the query may see has to be applied before candidate generation.
The type carries that contract and deliberately says nothing about where the
restriction came from; callers decide that.
ExactVectorScanFilterOperatoraccepts onethrough a new constructor overload, and no production caller passes one yet.
were previously invisible to
VectorSearchMetricsentirely.scope actually restricts the scan.
HnswVectorIndexReader.getDocIds(query, k, allowed).Validation
All commands ran with JDK 25.
ExactVectorScanFilterOperatorTest: 16 tests passed (6 new allowed-document tests).HnswVectorIndexCreatorTest: 6 tests passed (1 new filtered-reader test).Stack