public abstract class StatsCache extends Object implements PluginInfoInitialized
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 aggregator's cache).
Modifier and Type | Class and Description |
---|---|
static class |
StatsCache.StatsCacheMetrics |
Modifier and Type | Field and Description |
---|---|
static String |
COL_STATS_KEY
Value of
CollectionStats . |
static String |
FIELDS_KEY
List of fields in the query.
|
protected PluginInfo |
pluginInfo |
protected StatsCache.StatsCacheMetrics |
statsCacheMetrics |
static String |
TERM_STATS_KEY
Map of terms and
TermStats . |
static String |
TERMS_KEY
List of terms in the query.
|
Constructor and Description |
---|
StatsCache() |
Modifier and Type | Method and Description |
---|---|
int |
approxCheckMissingStats(ResponseBuilder rb,
StatsSource statsSource,
Consumer<Term> missingTermStats,
Consumer<String> missingFieldStats)
Check if the
statsSource is missing some term or field statistics info,
which then needs to be retrieved. |
void |
clear()
Clear cached statistics.
|
protected abstract StatsSource |
doGet(SolrQueryRequest req) |
protected abstract void |
doMergeToGlobalStats(SolrQueryRequest req,
List<ShardResponse> responses) |
protected abstract void |
doReceiveGlobalStats(SolrQueryRequest req) |
protected abstract ShardRequest |
doRetrieveStatsRequest(ResponseBuilder rb) |
protected abstract void |
doReturnLocalStats(ResponseBuilder rb,
SolrIndexSearcher searcher) |
protected abstract void |
doSendGlobalStats(ResponseBuilder rb,
ShardRequest outgoing) |
StatsSource |
get(SolrQueryRequest req)
Prepare a
StatsSource that provides stats information to perform
local scoring (to be precise, to build a local Weight from the
query). |
StatsCache.StatsCacheMetrics |
getCacheMetrics() |
void |
init(PluginInfo info) |
void |
mergeToGlobalStats(SolrQueryRequest req,
List<ShardResponse> responses)
Process shard responses that contain partial local stats.
|
void |
receiveGlobalStats(SolrQueryRequest req)
Receive global stats data from the master and update a local cache of global stats
with this global data.
|
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 . |
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.
|
public static final String TERM_STATS_KEY
TermStats
.public static final String COL_STATS_KEY
CollectionStats
.public static final String TERMS_KEY
public static final String FIELDS_KEY
protected StatsCache.StatsCacheMetrics statsCacheMetrics
protected PluginInfo pluginInfo
public StatsCache.StatsCacheMetrics getCacheMetrics()
public void init(PluginInfo info)
init
in interface PluginInfoInitialized
public ShardRequest retrieveStatsRequest(ResponseBuilder rb)
ShardRequest
to retrieve per-shard stats related to the
current query and the current state of the requester's StatsCache
.
This method updates the cache metrics and calls doRetrieveStatsRequest(ResponseBuilder)
.
rb
- contains current requestprotected abstract ShardRequest doRetrieveStatsRequest(ResponseBuilder rb)
public void returnLocalStats(ResponseBuilder rb, SolrIndexSearcher searcher)
This method updates the cache metrics and calls doReturnLocalStats(ResponseBuilder, SolrIndexSearcher)
.
rb
- response buildersearcher
- current local searcherprotected abstract void doReturnLocalStats(ResponseBuilder rb, SolrIndexSearcher searcher)
public void mergeToGlobalStats(SolrQueryRequest req, List<ShardResponse> responses)
This method updates the cache metrics and calls doMergeToGlobalStats(SolrQueryRequest, List)
.
req
- query requestresponses
- responses from shards containing local stats for each shardprotected abstract void doMergeToGlobalStats(SolrQueryRequest req, List<ShardResponse> responses)
public void receiveGlobalStats(SolrQueryRequest req)
QueryCommand
to be submitted to
the local SolrIndexSearcher
.
This method updates the cache metrics and calls doReceiveGlobalStats(SolrQueryRequest)
.
req
- query request with global stats dataprotected abstract void doReceiveGlobalStats(SolrQueryRequest req)
public void sendGlobalStats(ResponseBuilder rb, ShardRequest outgoing)
This method updates the cache metrics and calls doSendGlobalStats(ResponseBuilder, ShardRequest)
.
rb
- response builderoutgoing
- shard request to be sentprotected abstract void doSendGlobalStats(ResponseBuilder rb, ShardRequest outgoing)
public StatsSource get(SolrQueryRequest req)
StatsSource
that provides stats information to perform
local scoring (to be precise, to build a local Weight
from the
query).
This method updates the cache metrics and calls doGet(SolrQueryRequest)
.
req
- query requestStatsSource
to use in creating a query
Weight
protected abstract StatsSource doGet(SolrQueryRequest req)
public void clear()
public int approxCheckMissingStats(ResponseBuilder rb, StatsSource statsSource, Consumer<Term> missingTermStats, Consumer<String> missingFieldStats) throws IOException
statsSource
is missing some term or field statistics info,
which then needs to be retrieved.
NOTE: this uses the local IndexReader for query rewriting, which may expand to less (or different) terms as rewriting the same query on other shards' readers. This in turn may falsely fail to inform the consumers about possibly missing stats, which may lead consumers to skip the fetching of full stats. Consequently this would lead to incorrect global IDF data for the missing terms (because for these terms only local stats would be used).
rb
- request to evaluate against the statsSourcestatsSource
- stats source to checkmissingTermStats
- consumer of missing term statsmissingFieldStats
- consumer of missing field statsIOException
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.