Search in sources :

Example 6 with DrillCostBase

use of org.apache.drill.exec.planner.cost.DrillCostBase 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());
}
Also used : DrillCostFactory(org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory) DrillCostBase(org.apache.drill.exec.planner.cost.DrillCostBase)

Example 7 with DrillCostBase

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

the class MemoryEstimationVisitor method findCost.

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;
}
Also used : DrillCostBase(org.apache.drill.exec.planner.cost.DrillCostBase) Prel(org.apache.drill.exec.planner.physical.Prel)

Aggregations

DrillCostBase (org.apache.drill.exec.planner.cost.DrillCostBase)7 RelNode (org.apache.calcite.rel.RelNode)2 DrillCostFactory (org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory)2 Prel (org.apache.drill.exec.planner.physical.Prel)2 RelMetadataQuery (org.apache.calcite.rel.metadata.RelMetadataQuery)1 PrelCostEstimates (org.apache.drill.exec.planner.cost.PrelCostEstimates)1