Search in sources :

Example 21 with DrillCostFactory

use of org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory in project drill by apache.

the class UnionExchangePrel method computeSelfCost.

/**
   * A UnionExchange processes a total of M rows coming from N senders and
   * combines them into a single output stream.  Note that there is
   * no sort or merge operation going on. For costing purposes, we can
   * assume each sender is sending M/N rows to a single receiver.
   * (See DrillCostBase for symbol notations)
   * C =  CPU cost of SV remover for M/N rows
   *      + Network cost of sending M/N rows to 1 destination.
   * So, C = (s * M/N) + (w * M/N)
   * Total cost = N * C
   */
@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 rowWidth = child.getRowType().getFieldCount() * DrillCostBase.AVG_FIELD_WIDTH;
    double svrCpuCost = DrillCostBase.SVR_CPU_COST * inputRows;
    double networkCost = DrillCostBase.BYTE_NETWORK_COST * inputRows * rowWidth;
    DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();
    return costFactory.makeCost(inputRows, svrCpuCost, 0, networkCost);
}
Also used : DrillCostFactory(org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory) RelNode(org.apache.calcite.rel.RelNode)

Aggregations

DrillCostFactory (org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory)21 RelNode (org.apache.calcite.rel.RelNode)10 ScanStats (org.apache.drill.exec.physical.base.ScanStats)2 Predicate (com.google.common.base.Predicate)1 DrillCostBase (org.apache.drill.exec.planner.cost.DrillCostBase)1