zhaih commented on code in PR #12910: URL: https://github.com/apache/lucene/pull/12910#discussion_r1424029197
########## lucene/core/src/java/org/apache/lucene/util/hnsw/NeighborArray.java: ########## @@ -201,9 +225,69 @@ private int descSortFindRightMostInsertionPoint(float newScore, int bound) { int end = bound - 1; while (start <= end) { int mid = (start + end) / 2; - if (score[mid] < newScore) end = mid - 1; + if (scores[mid] < newScore) end = mid - 1; else start = mid + 1; } return start; } + + /** + * Find first non-diverse neighbour among the list of neighbors starting from the most distant + * neighbours + */ + private int findWorstNonDiverse(int nodeOrd, RandomVectorScorerSupplier scorerSupplier) + throws IOException { + RandomVectorScorer scorer = scorerSupplier.scorer(nodeOrd); + int[] uncheckedIndexes = sort(scorer); + if (uncheckedIndexes == null) { + // all nodes are checked, we will directly return the most distant one + return size - 1; + } Review Comment: Good catch it should actually be a code path that's never touched. It becomes clear after we move the check diversity logic inside `addOutOfOrder`, as we only sort after we add something out of order, and because we have out of order element the `uncheckedIndexes` will never be `null`. I'll remove this part and add an assertion here. -- 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