Esempio n. 1
0
  // 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);
  }
  /**
   * 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()));
    }
  }
Esempio n. 3
0
    public OptiqPreparingStmt(
        CatalogReader catalogReader, RelDataTypeFactory typeFactory, Schema schema) {
      super(catalogReader);
      this.schema = schema;
      planner = new VolcanoPlanner();
      planner.addRelTraitDef(CallingConventionTraitDef.instance);
      RelOptUtil.registerAbstractRels(planner);
      planner.addRule(JavaRules.ENUMERABLE_JOIN_RULE);
      planner.addRule(JavaRules.ENUMERABLE_CALC_RULE);
      planner.addRule(JavaRules.ENUMERABLE_AGGREGATE_RULE);
      planner.addRule(JavaRules.ENUMERABLE_SORT_RULE);
      planner.addRule(JavaRules.ENUMERABLE_UNION_RULE);
      planner.addRule(JavaRules.ENUMERABLE_INTERSECT_RULE);
      planner.addRule(JavaRules.ENUMERABLE_MINUS_RULE);
      planner.addRule(TableAccessRule.instance);

      rexBuilder = new RexBuilder(typeFactory);
    }
Esempio n. 4
0
 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);
 }
 // implement RelNode
 public RelOptCost computeSelfCost(RelOptPlanner planner) {
   return planner.makeTinyCost();
 }