cpoerschke commented on code in PR #13635:
URL: https://github.com/apache/lucene/pull/13635#discussion_r1778221739
##########
lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java:
##########
@@ -156,6 +196,55 @@ private TopDocs getLeafResults(
}
}
+ private DocIdSetIterator executeSeedQuery(LeafReaderContext ctx, Weight
seedWeight)
+ throws IOException {
+ if (seedWeight != null) {
+ // Execute the seed query
+ TopScoreDocCollector seedCollector =
+ new TopScoreDocCollectorManager(
+ k /* numHits */,
+ null /* after */,
+ Integer.MAX_VALUE /* totalHitsThreshold */,
+ false /* supportsConcurrency */)
+ .newCollector();
+ LeafCollector leafCollector;
+ try {
+ leafCollector = seedCollector.getLeafCollector(ctx);
+ if (leafCollector != null) {
+ BulkScorer scorer = seedWeight.bulkScorer(ctx);
+ if (scorer != null) {
+ scorer.score(
+ leafCollector,
+ ctx.reader().getLiveDocs(),
+ 0 /* min */,
+ DocIdSetIterator.NO_MORE_DOCS /* max */);
+ }
+ leafCollector.finish();
+ }
+ } catch (
+ @SuppressWarnings("unused")
+ CollectionTerminatedException e) {
+ // there is no doc of interest in this reader context
+ // continue with the following leaf
+ leafCollector = null;
+ }
+
+ TopDocs seedTopDocs = seedCollector.topDocs();
+ return convertDocIdsToVectorOrdinals(ctx.reader(), new
TopDocsDISI(seedTopDocs));
Review Comment:
minor/subjective: could introduce local variable to avoid repeat
`ctx.reader()` call and show that the two parts of the code using the reader
are connected
```
final LeafReader leafReader = ctx.reader();
```
--
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]