Class TotalHitCountCollectorManager

java.lang.Object
org.apache.lucene.search.TotalHitCountCollectorManager
All Implemented Interfaces:
CollectorManager<TotalHitCountCollector,Integer>

public class TotalHitCountCollectorManager extends Object implements CollectorManager<TotalHitCountCollector,Integer>
Collector manager based on TotalHitCountCollector that allows users to parallelize counting the number of hits, expected to be used mostly wrapped in MultiCollectorManager. For cases when this is the only collector manager used, IndexSearcher.count(Query) should be called instead of IndexSearcher.search(Query, CollectorManager) as the former is faster whenever the count can be returned directly from the index statistics.
  • Field Details

    • hasSegmentPartitions

      private final boolean hasSegmentPartitions
    • earlyTerminatedMap

      private final Map<Object,Future<Boolean>> earlyTerminatedMap
      Internal state shared across the different collectors that this collector manager creates. This is necessary to support intra-segment concurrency. We track leaves seen as an argument of 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 without further incrementing hit count. 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 retrieved from LRUQueryCache (which returns counts for the entire segment while we'd need only that of the current leaf partition).
  • Constructor Details

    • TotalHitCountCollectorManager

      public TotalHitCountCollectorManager(IndexSearcher.LeafSlice[] leafSlices)
      Creates a new total hit count collector manager, providing the array of leaf slices that search targets, which can be retrieved via IndexSearcher.getSlices() for the searcher.
      Parameters:
      leafSlices - the slices that the searcher targets. Used to optimize the collection depending on whether segments have been partitioned into partitions or not.
  • Method Details