From bf0e85a0773061a08727bf2a342e8e7e50720337 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Sat, 9 May 2020 08:08:33 -0400 Subject: [PATCH] Speed up rounding in auto_date_histogram (#56384) This wires `auto_date_histogram` into the rounding optimization that I built in #55559. This is should significantly speed up any `auto_date_histogram`s with `time_zone`s on them. --- .../histogram/AutoDateHistogramAggregatorFactory.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorFactory.java index 3d34515f9db29..747df2d3ec9d7 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorFactory.java @@ -37,6 +37,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Map; +import java.util.function.Function; public final class AutoDateHistogramAggregatorFactory extends ValuesSourceAggregatorFactory { @@ -77,9 +78,10 @@ protected Aggregator doCreateInternal(ValuesSource valuesSource, throw new AggregationExecutionException("Registry miss-match - expected AutoDateHistogramAggregationSupplier, found [" + aggregatorSupplier.getClass().toString() + "]"); } + Function roundingPreparer = + valuesSource.roundingPreparer(searchContext.getQueryShardContext().getIndexReader()); return ((AutoDateHistogramAggregatorSupplier) aggregatorSupplier).build(name, factories, numBuckets, roundingInfos, - // TODO once auto date histo is plugged into the ValuesSource refactoring use the date values source - Rounding::prepareForUnknown, valuesSource, config.format(), searchContext, parent, metadata); + roundingPreparer, valuesSource, config.format(), searchContext, parent, metadata); } @Override