@Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { return super.computeHashAggCost(planner, mq); }
public AggPrelBase(RelOptCluster cluster, RelTraitSet traits, RelNode child, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls, OperatorPhase phase) throws InvalidRelException { super(cluster, traits, child, indicator, groupSet, groupSets, aggCalls); this.operPhase = phase; createKeysAndExprs(); }
protected void createKeysAndExprs() { final List<String> childFields = getInput().getRowType().getFieldNames(); final List<String> fields = getRowType().getFieldNames(); int aggExprOrdinal = groupSet.cardinality() + aggCall.i; FieldReference ref = FieldReference.getWithQuotedRef(fields.get(aggExprOrdinal)); LogicalExpression expr = toDrill(aggCall.e, childFields); NamedExpression ne = new NamedExpression(expr, ref); aggExprs.add(ne); if (getOperatorPhase() == OperatorPhase.PHASE_1of2) { if (aggCall.e.getAggregation().getName().equals("COUNT")) {
@Override public Iterator<Prel> iterator() { return PrelUtil.iter(getInput()); }
@Override public Prel prepareForLateralUnnestPipeline(List<RelNode> children) { List<Integer> groupingCols = Lists.newArrayList(); groupingCols.add(0); for (int groupingCol : groupSet.asList()) { groupingCols.add(groupingCol + 1); } ImmutableBitSet groupingSet = ImmutableBitSet.of(groupingCols); List<ImmutableBitSet> groupingSets = Lists.newArrayList(); groupingSets.add(groupingSet); List<AggregateCall> aggregateCalls = Lists.newArrayList(); for (AggregateCall aggCall : aggCalls) { List<Integer> arglist = Lists.newArrayList(); for (int arg : aggCall.getArgList()) { arglist.add(arg + 1); } aggregateCalls.add(AggregateCall.create(aggCall.getAggregation(), aggCall.isDistinct(), aggCall.isApproximate(), arglist, aggCall.filterArg, aggCall.type, aggCall.name)); } return (Prel) copy(traitSet, children.get(0),indicator,groupingSet,groupingSets, aggregateCalls); } }
@Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) { return super.computeSelfCost(planner, mq).multiplyBy(.1); } RelNode child = this.getInput(); double inputRows = mq.getRowCount(child); int numGroupByFields = this.getGroupCount(); int numAggrFields = this.aggCalls.size(); double cpuCost = DrillCostBase.COMPARE_CPU_COST * numGroupByFields * inputRows; // add cpu cost for computing the aggregate functions cpuCost += DrillCostBase.FUNC_CPU_COST * numAggrFields * inputRows; DrillCostFactory costFactory = (DrillCostFactory)planner.getCostFactory(); return costFactory.makeCost(inputRows, cpuCost, 0 /* disk i/o cost */, 0 /* network cost */); }