From c619f845dc6d70ca599ca06e2898f260b6b04fdb Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Mon, 10 Jul 2023 17:12:55 -0700 Subject: [PATCH] AggregatorFactory: Use guessAggregatorHeapFootprint when factorizeWithSize is not implemented. There are two ways of estimating heap footprint of an Aggregator: 1) AggregatorFactory#guessAggregatorHeapFootprint 2) AggregatorFactory#factorizeWithSize + Aggregator#aggregateWithSize When the second path is used, the default implementation of factorizeWithSize is now updated to delegate to guessAggregatorHeapFootprint, making these equivalent. The old logic used getMaxIntermediateSize, which is less accurate. Also fixes a bug where, when using the second path, calling factorizeWithSize on PassthroughAggregatorFactory would fail because getMaxIntermediateSize was not implemented. (There is no buffer aggregator, so there would be no need.) --- .../org/apache/druid/query/aggregation/AggregatorFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorFactory.java index 023cb1654e0a..3e54f449d6c9 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/AggregatorFactory.java @@ -87,7 +87,7 @@ public VectorAggregator factorizeVector(VectorColumnSelectorFactory selectorFact */ public AggregatorAndSize factorizeWithSize(ColumnSelectorFactory metricFactory) { - return new AggregatorAndSize(factorize(metricFactory), getMaxIntermediateSize()); + return new AggregatorAndSize(factorize(metricFactory), guessAggregatorHeapFootprint(0)); } /**