Esempio n. 1
0
 /**
  * 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 HepProgramBuilder programBuilder = new HepProgramBuilder();
   programBuilder.addRuleInstance(PullUpProjectsAboveJoinRule.instanceRightProjectChild);
   programBuilder.addRuleInstance(PullUpProjectsAboveJoinRule.instanceLeftProjectChild);
   final HepPlanner planner = new HepPlanner(programBuilder.createProgram());
   planner.setRoot(rel);
   System.out.println(
       RelOptUtil.dumpPlan("before", rel, false, SqlExplainLevel.DIGEST_ATTRIBUTES));
   final RelNode rel2 = planner.findBestExp();
   System.out.println(
       RelOptUtil.dumpPlan("after", rel2, false, SqlExplainLevel.DIGEST_ATTRIBUTES));
   return rel2;
 }
 /**
  * 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) {
   HepProgram program =
       HepProgram.builder()
           .addRuleInstance(PullUpProjectsAboveJoinRule.RIGHT_PROJECT)
           .addRuleInstance(PullUpProjectsAboveJoinRule.LEFT_PROJECT)
           .build();
   final HepPlanner planner =
       new HepPlanner(
           program, //
           rel.getCluster().getPlanner().getContext());
   planner.setRoot(rel);
   System.out.println(
       RelOptUtil.dumpPlan("before", rel, false, SqlExplainLevel.DIGEST_ATTRIBUTES));
   final RelNode rel2 = planner.findBestExp();
   System.out.println(
       RelOptUtil.dumpPlan("after", rel2, false, SqlExplainLevel.DIGEST_ATTRIBUTES));
   return rel2;
 }