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/31 09:49:25 UTC

[GitHub] [lucene] mocobeta commented on a diff in pull request #932: LUCENE-10559: Add Prefilter Option to KnnGraphTester

mocobeta commented on code in PR #932:
URL: https://github.com/apache/lucene/pull/932#discussion_r885435733


##########
lucene/core/src/test/org/apache/lucene/util/hnsw/KnnGraphTester.java:
##########
@@ -730,4 +774,79 @@ protected int comparePivot(int j) {
       return Float.compare(score[pivot], score[j]);
     }
   }
+
+  private static class SelectiveQuery extends Query {
+
+    public float selectivity = 1f;
+    private FixedBitSet selectedBits;
+    private long cost;
+
+    public void createBitSet(int numDocs) {
+      selectedBits = new FixedBitSet(numDocs);
+      if (selectivity == 1f) {
+        selectedBits.set(0, numDocs);
+        cost = numDocs;
+      } else {
+        selectedBits.clear(0, numDocs);
+        cost = 0;
+        for (int i = 0; i < numDocs; i++) {
+          if (Math.random() < selectivity) {
+            selectedBits.set(i);
+            cost++;
+          }
+        }
+      }
+    }
+
+    @Override
+    public String toString(String field) {
+      return "SelectiveQuery[" + selectivity + "]";
+    }
+
+    @Override
+    public void visit(QueryVisitor visitor) {
+      visitor.visitLeaf(this);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+      return obj instanceof SelectiveQuery && obj.hashCode() == this.hashCode();

Review Comment:
   It looks like ErrorProne complains about this line (cause of the CI failure). 
   https://github.com/apache/lucene/runs/6666473724?check_suite_focus=true#step:6:624
   
   I wonder if `obj.selectivity == this.selectivity` could work instead of checking hashCode().



-- 
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