jpountz commented on a change in pull request #106:
URL: https://github.com/apache/lucene/pull/106#discussion_r620046351



##########
File path: lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
##########
@@ -2336,6 +2338,29 @@ static void checkImpacts(Impacts impacts, int 
lastTarget) {
                       + docCount
                       + " docs with values");
             }
+            VectorReader vectorReader = reader.getVectorReader();
+            if (vectorReader instanceof Lucene90HnswVectorReader) {
+              KnnGraphValues graphValues =
+                  ((Lucene90HnswVectorReader) 
vectorReader).getGraphValues(fieldInfo.name);
+              int size = graphValues.size();
+              for (int i = 0; i < size; i++) {
+                graphValues.seek(i);
+                for (int neighbor = graphValues.nextNeighbor();
+                    neighbor != NO_MORE_DOCS;
+                    neighbor = graphValues.nextNeighbor()) {
+                  if (neighbor < 0 || neighbor >= size) {
+                    throw new RuntimeException(
+                        "Field \""
+                            + fieldInfo.name
+                            + "\" has an invalid neighbor ordinal: "
+                            + neighbor
+                            + " which should be in [0,"
+                            + size
+                            + ")");
+                  }
+                }
+              }
+            }

Review comment:
       Codec-specific tests do not feel like a good fit for CheckIndex, should 
it move to TestLucene90HnswVectorFormat?




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

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