Remove dead code from ShardSearchStats
The clear methodsa are unused and unsafe at this point. This commit
removes the dead code.
@@ -122,27 +122,11 @@ public final class ShardSearchStats implements SearchOperationListener {
});
}
- public void clear() {
- totalStats.clear();
- synchronized (this) {
- if (!groupsStats.isEmpty()) {
- MapBuilder<String, StatsHolder> typesStatsBuilder = MapBuilder.newMapBuilder();
- for (Map.Entry<String, StatsHolder> typeStats : groupsStats.entrySet()) {
- if (typeStats.getValue().totalCurrent() > 0) {
- typeStats.getValue().clear();
- typesStatsBuilder.put(typeStats.getKey(), typeStats.getValue());
- }
- }
- groupsStats = typesStatsBuilder.immutableMap();
- }
- }
- }
-
private void computeStats(SearchContext searchContext, Consumer<StatsHolder> consumer) {
consumer.accept(totalStats);
if (searchContext.groupStats() != null) {
- for (int i = 0; i < searchContext.groupStats().size(); i++) {
- consumer.accept(groupStats(searchContext.groupStats().get(i)));
+ for (String group : searchContext.groupStats()) {
+ consumer.accept(groupStats(group));
}
}
}
@@ -184,8 +168,8 @@ public final class ShardSearchStats implements SearchOperationListener {
}
static final class StatsHolder {
- public final MeanMetric queryMetric = new MeanMetric();
- public final MeanMetric fetchMetric = new MeanMetric();
+ final MeanMetric queryMetric = new MeanMetric();
+ final MeanMetric fetchMetric = new MeanMetric();
/* We store scroll statistics in microseconds because with nanoseconds we run the risk of overflowing the total stats if there are
* many scrolls. For example, on a system with 2^24 scrolls that have been executed, each executing for 2^10 seconds, then using
* nanoseconds would require a numeric representation that can represent at least 2^24 * 2^10 * 10^9 > 2^24 * 2^10 * 2^29 = 2^63
@@ -193,14 +177,14 @@ public final class ShardSearchStats implements SearchOperationListener {
* times as many scrolls (i.e., billions of scrolls which at one per second would take 32 years to occur), or scrolls that execute
* for one-thousand times as long (i.e., scrolls that execute for almost twelve days on average).
*/
- public final MeanMetric scrollMetric = new MeanMetric();
- public final MeanMetric suggestMetric = new MeanMetric();
- public final CounterMetric queryCurrent = new CounterMetric();
- public final CounterMetric fetchCurrent = new CounterMetric();
- public final CounterMetric scrollCurrent = new CounterMetric();
- public final CounterMetric suggestCurrent = new CounterMetric();
-
- public SearchStats.Stats stats() {
+ final MeanMetric scrollMetric = new MeanMetric();
+ final MeanMetric suggestMetric = new MeanMetric();
+ final CounterMetric queryCurrent = new CounterMetric();
+ final CounterMetric fetchCurrent = new CounterMetric();
+ final CounterMetric scrollCurrent = new CounterMetric();
+ final CounterMetric suggestCurrent = new CounterMetric();
+
+ SearchStats.Stats stats() {
return new SearchStats.Stats(
queryMetric.count(), TimeUnit.NANOSECONDS.toMillis(queryMetric.sum()), queryCurrent.count(),
fetchMetric.count(), TimeUnit.NANOSECONDS.toMillis(fetchMetric.sum()), fetchCurrent.count(),
@@ -208,16 +192,5 @@ public final class ShardSearchStats implements SearchOperationListener {
suggestMetric.count(), TimeUnit.NANOSECONDS.toMillis(suggestMetric.sum()), suggestCurrent.count()
);
}
-
- public long totalCurrent() {
- return queryCurrent.count() + fetchCurrent.count() + scrollCurrent.count() + suggestCurrent.count();
- }
-
- public void clear() {
- queryMetric.clear();
- fetchMetric.clear();
- scrollMetric.clear();
- suggestMetric.clear();
- }
}
}
