gsmiller commented on code in PR #13463:
URL: https://github.com/apache/lucene/pull/13463#discussion_r1631767073


##########
lucene/core/src/java/org/apache/lucene/search/knn/MultiLeafKnnCollector.java:
##########
@@ -103,8 +105,11 @@ public boolean collect(int docId, float similarity) {
     if (kResultsCollected) {
       // as we've collected k results, we can start do periodic updates with 
the global queue
       if (firstKResultsCollected || (subCollector.visitedCount() & interval) 
== 0) {
-        cachedGlobalMinSim = 
globalSimilarityQueue.offer(updatesQueue.getHeap());
-        updatesQueue.clear();
+        for (int i = 0; i < k(); i++) {

Review Comment:
   Yeah, thanks @msokolov for the suggestion. Added a comment to explain. But 
yes, `#offer` expects a fully sorted array of values and has short-circuiting 
logic that depends on that assumption, but the backing array of a heap is only 
partially ordered, so you can hit edge-cases where `#offer` incorrectly 
short-circuits too early.



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

Reply via email to