コード例 #1
0
ファイル: RelTraitSet.java プロジェクト: norrislee/optiq
 public RelTraitSet plusAll(RelTrait[] traits) {
   RelTraitSet t = this;
   for (RelTrait trait : traits) {
     t = t.plus(trait);
   }
   return t;
 }
  /**
   * Creates new RelNodes replacing/removing the original project/row scan
   *
   * @param projectedScan new scan that is now projected
   * @param origProject original projection
   * @param needRename true if fields from the row scan need to be renamed
   * @param newProject projection that contains the new projection expressions, in the case where
   *     the original projection cannot be removed because it projects expressions
   * @return new RelNode
   */
  public RelNode createNewRelNode(
      RelNode projectedScan, ProjectRel origProject, boolean needRename, ProjectRel newProject) {
    RelNode scanRel;
    if (needRename) {
      // Replace calling convention with FENNEL_EXEC_CONVENTION
      RelTraitSet traits = RelOptUtil.clone(origProject.getTraits());
      traits.setTrait(CallingConventionTraitDef.instance, FennelRel.FENNEL_EXEC_CONVENTION);
      if (!traits.equals(projectedScan.getTraits())) {
        RelNode mergedProjectedScan = convert(projectedScan, traits);
        RelOptPlanner planner = projectedScan.getCluster().getPlanner();
        // register projectedScan == mergedProjectedScan
        // so mergedProjectedScan will have a set later on
        projectedScan = planner.ensureRegistered(mergedProjectedScan, projectedScan);
      }
      scanRel =
          new FennelRenameRel(
              origProject.getCluster(),
              projectedScan,
              RelOptUtil.getFieldNames(origProject.getRowType()),
              traits);
    } else {
      scanRel = projectedScan;
    }

    if (newProject == null) {
      return scanRel;
    } else {
      // in the case where the projection had expressions, put the
      // new, modified projection on top of the projected row scan
      return (ProjectRel)
          CalcRel.createProject(
              scanRel,
              newProject.getProjectExps(),
              RelOptUtil.getFieldNames(newProject.getRowType()));
    }
  }
コード例 #3
0
ファイル: RelTraitSet.java プロジェクト: norrislee/optiq
  /**
   * Compares two RelTraitSet objects to see if they match for the purposes of firing a rule. A null
   * RelTrait within a RelTraitSet indicates a wildcard: any RelTrait in the other RelTraitSet will
   * match. If one RelTraitSet is smaller than the other, comparison stops when the last RelTrait
   * from the smaller set has been examined and the remaining RelTraits in the larger set are
   * assumed to match.
   *
   * @param that another RelTraitSet
   * @return true if the RelTraitSets match, false otherwise
   */
  public boolean matches(RelTraitSet that) {
    final int n = Math.min(this.size(), that.size());

    for (int i = 0; i < n; i++) {
      RelTrait thisTrait = this.traits[i];
      RelTrait thatTrait = that.traits[i];

      if ((thisTrait == null) || (thatTrait == null)) {
        continue;
      }

      if (thisTrait != thatTrait) {
        return false;
      }
    }

    return true;
  }
コード例 #4
0
ファイル: ValuesRel.java プロジェクト: arunwizz/optiq
 public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) {
   assert traitSet.comprises(Convention.NONE);
   assert inputs.isEmpty();
   return new ValuesRel(getCluster(), rowType, tuples);
 }