javanna commented on code in PR #13542: URL: https://github.com/apache/lucene/pull/13542#discussion_r1741215790
########## lucene/core/src/java/org/apache/lucene/search/TotalHitCountCollectorManager.java: ########## @@ -28,17 +31,77 @@ */ public class TotalHitCountCollectorManager implements CollectorManager<TotalHitCountCollector, Integer> { + + /** + * Internal state shared across the different collectors that this collector manager creates. It + * tracks leaves seen as an argument of {@link Collector#getLeafCollector(LeafReaderContext)} + * calls, to ensure correctness: if the first partition of a segment early terminates, count has + * been already retrieved for the entire segment hence subsequent partitions of the same segment + * should also early terminate. If the first partition of a segment computes hit counts, + * subsequent partitions of the same segment should do the same, to prevent their counts from + * being retrieve from {@link LRUQueryCache} (which returns counts for the entire segment) + */ + private final Map<LeafReaderContext, Boolean> seenContexts = new HashMap<>(); Review Comment: Given that `IndexSearcher` no longer creates segments partitions by default, I looked into removing the synchronization overhead when it's not needed. That requires providing a flag when creating `TotalHitCountCollectorManager` to indicate whether it needs to to the additional synchronization to support leaf partitions, or not at all. The default `IndexSearcher#count` provides the flag according to how slices have been generated, without changes required on the user side. -- 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