zhaih commented on code in PR #12480: URL: https://github.com/apache/lucene/pull/12480#discussion_r1312372706
########## lucene/CHANGES.txt: ########## @@ -90,6 +90,8 @@ Optimizations * GITHUB#12408: Lazy initialization improvements for Facets implementations when there are segments with no hits to count. (Greg Miller) + +* GITHUB##12371: enable lazy computation of similarity score during initializeFromGraph (Jack Wang) Review Comment: Put it under Lucene 9.8? ########## lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraphBuilder.java: ########## @@ -205,27 +204,15 @@ private void initializeFromGraph( initializedNodes.add(newOrd); } - switch (this.vectorEncoding) { - case FLOAT32 -> vectorValue = (float[]) vectors.vectorValue(newOrd); - case BYTE -> binaryValue = (byte[]) vectors.vectorValue(newOrd); - } - NeighborArray newNeighbors = this.hnsw.getNeighbors(level, newOrd); initializerGraph.seek(level, oldOrd); for (int oldNeighbor = initializerGraph.nextNeighbor(); oldNeighbor != NO_MORE_DOCS; oldNeighbor = initializerGraph.nextNeighbor()) { int newNeighbor = oldToNewOrdinalMap.get(oldNeighbor); - float score = - switch (this.vectorEncoding) { - case FLOAT32 -> this.similarityFunction.compare( - vectorValue, (float[]) vectorsCopy.vectorValue(newNeighbor)); - case BYTE -> this.similarityFunction.compare( - binaryValue, (byte[]) vectorsCopy.vectorValue(newNeighbor)); - }; // we are not sure whether the previous graph contains Review Comment: Update this comment like `We will compute those scores lazily when we need to pop out the non-diverse nodes`? -- 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