You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/05/02 16:14:38 UTC

[GitHub] [lucene] msokolov commented on a diff in pull request #859: LUCENE-10552: KnnVectorQuery has incorrect equals/ hashCode

msokolov commented on code in PR #859:
URL: https://github.com/apache/lucene/pull/859#discussion_r862982712


##########
lucene/core/src/java/org/apache/lucene/search/KnnVectorQuery.java:
##########
@@ -288,15 +288,20 @@ public void visit(QueryVisitor visitor) {
 
   @Override
   public boolean equals(Object obj) {
-    return sameClassAs(obj)
-        && ((KnnVectorQuery) obj).k == k
-        && ((KnnVectorQuery) obj).field.equals(field)
-        && Arrays.equals(((KnnVectorQuery) obj).target, target);
+    if (sameClassAs(obj) == false) {
+      return false;
+    }
+    return ((KnnVectorQuery) obj).k == k
+            && ((KnnVectorQuery) obj).field.equals(field)
+            && Arrays.equals(((KnnVectorQuery) obj).target, target)
+            && ((KnnVectorQuery) obj).filter == null
+        ? filter == null

Review Comment:
   How about using Objects.equals(filter, ((KnnVectorQuery) obj).filter)? This will handle the null==null case



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org