Package net.hydromatic.optiq.tools

Examples of net.hydromatic.optiq.tools.Program


    final RelOptPlanner planner = rootRel.getCluster().getPlanner();

    planner.setRoot(rootRel);

    final RelTraitSet desiredTraits = getDesiredRootTraitSet(rootRel);
    final Program program1 =
        new Program() {
          public RelNode run(RelOptPlanner planner, RelNode rel,
              RelTraitSet requiredOutputTraits) {
            final DataContext dataContext = context.getDataContext();
            planner.setExecutor(new RexExecutorImpl(dataContext));

            for (Materialization materialization : materializations) {
              planner.addMaterialization(
                  new RelOptMaterialization(materialization.tableRel,
                      materialization.queryRel,
                      materialization.starRelOptTable));
            }

            final RelNode rootRel2 =
                planner.changeTraits(rel, requiredOutputTraits);
            assert rootRel2 != null;

            planner.setRoot(rootRel2);
            final RelOptPlanner planner2 = planner.chooseDelegate();
            final RelNode rootRel3 = planner2.findBestExp();
            assert rootRel3 != null : "could not implement exp";
            return rootRel3;
          }
        };

    final RelNode rootRel3 = program1.run(planner, rootRel, desiredTraits);

    // Second planner pass to do physical "tweaks". This the first time that
    // EnumerableCalcRel is introduced.
    final Program program2 =
        Programs.hep(CALC_RULES, true, new DefaultRelMetadataProvider());
    final RelNode rootRel4 = program2.run(null, rootRel3, null);
    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine(
          "Plan after physical tweaks: "
          + RelOptUtil.toString(rootRel4, SqlExplainLevel.ALL_ATTRIBUTES));
    }
View Full Code Here


    final RelOptPlanner planner = rootRel.getCluster().getPlanner();

    planner.setRoot(rootRel);

    final RelTraitSet desiredTraits = getDesiredRootTraitSet(rootRel);
    final Program program = getProgram();

    final DataContext dataContext = context.getDataContext();
    planner.setExecutor(new RexExecutorImpl(dataContext));

    for (Materialization materialization : materializations) {
      planner.addMaterialization(
          new RelOptMaterialization(materialization.tableRel,
              materialization.queryRel,
              materialization.starRelOptTable));
    }

    final RelNode rootRel4 = program.run(planner, rootRel, desiredTraits);
    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine(
          "Plan after physical tweaks: "
          + RelOptUtil.toString(rootRel4, SqlExplainLevel.ALL_ATTRIBUTES));
    }
View Full Code Here

    final RelOptPlanner planner = rootRel.getCluster().getPlanner();

    planner.setRoot(rootRel);

    final RelTraitSet desiredTraits = getDesiredRootTraitSet(rootRel);
    final Program program = getProgram();

    final DataContext dataContext = context.getDataContext();
    planner.setExecutor(new RexExecutorImpl(dataContext));

    for (Materialization materialization : materializations) {
      planner.addMaterialization(
          new RelOptMaterialization(materialization.tableRel,
              materialization.queryRel,
              materialization.starRelOptTable));
    }

    for (OptiqSchema.LatticeEntry lattice : lattices) {
      final OptiqSchema.TableEntry starTable = lattice.getStarTable();
      final JavaTypeFactory typeFactory = context.getTypeFactory();
      final RelOptTableImpl starRelOptTable =
          RelOptTableImpl.create(catalogReader,
              starTable.getTable().getRowType(typeFactory), starTable, null);
      planner.addLattice(
          new RelOptLattice(lattice.getLattice(), starRelOptTable));
    }

    final RelNode rootRel4 = program.run(planner, rootRel, desiredTraits);
    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine(
          "Plan after physical tweaks: "
          + RelOptUtil.toString(rootRel4, SqlExplainLevel.ALL_ATTRIBUTES));
    }
View Full Code Here

          }
        });
    if (rel2 == rel) {
      return rel;
    }
    final Program program = Programs.hep(
        ImmutableList.of(PushProjectPastFilterRule.INSTANCE,
            AggregateProjectMergeRule.INSTANCE,
            AggregateFilterTransposeRule.INSTANCE),
        false,
        new DefaultRelMetadataProvider());
    return program.run(null, rel2, null);
  }
View Full Code Here

   * Converts a relational expression to a form where
   * {@link org.eigenbase.rel.JoinRel}s are
   * as close to leaves as possible.
   */
  public static RelNode toLeafJoinForm(RelNode rel) {
    final Program program = Programs.hep(
        ImmutableList.of(
            PullUpProjectsAboveJoinRule.RIGHT_PROJECT,
            PullUpProjectsAboveJoinRule.LEFT_PROJECT,
            PushFilterPastJoinRule.PushFilterIntoJoinRule.FILTER_ON_JOIN,
            MergeProjectRule.INSTANCE),
        false,
        new DefaultRelMetadataProvider());
    if (OptiqPrepareImpl.DEBUG) {
      System.out.println(
          RelOptUtil.dumpPlan(
              "before", rel, false, SqlExplainLevel.DIGEST_ATTRIBUTES));
    }
    final RelNode rel2 = program.run(null, rel, null);
    if (OptiqPrepareImpl.DEBUG) {
      System.out.println(
          RelOptUtil.dumpPlan(
              "after", rel2, false, SqlExplainLevel.DIGEST_ATTRIBUTES));
    }
View Full Code Here

TOP

Related Classes of net.hydromatic.optiq.tools.Program

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.