use of org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory in project drill by apache.
the class SortPrel method computeSelfCost.
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
//We use multiplier 0.05 for TopN operator, and 0.1 for Sort, to make TopN a preferred choice.
return super.computeSelfCost(planner, mq).multiplyBy(.1);
}
RelNode child = this.getInput();
double inputRows = mq.getRowCount(child);
// int rowWidth = child.getRowType().getPrecision();
int numSortFields = this.collation.getFieldCollations().size();
double cpuCost = DrillCostBase.COMPARE_CPU_COST * numSortFields * inputRows * (Math.log(inputRows) / Math.log(2));
// assume in-memory for now until we enforce operator-level memory constraints
double diskIOCost = 0;
// TODO: use rowWidth instead of avgFieldWidth * numFields
// avgFieldWidth * numFields * inputRows
double numFields = this.getRowType().getFieldCount();
long fieldWidth = PrelUtil.getPlannerSettings(planner).getOptions().getOption(ExecConstants.AVERAGE_FIELD_WIDTH_KEY).num_val;
double memCost = fieldWidth * numFields * inputRows;
DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();
return costFactory.makeCost(inputRows, cpuCost, diskIOCost, 0, memCost);
}
use of org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory in project drill by apache.
the class StreamAggPrel method computeSelfCost.
@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);
}
use of org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory in project drill by apache.
the class UnionAllPrel method computeSelfCost.
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
return super.computeSelfCost(planner, mq).multiplyBy(.1);
}
double totalInputRowCount = 0;
for (int i = 0; i < this.getInputs().size(); i++) {
totalInputRowCount += mq.getRowCount(this.getInputs().get(i));
}
double cpuCost = totalInputRowCount * DrillCostBase.BASE_CPU_COST;
DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();
return costFactory.makeCost(totalInputRowCount, cpuCost, 0, 0);
}
use of org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory in project drill by apache.
the class DrillJoinRelBase method computeCartesianJoinCost.
protected RelOptCost computeCartesianJoinCost(RelOptPlanner planner, RelMetadataQuery mq) {
final double probeRowCount = mq.getRowCount(this.getLeft());
final double buildRowCount = mq.getRowCount(this.getRight());
final DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();
// This is a magic number,
final double mulFactor = 10000;
// just to make sure Cartesian Join is more expensive
// than Non-Cartesian Join.
// assume having 1 join key, when estimate join cost.
final int keySize = 1;
final DrillCostBase cost = (DrillCostBase) computeHashJoinCostWithKeySize(planner, keySize, mq).multiplyBy(mulFactor);
// Cartesian join row count will be product of two inputs. The other factors come from the above estimated DrillCost.
return costFactory.makeCost(buildRowCount * probeRowCount, cost.getCpu(), cost.getIo(), cost.getNetwork(), cost.getMemory());
}
use of org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory in project drill by apache.
the class DrillLimitRelBase method computeSelfCost.
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
return super.computeSelfCost(planner, mq).multiplyBy(.1);
}
double numRows = estimateRowCount(mq);
double cpuCost = DrillCostBase.COMPARE_CPU_COST * numRows;
DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();
return costFactory.makeCost(numRows, cpuCost, 0, 0);
}
Aggregations