You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by so...@apache.org on 2022/08/20 21:28:12 UTC

[lucene] branch main updated: Fix TestHnswGraph rare failure

This is an automated email from the ASF dual-hosted git repository.

sokolov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new daa56d30f0d Fix TestHnswGraph rare failure
daa56d30f0d is described below

commit daa56d30f0dc5370e60adc2dafd9947c65c75d4f
Author: Michael Sokolov <so...@amazon.com>
AuthorDate: Fri Aug 19 16:18:24 2022 -0400

    Fix TestHnswGraph rare failure
---
 .../core/src/test/org/apache/lucene/util/hnsw/TestHnswGraph.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lucene/core/src/test/org/apache/lucene/util/hnsw/TestHnswGraph.java b/lucene/core/src/test/org/apache/lucene/util/hnsw/TestHnswGraph.java
index a3da10590e0..1816de726e4 100644
--- a/lucene/core/src/test/org/apache/lucene/util/hnsw/TestHnswGraph.java
+++ b/lucene/core/src/test/org/apache/lucene/util/hnsw/TestHnswGraph.java
@@ -206,7 +206,7 @@ public class TestHnswGraph extends LuceneTestCase {
           IndexReader reader2 = DirectoryReader.open(dir2)) {
         IndexSearcher searcher = new IndexSearcher(reader);
         IndexSearcher searcher2 = new IndexSearcher(reader2);
-
+        OUTER:
         for (int i = 0; i < 10; i++) {
           // ask to explore a lot of candidates to ensure the same returned hits,
           // as graphs of 2 indices are organized differently
@@ -217,7 +217,14 @@ public class TestHnswGraph extends LuceneTestCase {
           List<Integer> docs2 = new ArrayList<>();
 
           TopDocs topDocs = searcher.search(query, 5);
+          float lastScore = -1;
           for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
+            if (scoreDoc.score == lastScore) {
+              // if we have repeated score this test is invalid
+              continue OUTER;
+            } else {
+              lastScore = scoreDoc.score;
+            }
             Document doc = reader.document(scoreDoc.doc, Set.of("id"));
             ids1.add(doc.get("id"));
             docs1.add(scoreDoc.doc);