org.apache.solr.search.stats

## Class StatsCache

- java.lang.Object
- - org.apache.solr.search.stats.StatsCache

- All Implemented Interfaces:
    PluginInfoInitialized
  Direct Known Subclasses:
    ExactStatsCache, LocalStatsCache

      public abstract class StatsCache
      extends Object
      implements PluginInfoInitialized

  This class represents a cache of global document frequency information for selected terms. This information is periodically updated from all shards, either through scheduled events of some kind, or on every request when there is no global stats available for terms involved in the query (or if this information is stale due to changes in the shards).

  There are instances of this class at the aggregator node (where the partial data from shards is aggregated), and on each core involved in a shard request (where this data is maintained and updated from the central cache).

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `COL_STATS_KEY` Value of `CollectionStats`.
    `static String` | `TERM_STATS_KEY` Map of terms and `TermStats`.
    `static String` | `TERMS_KEY` List of terms in the query.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StatsCache()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract StatsSource` | `get(SolrQueryRequest req)` Prepare local `StatsSource` to provide stats information to perform local scoring (to be precise, to build a local `Weight` from the query).
    `abstract void` | `mergeToGlobalStats(SolrQueryRequest req, List<ShardResponse> responses)` Process shard responses that contain partial local stats.
    `abstract void` | `receiveGlobalStats(SolrQueryRequest req)` Receive global stats data from the master and update a local cache of stats with this global data.
    `abstract ShardRequest` | `retrieveStatsRequest(ResponseBuilder rb)` Creates a `ShardRequest` to retrieve per-shard stats related to the current query and the current state of the requester's `StatsCache`.
    `abstract void` | `returnLocalStats(ResponseBuilder rb, SolrIndexSearcher searcher)` Prepare a local (from the local shard) response to a "retrieve stats" shard request.
    `abstract void` | `sendGlobalStats(ResponseBuilder rb, ShardRequest outgoing)` Prepare global stats data to be sent out to shards in this request.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.solr.util.plugin.PluginInfoInitialized

      `init`

- - ### Field Detail

    - #### TERM_STATS_KEY

          public static final String TERM_STATS_KEY

      Map of terms and `TermStats`.
      See Also:
        Constant Field Values

    - #### COL_STATS_KEY

          public static final String COL_STATS_KEY

      Value of `CollectionStats`.
      See Also:
        Constant Field Values

    - #### TERMS_KEY

          public static final String TERMS_KEY

      List of terms in the query.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### StatsCache

          public StatsCache()

  - ### Method Detail

    - #### retrieveStatsRequest

          public abstract ShardRequest retrieveStatsRequest(ResponseBuilder rb)

      Creates a `ShardRequest` to retrieve per-shard stats related to the current query and the current state of the requester's `StatsCache`.
      Parameters:
        `rb` - contains current request
      Returns:
        shard request to retrieve stats for terms in the current request, or null if no additional request is needed (e.g. if the information in global cache is already sufficient to satisfy this request).

    - #### returnLocalStats

          public abstract void returnLocalStats(ResponseBuilder rb,
                                                SolrIndexSearcher searcher)

      Prepare a local (from the local shard) response to a "retrieve stats" shard request.
      Parameters:
        `rb` - response builder
        `searcher` - current local searcher

    - #### mergeToGlobalStats

          public abstract void mergeToGlobalStats(SolrQueryRequest req,
                                                  List<ShardResponse> responses)

      Process shard responses that contain partial local stats. Usually this entails combining per-shard stats for each term.
      Parameters:
        `req` - query request
        `responses` - responses from shards containing local stats for each shard

    - #### receiveGlobalStats

          public abstract void receiveGlobalStats(SolrQueryRequest req)

      Receive global stats data from the master and update a local cache of stats with this global data. This event occurs either as a separate request, or together with the regular query request, in which case this method is called first, before preparing a `QueryCommand` to be submitted to the local `SolrIndexSearcher`.
      Parameters:
        `req` - query request with global stats data

    - #### sendGlobalStats

          public abstract void sendGlobalStats(ResponseBuilder rb,
                                               ShardRequest outgoing)

      Prepare global stats data to be sent out to shards in this request.
      Parameters:
        `rb` - response builder
        `outgoing` - shard request to be sent

    - #### get

          public abstract StatsSource get(SolrQueryRequest req)

      Prepare local `StatsSource` to provide stats information to perform local scoring (to be precise, to build a local `Weight` from the query).
      Parameters:
        `req` - query request
      Returns:
        an instance of `StatsSource` to use in creating a query `Weight`

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.