コード例 #1
0
ファイル: ValuesRelBase.java プロジェクト: arunwizz/optiq
  // implement RelNode
  public RelOptCost computeSelfCost(RelOptPlanner planner) {
    double dRows = RelMetadataQuery.getRowCount(this);

    // Assume CPU is negligible since values are precomputed.
    double dCpu = 1;
    double dIo = 0;
    return planner.makeCost(dRows, dCpu, dIo);
  }
コード例 #2
0
ファイル: RelOptCluster.java プロジェクト: norrislee/optiq
 public RelTraitSet traitSetOf(RelTrait... traits) {
   RelTraitSet traitSet = emptyTraitSet;
   assert traitSet.size() == planner.getRelTraitDefs().size();
   for (RelTrait trait : traits) {
     traitSet = traitSet.replace(trait);
   }
   return traitSet;
 }
コード例 #3
0
ファイル: SortRel.java プロジェクト: richwhitjr/optiq
 @Override
 public RelOptCost computeSelfCost(RelOptPlanner planner) {
   // Higher cost if rows are wider discourages pushing a project through a
   // sort.
   double rowCount = RelMetadataQuery.getRowCount(this);
   double bytesPerRow = getRowType().getFieldCount() * 4;
   return planner.getCostFactory().makeCost(Util.nLogN(rowCount) * bytesPerRow, rowCount, 0);
 }
  /**
   * 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()));
    }
  }
コード例 #5
0
ファイル: RelOptCluster.java プロジェクト: norrislee/optiq
  /** Creates a cluster. */
  RelOptCluster(
      RelOptQuery query,
      RelOptPlanner planner,
      RelDataTypeFactory typeFactory,
      RexBuilder rexBuilder) {
    assert planner != null;
    assert typeFactory != null;
    this.query = query;
    this.planner = planner;
    this.typeFactory = typeFactory;
    this.rexBuilder = rexBuilder;
    this.originalExpression = rexBuilder.makeLiteral("?");

    // set up a default rel metadata provider,
    // giving the planner first crack at everything
    metadataProvider = new DefaultRelMetadataProvider();
    this.emptyTraitSet = planner.emptyTraitSet();
  }
コード例 #6
0
ファイル: IterCalcRel.java プロジェクト: Jach/luciddb
 public RelOptCost computeSelfCost(RelOptPlanner planner) {
   double dRows = RelMetadataQuery.getRowCount(this);
   double dCpu = RelMetadataQuery.getRowCount(getChild()) * program.getExprCount();
   double dIo = 0;
   return planner.makeCost(dRows, dCpu, dIo);
 }