-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add check to directly use ANN Search when filters match all docs. #2320
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Wei Wang <[email protected]>
e05c94f
to
fbc6cf9
Compare
5cebe5c
to
d39c6e8
Compare
Signed-off-by: Wei Wang <[email protected]>
d39c6e8
to
105c39a
Compare
* If filters match all docs in this segment, then there is no need to do any extra step | ||
* and should directly do ANN Search*/ | ||
if (filterWeight != null && cardinality == maxDoc) { | ||
return new PerLeafResult(new FixedBitSet(0), doANNSearch(context, new FixedBitSet(0), 0, k)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see lots of new FixedBitSet(0)
in KNNWeight.
Could you factor it out with a meaningful name as a static variable then pass it down to the downstream?
private static final FixedBitSet ... = new FixedBitSet(0);
@@ -145,6 +146,12 @@ public PerLeafResult searchLeaf(LeafReaderContext context, int k) throws IOExcep | |||
Map<Integer, Float> result = doExactSearch(context, new BitSetIterator(filterBitSet, cardinality), cardinality, k); | |||
return new PerLeafResult(filterWeight == null ? null : filterBitSet, result); | |||
} | |||
/* | |||
* If filters match all docs in this segment, then there is no need to do any extra step |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give more context to the comment?? Would like to see why there's no need for extra steps for all doc matches case, and what passing new FixedBitSet(0)
means. Basically, we want to save a bitset look up cost when it's not required as possible.
Description
This change aims to resolve this github issue: #1387
by adding a simple check in searchLeaf method so that if the filters match all doc IDs in the segment (Max Doc == size of FilterBitSet), then we directly do ANN search and avoid other unnecessary steps. This will help improve the search performance.
Related Issues
Resolves #1387
Check List
--signoff
.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.