private static void fixDistributedApproxCountDistinct ( AggregatePlanNode distNode , AggregatePlanNode coordNode ) { assert ( distNode != null ) ; assert ( coordNode != null ) ; // Patch up any APPROX_COUNT_DISTINCT on the distributed node. List < ExpressionType > distAggTypes = distNode . getAggregateTypes ( ) ; boolean hasApproxCountDistinct = false ; for ( int i = 0 ; i < distAggTypes . size ( ) ; ++ i ) { ExpressionType et = distAggTypes . get ( i ) ; if ( et == ExpressionType . AGGREGATE_APPROX_COUNT_DISTINCT ) { hasApproxCountDistinct = true ; distNode . updateAggregate ( i , ExpressionType . AGGREGATE_VALS_TO_HYPERLOGLOG ) ; } } if ( hasApproxCountDistinct ) { // Now, patch up any APPROX_COUNT_DISTINCT on the coordinating node. List < ExpressionType > coordAggTypes = coordNode . getAggregateTypes ( ) ; for ( int i = 0 ; i < coordAggTypes . size ( ) ; ++ i ) { ExpressionType et = coordAggTypes . get ( i ) ; if ( et == ExpressionType . AGGREGATE_APPROX_COUNT_DISTINCT ) { coordNode . updateAggregate ( i , ExpressionType . AGGREGATE_HYPERLOGLOGS_TO_CARD ) ; } } } }
This function is called once it s been determined that we can push down an aggregation plan node .