cpoerschke commented on code in PR #13635:
URL: https://github.com/apache/lucene/pull/13635#discussion_r1778453629


##########
lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java:
##########
@@ -156,6 +196,49 @@ private TopDocs getLeafResults(
     }
   }
 
+  private DocIdSetIterator executeSeedQuery(LeafReaderContext ctx, Weight 
seedWeight)
+      throws IOException {
+    if (seedWeight == null) return null;
+    // Execute the seed query
+    TopScoreDocCollector seedCollector =
+        new TopScoreDocCollectorManager(
+                k /* numHits */,
+                null /* after */,
+                Integer.MAX_VALUE /* totalHitsThreshold */,
+                false /* supportsConcurrency */)
+            .newCollector();
+    final LeafReader leafReader = ctx.reader();
+    try {
+      final LeafCollector leafCollector = seedCollector.getLeafCollector(ctx);
+      if (leafCollector != null) {
+        BulkScorer scorer = seedWeight.bulkScorer(ctx);
+        if (scorer != null) {
+          scorer.score(
+              leafCollector,
+              leafReader.getLiveDocs(),
+              0 /* min */,
+              DocIdSetIterator.NO_MORE_DOCS /* max */);
+        }
+        leafCollector.finish();
+      }
+    } catch (
+        @SuppressWarnings("unused")
+        CollectionTerminatedException e) {
+    }

Review Comment:
   So that `leafCollector.finish()` is called even when 
`CollectionTerminatedException` was caught, and because (by inspection) 
`getLeafCollector` on this code path does not throw that exception.
   ```suggestion
       final LeafReader leafReader = ctx.reader();
         final LeafCollector leafCollector = 
seedCollector.getLeafCollector(ctx);
         if (leafCollector != null) {
       try {
           BulkScorer scorer = seedWeight.bulkScorer(ctx);
           if (scorer != null) {
             scorer.score(
                 leafCollector,
                 leafReader.getLiveDocs(),
                 0 /* min */,
                 DocIdSetIterator.NO_MORE_DOCS /* max */);
           }
       } catch (
           @SuppressWarnings("unused")
           CollectionTerminatedException e) {
       }
           leafCollector.finish();
         }
   ```



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