use of org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory in project drill by axbaretto.
the class MergeJoinPrel method computeSelfCost.
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
return super.computeSelfCost(planner, mq).multiplyBy(.1);
}
if (joincategory == JoinCategory.CARTESIAN || joincategory == JoinCategory.INEQUALITY) {
return planner.getCostFactory().makeInfiniteCost();
}
double leftRowCount = mq.getRowCount(this.getLeft());
double rightRowCount = mq.getRowCount(this.getRight());
// cost of evaluating each leftkey=rightkey join condition
double joinConditionCost = DrillCostBase.COMPARE_CPU_COST * this.getLeftKeys().size();
double cpuCost = joinConditionCost * (leftRowCount + rightRowCount);
DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();
return costFactory.makeCost(leftRowCount + rightRowCount, cpuCost, 0, 0);
}
use of org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory in project drill by axbaretto.
the class NestedLoopJoinPrel method computeSelfCost.
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) {
if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
return super.computeSelfCost(planner, mq).multiplyBy(.1);
}
double leftRowCount = mq.getRowCount(this.getLeft());
double rightRowCount = mq.getRowCount(this.getRight());
double nljFactor = PrelUtil.getSettings(getCluster()).getNestedLoopJoinFactor();
// cpu cost of evaluating each expression in join condition
int exprNum = RelOptUtil.conjunctions(getCondition()).size() + RelOptUtil.disjunctions(getCondition()).size();
double joinConditionCost = DrillCostBase.COMPARE_CPU_COST * exprNum;
double cpuCost = joinConditionCost * (leftRowCount * rightRowCount) * nljFactor;
DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();
return costFactory.makeCost(leftRowCount * rightRowCount, cpuCost, 0, 0, 0);
}
use of org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory in project drill by axbaretto.
the class OrderedPartitionExchangePrel 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 rowWidth = child.getRowType().getFieldCount() * DrillCostBase.AVG_FIELD_WIDTH;
double rangePartitionCpuCost = DrillCostBase.RANGE_PARTITION_CPU_COST * inputRows;
double svrCpuCost = DrillCostBase.SVR_CPU_COST * inputRows;
double networkCost = DrillCostBase.BYTE_NETWORK_COST * inputRows * rowWidth;
DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();
return costFactory.makeCost(inputRows, rangePartitionCpuCost + svrCpuCost, 0, networkCost);
}
use of org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory in project drill by axbaretto.
the class DrillScanRel method computeSelfCost.
// / TODO: this method is same as the one for ScanPrel...eventually we should consolidate
// / this and few other methods in a common base class which would be extended
// / by both logical and physical rels.
@Override
public RelOptCost computeSelfCost(final RelOptPlanner planner, RelMetadataQuery mq) {
final ScanStats stats = groupScan.getScanStats(settings);
int columnCount = getRowType().getFieldCount();
double ioCost = 0;
boolean isStarQuery = Utilities.isStarQuery(columns);
if (isStarQuery) {
columnCount = STAR_COLUMN_COST;
}
// double rowCount = RelMetadataQuery.getRowCount(this);
double rowCount = stats.getRecordCount();
if (rowCount < 1) {
rowCount = 1;
}
if (PrelUtil.getSettings(getCluster()).useDefaultCosting()) {
return planner.getCostFactory().makeCost(rowCount * columnCount, stats.getCpuCost(), stats.getDiskCost());
}
// for now, assume cpu cost is proportional to row count.
double cpuCost = rowCount * columnCount;
// Even though scan is reading from disk, in the currently generated plans all plans will
// need to read the same amount of data, so keeping the disk io cost 0 is ok for now.
// In the future we might consider alternative scans that go against projections or
// different compression schemes etc that affect the amount of data read. Such alternatives
// would affect both cpu and io cost.
DrillCostFactory costFactory = (DrillCostFactory) planner.getCostFactory();
return costFactory.makeCost(rowCount, cpuCost, ioCost, 0);
}
use of org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory in project drill by axbaretto.
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());
}
Aggregations