[Fix] [DiskSeismic]: take the exact-match path when the ID selector is smaller than k - #52
Merged
chishui merged 2 commits intoSep 9, 2026
Conversation
…tor is smaller than k Signed-off-by: Zirui Song <zrsong@amazon.com>
zirui-song-18
requested review from
chishui,
model-collapse and
yuye-aws
as code owners
September 8, 2026 09:39
chishui
reviewed
Sep 9, 2026
chishui
left a comment
Collaborator
There was a problem hiding this comment.
does this change impact latency? have you benchmarked?
| index_mapping_ = std::move(mapped); | ||
| } | ||
|
|
||
| auto DiskSeismicIndexBase::exact_match_mapped( |
Collaborator
There was a problem hiding this comment.
not necessary to name with "_mapped"
| static_cast<uint64_t>(doc_id) >= num_locators_) { | ||
| continue; // out-of-range member: nothing to score | ||
| } | ||
| const detail::DocLocator loc = doc_locators_[doc_id]; |
Collaborator
There was a problem hiding this comment.
from 371-399 is basically a get_doc function. Also, I'm wondering if we can use a same exact_match function with get_doc an input to differenciate the exact_match in seismic and disk
Signed-off-by: Zirui Song <zrsong@amazon.com>
Collaborator
Author
It won't impact latency. |
chishui
approved these changes
Sep 9, 2026
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.
Description
SeismicIndexandSeismicScalarQuantizedIndextake an exact-match path when the query carries an enumerableIDSelectorof size <= k: they score exactly the selected docs and return all of them. The disk-resident indexes (DiskSeismicIndex,DiskSeismicScalarQuantizedIndex) did not — they always ran the block-budget search and applied the selector only as a post-filter over the top-k' blocks, so a selected doc that fell in no scored block was silently dropped. A field filtered to fewer than k docs could therefore return too few results (or none).This routes the disk-resident indexes through the exact-match path too:
get_vectors()is doc-id-addressable): reuse ExactMatcher.Also hardened along the way: ExactMatcher now skips selector ids outside the index instead of indexing out of bounds, and the mapped remainder lookup is bounds-checked (fail-closed, matching the rest of the mmap read path).
Format / cost. The serialized index gains a locator-directory + remainder section after the inline forward. Overhead is a flat ~12 bytes/doc (the directory); the remainder is empty whenever posting-list pruning drops nothing. On a ~23.6 GB base_small index this measured +1.2 MB (+0.005%). The directory and remainder are borrowed from the mapping (not copied to the heap), so resident memory is unchanged; normal (non-filtered) queries take a guarded early check and the identical block-budget path, so their latency is unchanged.
Testing
Issues Resolved
#49
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.