@Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { // huge cost to ensure OLAPToEnumerableConverter only appears once in rel tree return super.computeSelfCost(planner, mq).multiplyBy(0.05); }
@Override public RelOptCost computeSelfCost(final RelOptPlanner planner, final RelMetadataQuery mq) { return right.computeSelfCost(planner, mq).plus(left.computeSelfCost(planner, mq).multiplyBy(50)); }
public RelOptCost plus(RelOptCost other) { if ((this == INFINITY) || (other.isInfinite())) { return INFINITY; } return new HiveCost(this.rowCount + other.getRows(), this.cpu + other.getCpu(), this.io + other.getIo()); }
/** * 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); }
if (!costFactory.makeZeroCost().isLt(cost)) { cost = cost.multiplyBy(RelOptUtil.EPSILON); if (!costFactory.makeZeroCost().isLt(cost)) { cost = cost.plus(getCost(input, mq)); cost = cost.plus(getCost(input, mq));
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); } }
@Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { RelOptCost relOptCost = super.computeSelfCost(planner, mq).multiplyBy(0.05); return planner.getCostFactory().makeCost(relOptCost.getRows(), 0, 0); }
++tick; ++cumulativeTicks; if (root.bestCost.isLe(targetCost)) { if (firstFiniteTick < 0) { firstFiniteTick = cumulativeTicks; targetCost = root.bestCost.multiplyBy(0.9); ++splitCount; if (impatient) { } else if (root.bestCost.isInfinite() && ((tick % 10) == 0)) { injectImportanceBoost();
public boolean isEqWithEpsilon(RelOptCost other) { return Math.abs(getRows() - other.getRows()) < RelOptUtil.EPSILON; }
public RelOptCost getJoinCost(HiveJoin join) { // Select algorithm with min cost JoinAlgorithm joinAlgorithm = null; RelOptCost minJoinCost = null; if (LOG.isTraceEnabled()) { LOG.trace("Join algorithm selection for:\n" + RelOptUtil.toString(join)); } for (JoinAlgorithm possibleAlgorithm : this.joinAlgorithms) { if (!possibleAlgorithm.isExecutable(join)) { continue; } RelOptCost joinCost = possibleAlgorithm.getCost(join); if (LOG.isTraceEnabled()) { LOG.trace(possibleAlgorithm + " cost: " + joinCost); } if (minJoinCost == null || joinCost.isLt(minJoinCost) ) { joinAlgorithm = possibleAlgorithm; minJoinCost = joinCost; } } if (LOG.isTraceEnabled()) { LOG.trace(joinAlgorithm + " selected"); } join.setJoinAlgorithm(joinAlgorithm); join.setJoinCost(minJoinCost); return minJoinCost; }
Convention previous = null; for (Convention arc : conversionPath) { if (planner.getCost(converted, mq).isInfinite() && !allowInfiniteCostConverters) { continue loop;
/** * Returns the aggregate cost from given {@link org.apache.calcite.plan.RelOptCost} cost. * */ public static double aggregateCost(final org.apache.calcite.plan.RelOptCost cost) { final double aggCost = DremioCost.BASE_CPU_COST * cost.getCpu() + DremioCost.BYTE_DISK_READ_COST * cost.getIo(); if (cost instanceof DremioCost) { final DremioCost dremioCost = (DremioCost) cost; return aggCost + DremioCost.BYTE_NETWORK_COST * dremioCost.getNetwork() + dremioCost.getMemory() * DremioCost.BASE_CPU_COST / DremioCost.MEMORY_TO_CPU_RATIO; } return aggCost; }
public int compare(Integer rel1Idx, Integer rel2Idx) { RelOptCost c1 = mq.getCumulativeCost(chosenSemiJoins[rel1Idx]); RelOptCost c2 = mq.getCumulativeCost(chosenSemiJoins[rel2Idx]); // nulls are arbitrarily sorted if ((c1 == null) || (c2 == null)) { return -1; } return (c1.isLt(c2)) ? -1 : ((c1.equals(c2)) ? 0 : 1); } }
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; }
bestTree = pushDownTree; } else { if (costPushDown.isEqWithEpsilon(costTop)) { bestTree = topTree; } else if (costPushDown.isLt(costTop)) { bestTree = pushDownTree; } else {
public RelOptCost plus(RelOptCost other) { if ((this == INFINITY) || (other.isInfinite())) { return INFINITY; } return new HiveCost(this.rowCount + other.getRows(), this.cpu + other.getCpu(), this.io + other.getIo()); }
/** * 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(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); } }
@Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { RelOptCost relOptCost = super.computeSelfCost(planner, mq).multiplyBy(0.05); return planner.getCostFactory().makeCost(relOptCost.getRows(), 0, 0); }