cpoerschke commented on code in PR #13635: URL: https://github.com/apache/lucene/pull/13635#discussion_r1755161198
########## lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java: ########## @@ -156,6 +196,58 @@ 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); + } catch ( + @SuppressWarnings("unused") + CollectionTerminatedException e) { + // there is no doc of interest in this reader context + // continue with the following leaf + leafCollector = null; + } + if (leafCollector != null) { + BulkScorer scorer = seedWeight.bulkScorer(ctx); + if (scorer != null) { + try { + scorer.score(leafCollector, ctx.reader().getLiveDocs()); + } catch ( + @SuppressWarnings("unused") + CollectionTerminatedException e) { + // collection was terminated prematurely + // continue with the following leaf + } + } + leafCollector.finish(); + } + + TopDocs seedTopDocs = seedCollector.topDocs(); + return convertDocIdsToVectorOrdinals(ctx, new TopDocsDISI(seedTopDocs)); + } else { + return null; + } + } + + /** + * Returns a new iterator that maps the provided docIds to the vector ordinals. + * + * @lucene.internal + * @lucene.experimental + */ + protected abstract DocIdSetIterator convertDocIdsToVectorOrdinals( + LeafReaderContext ctx, DocIdSetIterator docIds) throws IOException; Review Comment: Since both implementations do a `ctx.reader()` call, wondering if the signature might be narrower then? ```suggestion LeafReader reader, DocIdSetIterator docIds) throws IOException; ``` -- 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