msokolov commented on code in PR #15478:
URL: https://github.com/apache/lucene/pull/15478#discussion_r2593495017


##########
lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraphBuilder.java:
##########
@@ -374,18 +374,26 @@ void addDiverseNeighbors(
       if (hnswLock != null) {
         Lock lock = hnswLock.write(level, nbr);
         try {
-          NeighborArray nbrsOfNbr = getGraph().getNeighbors(level, nbr);
-          nbrsOfNbr.addAndEnsureDiversity(node, candidates.getScores(i), nbr, 
scorer);
+          updateNeighbor(
+              getGraph().getNeighbors(level, nbr), node, 
candidates.getScores(i), nbr, scorer);
         } finally {
           lock.unlock();
         }
       } else {
-        NeighborArray nbrsOfNbr = hnsw.getNeighbors(level, nbr);
-        nbrsOfNbr.addAndEnsureDiversity(node, candidates.getScores(i), nbr, 
scorer);
+        updateNeighbor(hnsw.getNeighbors(level, nbr), node, 
candidates.getScores(i), nbr, scorer);

Review Comment:
   That would enable us to save the check in the "normal" case
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to