-
Notifications
You must be signed in to change notification settings - Fork 136
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
Introduces NativeEngineKNNQuery which executes ANN on rewrite #1877
Conversation
src/main/java/org/opensearch/knn/search/NativeEngineKnnVectorQuery.java
Outdated
Show resolved
Hide resolved
@shatejas Lets ensure all CI are working. I know this code is only for feedback. but successful CIs gives confidence. |
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.
Overall code looks good to me. I would like to see other usecase of KNNQuery getting added here like currently filters are not present here. Similarly Radial search, other ITs and BWC tests.
src/main/java/org/opensearch/knn/search/NativeEngineKnnVectorQuery.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/search/NativeEngineKnnVectorQuery.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/search/NativeEngineKnnVectorQuery.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/search/NativeEngineKnnVectorQuery.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/search/NativeEngineKnnVectorQuery.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/search/NativeEngineKnnVectorQuery.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/search/NativeEngineKnnVectorQuery.java
Outdated
Show resolved
Hide resolved
d923ba0
to
8d9b082
Compare
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.
Overall looks good. Few minor comments
src/main/java/org/opensearch/knn/index/query/nativelib/DocAndScoreQuery.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/index/query/nativelib/NativeEngineKnnVectorQuery.java
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/index/query/nativelib/NativeEngineKnnVectorQuery.java
Show resolved
Hide resolved
5ec1eb6
to
ff64081
Compare
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.
LGTM
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.
Looks Good to me .
* @param context LeafReaderContext | ||
* @return A Map of docId to scores for top k results | ||
*/ | ||
public Map<Integer, Float> searchLeaf(LeafReaderContext context) throws IOException { | ||
|
||
final BitSet filterBitSet = getFilteredDocsBitSet(context); | ||
int cardinality = filterBitSet.cardinality(); | ||
// We don't need to go to JNI layer if no documents are found which satisfy the filters | ||
// We should give this condition a deeper look that where it should be placed. For now I feel this is a good | ||
// place, |
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 think this comment does not describe the new change added. Can you describe why are we returning an empty Map?
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.
It still applies - Its an optimization where we don't search (don't go to JNI layer). filters being empty indicates no results were found. Doing additional search will always results in empty response.
We are returning empty Map to indicate that there were no matches. This is for both NativeEngineKnnVectorQuery as well as scorer
in this class. The emtyScorer part is simply moved to line 113
Minor comments, overall code looks good to me |
@shatejas please resolve conflicts. |
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.
Can you fix changelog? Other than that looks good
CHANGELOG.md
Outdated
@@ -28,5 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | |||
* Clean up parsing for query [#1824](https://github.com/opensearch-project/k-NN/pull/1824) | |||
* Refactor engine package structure [#1913](https://github.com/opensearch-project/k-NN/pull/1913) | |||
* Refactor method structure and definitions [#1920](https://github.com/opensearch-project/k-NN/pull/1920) | |||
* Generalize lib interface to return context objects [#1925](https://github.com/opensearch-project/k-NN/pull/1925) |
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.
duplicate changelog entry
Signed-off-by: Tejas Shah <[email protected]>
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.
LGTM thanks
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-1877-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 df7627c6e580843beb2361f5c2ec3519efd52280
# Push it to GitHub
git push --set-upstream origin backport/backport-1877-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x Then, create a pull request where the |
…arch-project#1877) Signed-off-by: Tejas Shah <[email protected]> (cherry picked from commit df7627c)
…arch-project#1877) Signed-off-by: Tejas Shah <[email protected]> (cherry picked from commit df7627c)
…#1943) Signed-off-by: Tejas Shah <[email protected]> (cherry picked from commit df7627c)
Description
All integration tests are passing. Cannot support radial currently since k is not significant, there are ways to do it but since its not planned for 2.17 this should work
Related Issues
Resolves #1845
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.