gianm commented on a change in pull request #11950:
URL: https://github.com/apache/druid/pull/11950#discussion_r756228094



##########
File path: 
processing/src/main/java/org/apache/druid/segment/incremental/OnheapIncrementalIndex.java
##########
@@ -114,10 +122,13 @@
   private static long getMaxBytesPerRowForAggregators(IncrementalIndexSchema 
incrementalIndexSchema)
   {
     long maxAggregatorIntermediateSize = ((long) Integer.BYTES) * 
incrementalIndexSchema.getMetrics().length;
-    maxAggregatorIntermediateSize += 
Arrays.stream(incrementalIndexSchema.getMetrics())
-                                           .mapToLong(aggregator -> 
aggregator.getMaxIntermediateSizeWithNulls()
-                                                                    + 
Long.BYTES * 2L)
-                                           .sum();
+
+    for (final AggregatorFactory aggregator : 
incrementalIndexSchema.getMetrics()) {
+      final long rows =
+          incrementalIndexSchema.isRollup() ? 
ROLLUP_RATIO_FOR_AGGREGATOR_FOOTPRINT_ESTIMATION : 1;
+      maxAggregatorIntermediateSize += (long) 
aggregator.guessAggregatorHeapFootprint(rows) + 2 * Long.BYTES;

Review comment:
       It's still useful for aggregators that have a small data size, like 
longSum etc. For those, the overheads are bigger than the intermediate data 
size.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to