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 i
| 56 | * updated from the aggregator's cache). |
| 57 | */ |
| 58 | public abstract class StatsCache implements PluginInfoInitialized, SolrInfoBean { |
| 59 | // TODO: decouple use in response from use in request context for these keys |
| 60 | /** Map of terms and {@link TermStats}. */ |
| 61 | public static final String TERM_STATS_KEY = "solr.stats.term"; |
| 62 | |
| 63 | /** Value of {@link CollectionStats}. */ |
| 64 | public static final String COL_STATS_KEY = "solr.stats.col"; |
| 65 | |
| 66 | /** List of terms in the query. */ |
| 67 | public static final String TERMS_KEY = "solr.stats.terms"; |
| 68 | |
| 69 | /** List of fields in the query. */ |
| 70 | public static final String FIELDS_KEY = "solr.stats.fields"; |
| 71 | |
| 72 | private SolrMetricsContext solrMetricsContext; |
| 73 | |
| 74 | public static final class StatsCacheMetrics { |
| 75 | public final LongAdder lookups = new LongAdder(); |
| 76 | public final LongAdder retrieveStats = new LongAdder(); |
| 77 | public final LongAdder receiveGlobalStats = new LongAdder(); |
| 78 | public final LongAdder returnLocalStats = new LongAdder(); |
| 79 | public final LongAdder mergeToGlobalStats = new LongAdder(); |
| 80 | public final LongAdder sendGlobalStats = new LongAdder(); |
| 81 | public final LongAdder useCachedGlobalStats = new LongAdder(); |
| 82 | public final LongAdder missingGlobalTermStats = new LongAdder(); |
| 83 | public final LongAdder missingGlobalFieldStats = new LongAdder(); |
| 84 | |
| 85 | public void clear() { |
| 86 | lookups.reset(); |
| 87 | retrieveStats.reset(); |
| 88 | receiveGlobalStats.reset(); |
| 89 | returnLocalStats.reset(); |
| 90 | mergeToGlobalStats.reset(); |
| 91 | sendGlobalStats.reset(); |
| 92 | useCachedGlobalStats.reset(); |
| 93 | missingGlobalTermStats.reset(); |
| 94 | missingGlobalFieldStats.reset(); |
| 95 | } |
| 96 | |
| 97 | public void getSnapshot(BiConsumer<String, Object> consumer) { |
| 98 | consumer.accept(SolrCache.LOOKUPS_PARAM, lookups.longValue()); |
| 99 | consumer.accept("retrieveStats", retrieveStats.longValue()); |
| 100 | consumer.accept("receiveGlobalStats", receiveGlobalStats.longValue()); |
| 101 | consumer.accept("returnLocalStats", returnLocalStats.longValue()); |
| 102 | consumer.accept("mergeToGlobalStats", mergeToGlobalStats.longValue()); |
| 103 | consumer.accept("sendGlobalStats", sendGlobalStats.longValue()); |
| 104 | consumer.accept("useCachedGlobalStats", useCachedGlobalStats.longValue()); |
| 105 | consumer.accept("missingGlobalTermStats", missingGlobalTermStats.longValue()); |
| 106 | consumer.accept("missingGlobalFieldStats", missingGlobalFieldStats.longValue()); |
| 107 | } |
| 108 | |
| 109 | @Override |
| 110 | public String toString() { |
| 111 | Map<String, Object> map = new HashMap<>(); |
| 112 | getSnapshot(map::put); |
| 113 | return map.toString(); |
| 114 | } |
| 115 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…