@Override public RelOptCost computeSelfCost(final RelOptPlanner planner, final RelMetadataQuery mq) { return right.computeSelfCost(planner, mq).plus(left.computeSelfCost(planner, mq).multiplyBy(50)); }
public RelOptCost getCumulativeCost(HiveJoin rel, RelMetadataQuery mq) { RelOptCost cost = mq.getNonCumulativeCost(rel); List<RelNode> inputs = rel.getInputs(); RelOptCost maxICost = HiveCost.ZERO; for (RelNode input : inputs) { RelOptCost iCost = mq.getCumulativeCost(input); if (maxICost.isLt(iCost)) { maxICost = iCost; } } return cost.plus(maxICost); } }
public RelOptCost getCumulativeCost(HiveJoin rel, RelMetadataQuery mq) { RelOptCost cost = mq.getNonCumulativeCost(rel); List<RelNode> inputs = rel.getInputs(); RelOptCost maxICost = HiveCost.ZERO; for (RelNode input : inputs) { RelOptCost iCost = mq.getCumulativeCost(input); if (maxICost.isLt(iCost)) { maxICost = iCost; } } return cost.plus(maxICost); } }
/** * Since the grouping aggregate will be expanded by {@link org.apache.kylin.query.optrule.AggregateMultipleExpandRule}, * made the cost of grouping aggregate more expensive to use the expanded aggregates */ @Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { RelOptCost cost; if (getGroupType() == Group.SIMPLE) { cost = super.computeSelfCost(planner, mq).multiplyBy(.05); } else { cost = super.computeSelfCost(planner, mq).multiplyBy(.05).plus(planner.getCost(getInput(), mq)) .multiplyBy(groupSets.size() * 1.5); } return cost; }
/** * Since the project under aggregate maybe reduce expressions by {@link org.apache.kylin.query.optrule.AggregateProjectReduceRule}, * consider the count of expressions into cost, the reduced project will be used. * * Made RexOver much more expensive so we can transform into {@link org.apache.kylin.query.relnode.OLAPWindowRel} * by rules in {@link org.apache.calcite.rel.rules.ProjectToWindowRule} */ @Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { boolean hasRexOver = RexOver.containsOver(getProjects(), null); RelOptCost relOptCost = super.computeSelfCost(planner, mq).multiplyBy(.05) .multiplyBy(getProjects().size() * (hasRexOver ? 50 : 1)) .plus(planner.getCostFactory().makeCost(0.1 * caseCount, 0, 0)); return planner.getCostFactory().makeCost(relOptCost.getRows(), 0, 0); }
public RelOptCost getCumulativeCost(RelNode rel, RelMetadataQuery mq) { RelOptCost cost = mq.getNonCumulativeCost(rel); List<RelNode> inputs = rel.getInputs(); for (RelNode input : inputs) { cost = cost.plus(mq.getCumulativeCost(input)); } return cost; }
public RelOptCost getCumulativeCost(RelNode rel, RelMetadataQuery mq) { RelOptCost cost = mq.getNonCumulativeCost(rel); List<RelNode> inputs = rel.getInputs(); for (RelNode input : inputs) { cost = cost.plus(mq.getCumulativeCost(input)); } return cost; }
@Override public RelOptCost computeSelfCost(final RelOptPlanner planner, final RelMetadataQuery mq) { return right.computeSelfCost(planner, mq).plus(left.computeSelfCost(planner, mq).multiplyBy(50)); }
public RelOptCost getCumulativeCost(HiveJoin rel) { RelOptCost cost = RelMetadataQuery.getNonCumulativeCost(rel); List<RelNode> inputs = rel.getInputs(); RelOptCost maxICost = HiveCost.ZERO; for (RelNode input : inputs) { RelOptCost iCost = RelMetadataQuery.getCumulativeCost(input); if (maxICost.isLt(iCost)) { maxICost = iCost; } } return cost.plus(maxICost); } }
/** * Since the grouping aggregate will be expanded by {@link org.apache.kylin.query.optrule.AggregateMultipleExpandRule}, * made the cost of grouping aggregate more expensive to use the expanded aggregates */ @Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { RelOptCost cost; if (getGroupType() == Group.SIMPLE) { cost = super.computeSelfCost(planner, mq).multiplyBy(.05); } else { cost = super.computeSelfCost(planner, mq).multiplyBy(.05).plus(planner.getCost(getInput(), mq)) .multiplyBy(groupSets.size() * 1.5); } return cost; }
@Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { double rowCount = mq.getRowCount(this); final double rightRowCount = right.estimateRowCount(mq); final double leftRowCount = left.estimateRowCount(mq); if (Double.isInfinite(leftRowCount) || Double.isInfinite(rightRowCount)) { return planner.getCostFactory().makeInfiniteCost(); } Double restartCount = mq.getRowCount(getLeft()); // RelMetadataQuery.getCumulativeCost(getRight()); does not work for // RelSubset, so we ask planner to cost-estimate right relation RelOptCost rightCost = planner.getCost(getRight(), mq); RelOptCost rescanCost = rightCost.multiplyBy(Math.max(1.0, restartCount - 1)); return planner.getCostFactory().makeCost( rowCount /* generate results */ + leftRowCount /* scan left results */, 0, 0).plus(rescanCost); } }
@Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { double rowCount = mq.getRowCount(this); final double rightRowCount = right.estimateRowCount(mq); final double leftRowCount = left.estimateRowCount(mq); if (Double.isInfinite(leftRowCount) || Double.isInfinite(rightRowCount)) { return planner.getCostFactory().makeInfiniteCost(); } Double restartCount = mq.getRowCount(getLeft()); // RelMetadataQuery.getCumulativeCost(getRight()); does not work for // RelSubset, so we ask planner to cost-estimate right relation RelOptCost rightCost = planner.getCost(getRight(), mq); RelOptCost rescanCost = rightCost.multiplyBy(Math.max(1.0, restartCount - 1)); return planner.getCostFactory().makeCost( rowCount /* generate results */ + leftRowCount /* scan left results */, 0, 0).plus(rescanCost); } }
/** * Since the project under aggregate maybe reduce expressions by {@link org.apache.kylin.query.optrule.AggregateProjectReduceRule}, * consider the count of expressions into cost, the reduced project will be used. * * Made RexOver much more expensive so we can transform into {@link org.apache.kylin.query.relnode.OLAPWindowRel} * by rules in {@link org.apache.calcite.rel.rules.ProjectToWindowRule} */ @Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { boolean hasRexOver = RexOver.containsOver(getProjects(), null); RelOptCost relOptCost = super.computeSelfCost(planner, mq).multiplyBy(.05) .multiplyBy(getProjects().size() * (hasRexOver ? 50 : 1)) .plus(planner.getCostFactory().makeCost(0.1 * caseCount, 0, 0)); return planner.getCostFactory().makeCost(relOptCost.getRows(), 0, 0); }
public RelOptCost getCost(RelNode rel, RelMetadataQuery mq) { assert rel != null : "pre-condition: rel != null"; if (rel instanceof RelSubset) { return ((RelSubset) rel).bestCost; } if (rel.getTraitSet().getTrait(ConventionTraitDef.INSTANCE) == Convention.NONE) { return costFactory.makeInfiniteCost(); } RelOptCost cost = mq.getNonCumulativeCost(rel); if (!zeroCost.isLt(cost)) { // cost must be positive, so nudge it cost = costFactory.makeTinyCost(); } for (RelNode input : rel.getInputs()) { cost = cost.plus(getCost(input, mq)); } return cost; }
public RelOptCost getCost(RelNode rel, RelMetadataQuery mq) { assert rel != null : "pre-condition: rel != null"; if (rel instanceof RelSubset) { return ((RelSubset) rel).bestCost; } if (rel.getTraitSet().getTrait(ConventionTraitDef.INSTANCE) == Convention.NONE) { return costFactory.makeInfiniteCost(); } RelOptCost cost = mq.getNonCumulativeCost(rel); if (!zeroCost.isLt(cost)) { // cost must be positive, so nudge it cost = costFactory.makeTinyCost(); } for (RelNode input : rel.getInputs()) { cost = cost.plus(getCost(input, mq)); } return cost; }