HUSTERGS commented on code in PR #14896:
URL: https://github.com/apache/lucene/pull/14896#discussion_r2192660438


##########
lucene/core/src/test/org/apache/lucene/util/TestVectorUtil.java:
##########
@@ -390,6 +391,45 @@ private static int slowFindNextGEQ(int[] buffer, int 
length, int target, int fro
     return length;
   }
 
+  public void testFilterByScore() {
+    for (int iter = 0; iter < 1_000; ++iter) {
+      int padding = TestUtil.nextInt(random(), 0, 5);
+      DocAndScoreAccBuffer b1 = new DocAndScoreAccBuffer();
+      DocAndScoreAccBuffer b2 = new DocAndScoreAccBuffer();
+      b1.growNoCopy(128 + padding);
+      b2.growNoCopy(128 + padding);
+
+      int doc = 0;
+      for (int i = 0; i < 128; ++i) {
+        doc += TestUtil.nextInt(random(), 1, 1000);
+        b1.docs[i] = b2.docs[i] = doc;
+        b1.scores[i] = b2.scores[i] = random().nextDouble();
+      }
+
+      double minScoreInclusive = random().nextDouble();
+      int upTo = TestUtil.nextInt(random(), 0, 127);
+      b1.size = slowFilterByScore(b1.docs, b1.scores, minScoreInclusive, upTo);
+      b2.size = VectorUtil.filterByScore(b2.docs, b2.scores, 
minScoreInclusive, upTo);
+      assertEquals(b1.size, b2.size);
+      assertArrayEquals(b1.docs, b2.docs);
+      // two double array should be exactly the same, so the delta should be 0
+      assertArrayEquals(b1.scores, b2.scores, 0);

Review Comment:
   Yeah, you're right !



-- 
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-unsubscr...@lucene.apache.org

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


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

Reply via email to