/** * Converts a cost to a scalar quantity. */ private double toDouble(RelOptCost cost) { if (cost.isInfinite()) { return 1e+30; } else { return cost.getCpu() + cost.getRows() + cost.getIo(); } }
@Override public RelOptCost computeSelfCost( RelOptPlanner planner ) { final RelOptCost cost = super.computeSelfCost( planner ); if( leftKeys.size() == 0 ) // cartesian product. make artificially expensive. return cost.multiplyBy( 10d ); return cost.multiplyBy( .1 ); }
public int compare(Integer rel1Idx, Integer rel2Idx) { RelOptCost c1 = RelMetadataQuery.getCumulativeCost(chosenSemiJoins[rel1Idx]); RelOptCost c2 = RelMetadataQuery.getCumulativeCost(chosenSemiJoins[rel2Idx]); // nulls are arbitrarily sorted if ((c1 == null) || (c2 == null)) { return -1; } return (c1.isLt(c2)) ? -1 : ((c1.equals(c2)) ? 0 : 1); } }
++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();
Convention previous = null; for (Convention arc : conversionPath) { if (planner.getCost(converted).isInfinite() && !allowInfiniteCostConverters) { continue loop;
public boolean isLt(RelOptCost other) { return getRows() < other.getRows(); }
/** * Checks internal consistency. */ protected void validate() { for (RelSet set : allSets) { if (set.equivalentSet != null) { throw new AssertionError( "set [" + set + "] has been merged: it should not be in the list"); } for (RelSubset subset : set.subsets) { if (subset.set != set) { throw new AssertionError( "subset [" + subset.getDescription() + "] is in wrong set [" + set + "]"); } for (RelNode rel : subset.getRels()) { RelOptCost relCost = getCost(rel); if (relCost.isLt(subset.bestCost)) { throw new AssertionError( "rel [" + rel.getDescription() + "] has lower cost " + relCost + " than best cost " + subset.bestCost + " of subset [" + subset.getDescription() + "]"); } } } } }
public RelOptCost getCost(RelNode rel) { assert rel != null : "pre-condition: rel != null"; if (rel instanceof RelSubset) { return ((RelSubset) rel).bestCost; } if (rel.getTraitSet().getTrait(0) == Convention.NONE) { return costFactory.makeInfiniteCost(); } RelOptCost cost = RelMetadataQuery.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)); } return cost; }
public RelOptCost getCumulativeCost(RelNode rel) { RelOptCost cost = RelMetadataQuery.getNonCumulativeCost(rel); List<RelNode> inputs = rel.getInputs(); for (int i = 0, n = inputs.size(); i < n; i++) { cost = cost.plus(RelMetadataQuery.getCumulativeCost(inputs.get(i))); } return cost; }
bestTree = pushDownTree; } else { if (costPushDown.isEqWithEpsilon(costTop)) { bestTree = topTree; } else if (costPushDown.isLt(costTop)) { bestTree = pushDownTree; } else {
++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();
RelNode converted = rel; for (Graph.Arc arc : arcs) { if (planner.getCost(converted).isInfinite() && !allowInfiniteCostConverters)
public boolean equals(RelOptCost other) { return getRows() == other.getRows(); }
/** * Checks internal consistency. */ protected void validate() { for (RelSet set : allSets) { if (set.equivalentSet != null) { throw new AssertionError( "set [" + set + "] has been merged: it should not be in the list"); } for (RelSubset subset : set.subsets) { if (subset.set != set) { throw new AssertionError( "subset [" + subset.getDescription() + "] is in wrong set [" + set + "]"); } for (RelNode rel : subset.getRels()) { RelOptCost relCost = getCost(rel); if (relCost.isLt(subset.bestCost)) { throw new AssertionError( "rel [" + rel.getDescription() + "] has lower cost " + relCost + " than best cost " + subset.bestCost + " of subset [" + subset.getDescription() + "]"); } } } } }
public RelOptCost getCumulativeCost(RelNode rel) { RelOptCost cost = RelMetadataQuery.getNonCumulativeCost(rel); List<RelNode> inputs = rel.getInputs(); for (RelNode input : inputs) { cost = cost.plus(RelMetadataQuery.getCumulativeCost(input)); } return cost; }
/** * Converts a cost to a scalar quantity. */ private double toDouble(RelOptCost cost) { if (cost.isInfinite()) { return 1e+30; } else { return cost.getCpu() + cost.getRows() + cost.getIo(); } }
@Override public RelOptCost computeSelfCost( RelOptPlanner planner ) { return super.computeSelfCost( planner ).multiplyBy( .1 ); }
public RelNode convert( RelOptPlanner planner, RelNode rel, AltTrait toTrait, boolean allowInfiniteCostConverters) { RelTrait fromTrait = rel.getTraitSet().getTrait(this); if (conversionMap.containsKey(fromTrait)) { for (Pair<RelTrait, ConverterRule> traitAndRule : conversionMap.get(fromTrait)) { RelTrait trait = traitAndRule.left; ConverterRule rule = traitAndRule.right; if (trait == toTrait) { RelNode converted = rule.convert(rel); if ((converted != null) && (!planner.getCost(converted).isInfinite() || allowInfiniteCostConverters)) { return converted; } } } } return null; }
public boolean isEqWithEpsilon(RelOptCost other) { return Math.abs(getRows() - other.getRows()) < RelOptUtil.EPSILON; }
if (cost.isLt(bestCost)) { if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer(