Package org.apache.solr.search.stats
Class ExactStatsCache
- java.lang.Object
-
- org.apache.solr.search.stats.StatsCache
-
- org.apache.solr.search.stats.ExactStatsCache
-
- All Implemented Interfaces:
PluginInfoInitialized
- Direct Known Subclasses:
ExactSharedStatsCache
,LRUStatsCache
public class ExactStatsCache extends StatsCache
This class implements exact caching of statistics. It requires an additional round-trip to parse query at shard servers, and return term statistics for query terms (and collection statistics for term fields).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ExactStatsCache.ExactStatsSource
-
Field Summary
-
Fields inherited from class org.apache.solr.search.stats.StatsCache
COL_STATS_KEY, TERM_STATS_KEY, TERMS_KEY
-
-
Constructor Summary
Constructors Constructor Description ExactStatsCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addToGlobalColStats(SolrQueryRequest req, Map.Entry<String,CollectionStats> e)
protected void
addToGlobalTermStats(SolrQueryRequest req, Map.Entry<String,TermStats> e)
protected void
addToPerShardColStats(SolrQueryRequest req, String shard, Map<String,CollectionStats> colStats)
protected void
addToPerShardTermStats(SolrQueryRequest req, String shard, String termStatsString)
StatsSource
get(SolrQueryRequest req)
Prepare localStatsSource
to provide stats information to perform local scoring (to be precise, to build a localWeight
from the query).protected Map<String,CollectionStats>
getPerShardColStats(ResponseBuilder rb, String shard)
protected TermStats
getPerShardTermStats(SolrQueryRequest req, String t, String shard)
void
init(PluginInfo info)
void
mergeToGlobalStats(SolrQueryRequest req, List<ShardResponse> responses)
Process shard responses that contain partial local stats.protected void
printStats(SolrQueryRequest req)
void
receiveGlobalStats(SolrQueryRequest req)
Receive global stats data from the master and update a local cache of stats with this global data.ShardRequest
retrieveStatsRequest(ResponseBuilder rb)
Creates aShardRequest
to retrieve per-shard stats related to the current query and the current state of the requester'sStatsCache
.void
returnLocalStats(ResponseBuilder rb, SolrIndexSearcher searcher)
Prepare a local (from the local shard) response to a "retrieve stats" shard request.void
sendGlobalStats(ResponseBuilder rb, ShardRequest outgoing)
Prepare global stats data to be sent out to shards in this request.
-
-
-
Method Detail
-
get
public StatsSource get(SolrQueryRequest req)
Description copied from class:StatsCache
Prepare localStatsSource
to provide stats information to perform local scoring (to be precise, to build a localWeight
from the query).- Specified by:
get
in classStatsCache
- Parameters:
req
- query request- Returns:
- an instance of
StatsSource
to use in creating a queryWeight
-
init
public void init(PluginInfo info)
-
retrieveStatsRequest
public ShardRequest retrieveStatsRequest(ResponseBuilder rb)
Description copied from class:StatsCache
Creates aShardRequest
to retrieve per-shard stats related to the current query and the current state of the requester'sStatsCache
.- Specified by:
retrieveStatsRequest
in classStatsCache
- 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).
-
mergeToGlobalStats
public void mergeToGlobalStats(SolrQueryRequest req, List<ShardResponse> responses)
Description copied from class:StatsCache
Process shard responses that contain partial local stats. Usually this entails combining per-shard stats for each term.- Specified by:
mergeToGlobalStats
in classStatsCache
- Parameters:
req
- query requestresponses
- responses from shards containing local stats for each shard
-
addToPerShardColStats
protected void addToPerShardColStats(SolrQueryRequest req, String shard, Map<String,CollectionStats> colStats)
-
printStats
protected void printStats(SolrQueryRequest req)
-
addToPerShardTermStats
protected void addToPerShardTermStats(SolrQueryRequest req, String shard, String termStatsString)
-
returnLocalStats
public void returnLocalStats(ResponseBuilder rb, SolrIndexSearcher searcher)
Description copied from class:StatsCache
Prepare a local (from the local shard) response to a "retrieve stats" shard request.- Specified by:
returnLocalStats
in classStatsCache
- Parameters:
rb
- response buildersearcher
- current local searcher
-
sendGlobalStats
public void sendGlobalStats(ResponseBuilder rb, ShardRequest outgoing)
Description copied from class:StatsCache
Prepare global stats data to be sent out to shards in this request.- Specified by:
sendGlobalStats
in classStatsCache
- Parameters:
rb
- response builderoutgoing
- shard request to be sent
-
getPerShardColStats
protected Map<String,CollectionStats> getPerShardColStats(ResponseBuilder rb, String shard)
-
getPerShardTermStats
protected TermStats getPerShardTermStats(SolrQueryRequest req, String t, String shard)
-
receiveGlobalStats
public void receiveGlobalStats(SolrQueryRequest req)
Description copied from class:StatsCache
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 aQueryCommand
to be submitted to the localSolrIndexSearcher
.- Specified by:
receiveGlobalStats
in classStatsCache
- Parameters:
req
- query request with global stats data
-
addToGlobalColStats
protected void addToGlobalColStats(SolrQueryRequest req, Map.Entry<String,CollectionStats> e)
-
addToGlobalTermStats
protected void addToGlobalTermStats(SolrQueryRequest req, Map.Entry<String,TermStats> e)
-
-