コード例 #1
0
  /**
   * Computes the importance of this rule match.
   *
   * @return importance of this rule match
   */
  double computeImportance() {
    assert rels[0] != null;
    RelSubset subset = volcanoPlanner.getSubset(rels[0]);
    double importance = 0;
    if (subset != null) {
      importance = volcanoPlanner.ruleQueue.getImportance(subset);
    }
    final RelSubset targetSubset = guessSubset();
    if ((targetSubset != null) && (targetSubset != subset)) {
      // If this rule will generate a member of an equivalence class
      // which is more important, use that importance.
      final double targetImportance = volcanoPlanner.ruleQueue.getImportance(targetSubset);
      if (targetImportance > importance) {
        importance = targetImportance;

        // If the equivalence class is cheaper than the target, bump up
        // the importance of the rule. A converter is an easy way to
        // make the plan cheaper, so we'd hate to miss this opportunity.
        //
        // REVIEW: jhyde, 2007/12/21: This rule seems to make sense, but
        // is disabled until it has been proven.
        //
        // CHECKSTYLE: IGNORE 3
        if ((subset != null) && subset.bestCost.isLt(targetSubset.bestCost) && false) {
          importance *= targetSubset.bestCost.divideBy(subset.bestCost);
          importance = Math.min(importance, 0.99);
        }
      }
    }

    return importance;
  }
コード例 #2
0
  /**
   * Creates a <code>VolcanoRuleMatch</code>.
   *
   * @param operand0 Primary operand
   * @param rels List of targets; copied by the constructor, so the client can modify it later
   * @pre rels[i] != null
   */
  VolcanoRuleMatch(VolcanoPlanner volcanoPlanner, RelOptRuleOperand operand0, RelNode[] rels) {
    super(volcanoPlanner, operand0, rels.clone());
    this.volcanoPlanner = volcanoPlanner;
    for (int i = 0; i < rels.length; i++) {
      assert rels[i] != null;
    }

    // Try to deduce which subset the result will belong to. Assume --
    // for now -- that the set is the same as the root relexp.
    targetSet = volcanoPlanner.getSet(rels[0]);
    assert targetSet != null : rels[0].toString() + " isn't in a set";
    digest = computeDigest();
  }