Package org.eigenbase.relopt.hep

Examples of org.eigenbase.relopt.hep.HepPlanner


  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);
    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;
  }
View Full Code Here


        .addRuleInstance(PushFilterPastJoinRule.DUMB_FILTER_ON_JOIN)
        .addRuleInstance(PushFilterPastJoinRule.JOIN)
        .addRuleInstance(PushFilterPastProjectRule.INSTANCE)
        .addRuleInstance(PushFilterPastSetOpRule.INSTANCE)
        .build();
    HepPlanner planner = new HepPlanner(program);

    RelNode relInitial = tester.convertSqlToRel(sql);

    assertTrue(relInitial != null);

    List<RelMetadataProvider> list = Lists.newArrayList();
    DefaultRelMetadataProvider defaultProvider =
        new DefaultRelMetadataProvider();
    list.add(defaultProvider);
    planner.registerMetadataProviders(list);
    RelMetadataProvider plannerChain = ChainedRelMetadataProvider.of(list);
    relInitial.getCluster().setMetadataProvider(
        new CachingRelMetadataProvider(plannerChain, planner));

    planner.setRoot(relInitial);
    RelNode relAfter = planner.findBestExp();

    String planBefore = NL + RelOptUtil.toString(relAfter);
    diffRepos.assertEquals("planBefore", "${planBefore}", planBefore);

    HepProgram program2 = new HepProgramBuilder()
        .addMatchOrder(HepMatchOrder.BOTTOM_UP)
        .addRuleInstance(PushFilterPastJoinRule.DUMB_FILTER_ON_JOIN)
        .addRuleInstance(PushFilterPastJoinRule.JOIN)
        .addRuleInstance(PushFilterPastProjectRule.INSTANCE)
        .addRuleInstance(PushFilterPastSetOpRule.INSTANCE)
        .addRuleInstance(TransitivePredicatesOnJoinRule.INSTANCE)
        .build();
    HepPlanner planner2 = new HepPlanner(program2);
    planner.registerMetadataProviders(list);
    planner2.setRoot(relAfter);
    relAfter = planner2.findBestExp();

    String planAfter = NL + RelOptUtil.toString(relAfter);
    diffRepos.assertEquals("planAfter", "${planAfter}", planAfter);
  }
View Full Code Here

    final HepProgram program =
        HepProgram.builder()
            .addRuleInstance(PushFilterPastJoinRule.FILTER_ON_JOIN)
            .build();
    checkPlanning(tester.withDecorrelation(true).withTrim(true), preProgram,
        new HepPlanner(program),
        "select * from dept where exists (\n"
        + "  select * from emp\n"
        + "  where emp.deptno = dept.deptno\n"
        + "  and emp.sal > 100)");
  }
View Full Code Here

    final HepProgram program =
        HepProgram.builder()
            .addRuleInstance(SemiJoinRule.INSTANCE)
            .build();
    checkPlanning(tester.withDecorrelation(true).withTrim(true), preProgram,
        new HepPlanner(program),
        "select * from dept where exists (\n"
            + "  select * from emp\n"
            + "  where emp.deptno = dept.deptno\n"
            + "  and emp.sal > 100)");
  }
View Full Code Here

        .addMatchOrder(HepMatchOrder.BOTTOM_UP)
        .addRuleInstance(RemoveTrivialProjectRule.INSTANCE)
        .addRuleInstance(ConvertMultiJoinRule.INSTANCE)
        .build();
    checkPlanning(tester1, null,
        new HepPlanner(program),
        "select * from "
        + "    (select * from "
        + "        (select * from "
        + "            (select * from A right outer join B on a = b) "
        + "            left outer join "
View Full Code Here

  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;
  }
View Full Code Here

          .addRuleInstance(new ConvertMultiJoinRule(HiveJoinRel.class));
      hepPgmBldr.addRuleInstance(new LoptOptimizeJoinRule(HiveJoinRel.HIVE_JOIN_FACTORY,
          HiveProjectRel.DEFAULT_PROJECT_FACTORY, HiveFilterRel.DEFAULT_FILTER_FACTORY));

      hepPgm = hepPgmBldr.build();
      HepPlanner hepPlanner = new HepPlanner(hepPgm);

      hepPlanner.registerMetadataProviders(list);
      RelMetadataProvider chainedProvider = ChainedRelMetadataProvider.of(list);
      cluster.setMetadataProvider(new CachingRelMetadataProvider(chainedProvider, hepPlanner));

      RelNode rootRel = optiqPreCboPlan;
      hepPlanner.setRoot(rootRel);
      if (!optiqPreCboPlan.getTraitSet().equals(desiredTraits)) {
        rootRel = hepPlanner.changeTraits(optiqPreCboPlan, desiredTraits);
      }
      hepPlanner.setRoot(rootRel);

      optiqOptimizedPlan = hepPlanner.findBestExp();

      if (LOG.isDebugEnabled() && !conf.getBoolVar(ConfVars.HIVE_IN_TEST)) {
        LOG.debug("CBO Planning details:\n");
        LOG.debug("Original Plan:\n" + RelOptUtil.toString(optiqGenPlan));
        LOG.debug("Plan After PPD, PartPruning, ColumnPruning:\n"
View Full Code Here

        // TODO: Should this be also TOP_DOWN?
        for (RelOptRule r : rules)
          programBuilder.addRuleInstance(r);
      }

      HepPlanner planner = new HepPlanner(programBuilder.build());
      List<RelMetadataProvider> list = Lists.newArrayList();
      list.add(mdProvider);
      planner.registerMetadataProviders(list);
      RelMetadataProvider chainedProvider = ChainedRelMetadataProvider.of(list);
      basePlan.getCluster().setMetadataProvider(
          new CachingRelMetadataProvider(chainedProvider, planner));

      planner.setRoot(basePlan);
      optimizedRelNode = planner.findBestExp();

      return optimizedRelNode;
    }
View Full Code Here

        .build();
    this.planner = Frameworks.getPlanner(config);
    HepProgramBuilder builder = new HepProgramBuilder();
    builder.addRuleClass(ReduceExpressionsRule.class);
    builder.addRuleClass(WindowedAggSplitterRule.class);
    this.hepPlanner = new HepPlanner(builder.build());
    hepPlanner.addRule(ReduceExpressionsRule.CALC_INSTANCE);
    hepPlanner.addRule(WindowedAggSplitterRule.PROJECT);
  }
View Full Code Here

TOP

Related Classes of org.eigenbase.relopt.hep.HepPlanner

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.