mayya-sharipova commented on a change in pull request #416: URL: https://github.com/apache/lucene/pull/416#discussion_r784284891
########## File path: lucene/core/src/test/org/apache/lucene/util/hnsw/TestHnswGraph.java ########## @@ -116,33 +116,59 @@ public KnnVectorsFormat getKnnVectorsFormatForField(String field) { ((CodecReader) ctx.reader()).getVectorReader()) .getFieldReader("field")) .getGraphValues("field"); - assertGraphEqual(hnsw, graphValues, nVec); + assertGraphEqual(hnsw, graphValues); } } } } + private void assertGraphEqual(KnnGraphValues g, KnnGraphValues h) throws IOException { + assertEquals("the number of levels in the graphs are different!", g.numLevels(), h.numLevels()); + assertEquals("the number of nodes in the graphs are different!", g.size(), h.size()); + + // assert equal nodes on each level + for (int level = 0; level < g.numLevels(); level++) { + NodesIterator nodesOnLevel = g.getNodesOnLevel(level); + NodesIterator nodesOnLevel2 = h.getNodesOnLevel(level); + while (nodesOnLevel.hasNext() && nodesOnLevel2.hasNext()) { + int node = nodesOnLevel.nextInt(); + int node2 = nodesOnLevel2.nextInt(); + assertEquals("nodes in the graphs are different", node, node2); + } + } + + // assert equal nodes' neighbours on each level + for (int level = 0; level < g.numLevels(); level++) { + NodesIterator nodesOnLevel = g.getNodesOnLevel(level); + while (nodesOnLevel.hasNext()) { + int node = nodesOnLevel.nextInt(); + g.seek(level, node); + h.seek(level, node); + assertEquals("arcs differ for node " + node, getNeighborNodes(g), getNeighborNodes(h)); + } + } + } + // Make sure we actually approximately find the closest k elements. Mostly this is about // ensuring that we have all the distance functions, comparators, priority queues and so on // oriented in the right directions public void testAknnDiverse() throws IOException { + int maxConn = 10; int nDoc = 100; - CircularVectorValues vectors = new CircularVectorValues(nDoc); + TestHnswGraph.CircularVectorValues vectors = new TestHnswGraph.CircularVectorValues(nDoc); Review comment: Addressed in 7bce9f15daa225243c034c22ca9cb3d581e09fc5 -- 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