processing/src/main/java/org/apache/druid/segment/incremental/OnheapIncrementalIndex.java
/**
   * Creates aggregators for the given aggregator factories.
   *
   * @return Total initial size in bytes required by all the aggregators.
   * This value is non-zero only when {@link #useMaxMemoryEstimates} is false.
   */
Creates aggregators for the given aggregator factories.
@return Total initial size in bytes required by all the aggregators.
This value is non-zero only when  #useMaxMemoryEstimates is false.
Creates aggregators for the given aggregator factories . @return Total initial size in bytes required by all the aggregators . This value is non - zero only when #useMaxMemoryEstimates is false .
private long factorizeAggs(
      AggregatorFactory[] metrics,
      Aggregator[] aggs,
      ThreadLocal<InputRow> rowContainer,
      InputRow row
  )
  {
    long totalInitialSizeBytes = 0L;
    rowContainer.set(row);
    final long aggReferenceSize = Long.BYTES;
    for (int i = 0; i < metrics.length; i++) {
      final AggregatorFactory agg = metrics[i];
      if (useMaxMemoryEstimates) {
        aggs[i] = agg.factorize(selectors.get(agg.getName()));
      } else {
        AggregatorAndSize aggregatorAndSize = agg.factorizeWithSize(selectors.get(agg.getName()));
        aggs[i] = aggregatorAndSize.getAggregator();
        totalInitialSizeBytes += aggregatorAndSize.getInitialSizeBytes();
        totalInitialSizeBytes += aggReferenceSize;
      }
      if (preserveExistingMetrics) {
        if (useMaxMemoryEstimates) {
          AggregatorFactory combiningAgg = agg.getCombiningFactory();
          aggs[i + metrics.length] = combiningAgg.factorize(combiningAggSelectors.get(combiningAgg.getName()));
        } else {
          AggregatorFactory combiningAgg = agg.getCombiningFactory();
          AggregatorAndSize aggregatorAndSize = combiningAgg.factorizeWithSize(combiningAggSelectors.get(combiningAgg.getName()));
          aggs[i + metrics.length] = aggregatorAndSize.getAggregator();
          totalInitialSizeBytes += aggregatorAndSize.getInitialSizeBytes();
          totalInitialSizeBytes += aggReferenceSize;
        }
      }
    }
    rowContainer.set(null);
    return totalInitialSizeBytes;
  }
private long factorizeAggs ( AggregatorFactory [ ] metrics , Aggregator [ ] aggs , ThreadLocal < InputRow > rowContainer , InputRow row ) { long totalInitialSizeBytes = 0L ; rowContainer . set ( row ) ; final long aggReferenceSize = Long . BYTES ; for ( int i = 0 ; i < metrics . length ; i ++ ) { final AggregatorFactory agg = metrics [ i ] ; if ( useMaxMemoryEstimates ) { aggs [ i ] = agg . factorize ( selectors . get ( agg . getName ( ) ) ) ; } else { AggregatorAndSize aggregatorAndSize = agg . factorizeWithSize ( selectors . get ( agg . getName ( ) ) ) ; aggs [ i ] = aggregatorAndSize . getAggregator ( ) ; totalInitialSizeBytes += aggregatorAndSize . getInitialSizeBytes ( ) ; totalInitialSizeBytes += aggReferenceSize ; } if ( preserveExistingMetrics ) { if ( useMaxMemoryEstimates ) { AggregatorFactory combiningAgg = agg . getCombiningFactory ( ) ; aggs [ i + metrics . length ] = combiningAgg . factorize ( combiningAggSelectors . get ( combiningAgg . getName ( ) ) ) ; } else { AggregatorFactory combiningAgg = agg . getCombiningFactory ( ) ; AggregatorAndSize aggregatorAndSize = combiningAgg . factorizeWithSize ( combiningAggSelectors . get ( combiningAgg . getName ( ) ) ) ; aggs [ i + metrics . length ] = aggregatorAndSize . getAggregator ( ) ; totalInitialSizeBytes += aggregatorAndSize . getInitialSizeBytes ( ) ; totalInitialSizeBytes += aggReferenceSize ; } } } rowContainer . set ( null ) ; return totalInitialSizeBytes ; }
Creates aggregators for the given aggregator factories.
Creates aggregators for the given aggregator factories .
// Creates aggregators to aggregate from input into output fields // Creates aggregators to combine already aggregated field