use of org.apache.drill.exec.planner.cost.DrillCostBase in project drill by apache.
the class MemoryEstimationVisitor method findCost.
@SuppressWarnings("unused")
private double findCost(Prel prel, RelMetadataQuery mq) {
DrillCostBase cost = (DrillCostBase) mq.getNonCumulativeCost(prel);
double memory = cost.getMemory();
for (Prel child : prel) {
memory += findCost(child, mq);
}
return memory;
}
use of org.apache.drill.exec.planner.cost.DrillCostBase 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 in project drill by apache.
the class BroadcastExchangePrel method computeSelfCost.
/**
* In a BroadcastExchange, each sender is sending data to N receivers (for costing
* purposes we assume it is also sending to itself).
*/
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
return super.computeSelfCost(planner, mq).multiplyBy(.1);
}
RelNode child = this.getInput();
final int numEndPoints = PrelUtil.getSettings(getCluster()).numEndPoints();
final double broadcastFactor = PrelUtil.getSettings(getCluster()).getBroadcastFactor();
final double inputRows = mq.getRowCount(child);
final int rowWidth = child.getRowType().getFieldCount() * DrillCostBase.AVG_FIELD_WIDTH;
final double cpuCost = broadcastFactor * DrillCostBase.SVR_CPU_COST * inputRows;
// We assume localhost network cost is 1/10 of regular network cost
// ( c * num_bytes * (N - 1) ) + ( c * num_bytes * 0.1)
// = c * num_bytes * (N - 0.9)
// TODO: a similar adjustment should be made to HashExchangePrel
final double networkCost = broadcastFactor * DrillCostBase.BYTE_NETWORK_COST * inputRows * rowWidth * (numEndPoints - 0.9);
return new DrillCostBase(inputRows, cpuCost, 0, networkCost);
}
use of org.apache.drill.exec.planner.cost.DrillCostBase in project drill by apache.
the class PhysicalPlanCreator method getPrelCostEstimates.
private PrelCostEstimates getPrelCostEstimates(Prel originalPrel, PhysicalOperator op) {
final RelMetadataQuery mq = originalPrel.getCluster().getMetadataQuery();
final double estimatedRowCount = originalPrel.estimateRowCount(mq);
final DrillCostBase costBase = (DrillCostBase) originalPrel.computeSelfCost(originalPrel.getCluster().getPlanner(), mq);
final PrelCostEstimates costEstimates;
if (!op.isBufferedOperator(context)) {
costEstimates = new PrelCostEstimates(context.getOptions().getLong(ExecConstants.OUTPUT_BATCH_SIZE), estimatedRowCount);
} else {
costEstimates = new PrelCostEstimates(costBase.getMemory(), estimatedRowCount);
}
return costEstimates;
}
use of org.apache.drill.exec.planner.cost.DrillCostBase in project drill by axbaretto.
the class BroadcastExchangePrel method computeSelfCost.
/**
* In a BroadcastExchange, each sender is sending data to N receivers (for costing
* purposes we assume it is also sending to itself).
*/
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
return super.computeSelfCost(planner, mq).multiplyBy(.1);
}
RelNode child = this.getInput();
final int numEndPoints = PrelUtil.getSettings(getCluster()).numEndPoints();
final double broadcastFactor = PrelUtil.getSettings(getCluster()).getBroadcastFactor();
final double inputRows = mq.getRowCount(child);
final int rowWidth = child.getRowType().getFieldCount() * DrillCostBase.AVG_FIELD_WIDTH;
final double cpuCost = broadcastFactor * DrillCostBase.SVR_CPU_COST * inputRows;
final double networkCost = broadcastFactor * DrillCostBase.BYTE_NETWORK_COST * inputRows * rowWidth * numEndPoints;
return new DrillCostBase(inputRows, cpuCost, 0, networkCost);
}
Aggregations