Skip to content

Commit bf0e85a

Browse files
committed
Speed up rounding in auto_date_histogram (elastic#56384)
This wires `auto_date_histogram` into the rounding optimization that I built in elastic#55559. This is should significantly speed up any `auto_date_histogram`s with `time_zone`s on them.
1 parent 2f38aeb commit bf0e85a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.io.IOException;
3838
import java.util.Arrays;
3939
import java.util.Map;
40+
import java.util.function.Function;
4041

4142
public final class AutoDateHistogramAggregatorFactory extends ValuesSourceAggregatorFactory {
4243

@@ -77,9 +78,10 @@ protected Aggregator doCreateInternal(ValuesSource valuesSource,
7778
throw new AggregationExecutionException("Registry miss-match - expected AutoDateHistogramAggregationSupplier, found [" +
7879
aggregatorSupplier.getClass().toString() + "]");
7980
}
81+
Function<Rounding, Rounding.Prepared> roundingPreparer =
82+
valuesSource.roundingPreparer(searchContext.getQueryShardContext().getIndexReader());
8083
return ((AutoDateHistogramAggregatorSupplier) aggregatorSupplier).build(name, factories, numBuckets, roundingInfos,
81-
// TODO once auto date histo is plugged into the ValuesSource refactoring use the date values source
82-
Rounding::prepareForUnknown, valuesSource, config.format(), searchContext, parent, metadata);
84+
roundingPreparer, valuesSource, config.format(), searchContext, parent, metadata);
8385
}
8486

8587
@Override

0 commit comments

Comments
 (0)