fe/src/main/java/com/cloudera/impala/analysis/AggregateInfo.java
/**
   * Create the info for an aggregation node that merges its pre-aggregated inputs:
   * - pre-aggregation is computed by 'this'
   * - tuple desc and smap are the same as that of the input (we're materializing
   *   the same logical tuple)
   * - grouping exprs: slotrefs to the input's grouping slots
   * - aggregate exprs: aggregation of the input's aggregateExprs slots
   *
   * The returned AggregateInfo shares its descriptor and smap with the input info;
   * createAggTupleDesc() must not be called on it.
   */


The returned AggregateInfo shares its descriptor and smap with the input info;
createAggTupleDesc() must not be called on it.
The returned AggregateInfo shares its descriptor and smap with the input info ; createAggTupleDesc () must not be called on it .
private void createMergeAggInfo(Analyzer analyzer) throws
      InternalException, AuthorizationException {
    Preconditions.checkState(mergeAggInfo_ == null);
    TupleDescriptor inputDesc = aggTupleDesc_;
    ArrayList<Expr> groupingExprs = Lists.newArrayList();
    for (int i = 0; i < getGroupingExprs().size(); ++i) {
      groupingExprs.add(new SlotRef(inputDesc.getSlots().get(i)));
    }
    ArrayList<FunctionCallExpr> aggExprs = Lists.newArrayList();
    for (int i = 0; i < getAggregateExprs().size(); ++i) {
      FunctionCallExpr inputExpr = getAggregateExprs().get(i);
      Preconditions.checkState(inputExpr.isAggregateFunction());
      Expr aggExprParam =
          new SlotRef(inputDesc.getSlots().get(i + getGroupingExprs().size()));
      List<Expr> aggExprParamList = Lists.newArrayList(aggExprParam);
      FunctionCallExpr aggExpr = null;
      if (inputExpr.getFnName().getFunction().equals("count")) {
        aggExpr = new FunctionCallExpr("sum", new FunctionParams(aggExprParamList));
      } else {
        aggExpr = new FunctionCallExpr(inputExpr, new FunctionParams(aggExprParamList));
      }
      try {
        aggExpr.analyze(analyzer);
      } catch (AnalysisException e) {
        throw new InternalException(
            "error constructing merge aggregation node: " + e.getMessage());
      }
      aggExprs.add(aggExpr);
    }
    mergeAggInfo_ = new AggregateInfo(groupingExprs, aggExprs, true);
    mergeAggInfo_.aggTupleDesc_ = aggTupleDesc_;
    mergeAggInfo_.aggTupleSMap_ = aggTupleSMap_;
    mergeAggInfo_.mergeAggInfo_ = mergeAggInfo_;
    mergeAggInfo_.materializedAggregateSlots_ = materializedAggregateSlots_;
  }
private void createMergeAggInfo ( Analyzer analyzer ) throws InternalException , AuthorizationException { Preconditions . checkState ( mergeAggInfo_ == null ) ; TupleDescriptor inputDesc = aggTupleDesc_ ; ArrayList < Expr > groupingExprs = Lists . newArrayList ( ) ; for ( int i = 0 ; i < getGroupingExprs ( ) . size ( ) ; ++ i ) { groupingExprs . add ( new SlotRef ( inputDesc . getSlots ( ) . get ( i ) ) ) ; } ArrayList < FunctionCallExpr > aggExprs = Lists . newArrayList ( ) ; for ( int i = 0 ; i < getAggregateExprs ( ) . size ( ) ; ++ i ) { FunctionCallExpr inputExpr = getAggregateExprs ( ) . get ( i ) ; Preconditions . checkState ( inputExpr . isAggregateFunction ( ) ) ; Expr aggExprParam = new SlotRef ( inputDesc . getSlots ( ) . get ( i + getGroupingExprs ( ) . size ( ) ) ) ; List < Expr > aggExprParamList = Lists . newArrayList ( aggExprParam ) ; FunctionCallExpr aggExpr = null ; if ( inputExpr . getFnName ( ) . getFunction ( ) . equals ( "count" ) ) { aggExpr = new FunctionCallExpr ( "sum" , new FunctionParams ( aggExprParamList ) ) ; } else { aggExpr = new FunctionCallExpr ( inputExpr , new FunctionParams ( aggExprParamList ) ) ; } try { aggExpr . analyze ( analyzer ) ; } catch ( AnalysisException e ) { throw new InternalException ( "error constructing merge aggregation node: " + e . getMessage ( ) ) ; } aggExprs . add ( aggExpr ) ; } mergeAggInfo_ = new AggregateInfo ( groupingExprs , aggExprs , true ) ; mergeAggInfo_ . aggTupleDesc_ = aggTupleDesc_ ; mergeAggInfo_ . aggTupleSMap_ = aggTupleSMap_ ; mergeAggInfo_ . mergeAggInfo_ = mergeAggInfo_ ; mergeAggInfo_ . materializedAggregateSlots_ = materializedAggregateSlots_ ; }
Create the info for an aggregation node that merges its pre-aggregated inputs:
 - pre-aggregation is computed by 'this'
 - tuple desc and smap are the same as that of the input (we're materializing
   the same logical tuple)
 - grouping exprs: slotrefs to the input's grouping slots
 - aggregate exprs: aggregation of the input's aggregateExprs slots
Create the info for an aggregation node that merges its pre - aggregated inputs : - pre - aggregation is computed by ' this ' - tuple desc and smap are the same as that of the input ( we ' re materializing the same logical tuple ) - grouping exprs : slotrefs to the input ' s grouping slots - aggregate exprs : aggregation of the input ' s aggregateExprs slots
// construct grouping exprs // construct agg exprs // we shouldn't see this