当前位置: 首页>>代码示例>>Java>>正文


Java HepProgramBuilder.addRuleInstance方法代码示例

本文整理汇总了Java中org.apache.calcite.plan.hep.HepProgramBuilder.addRuleInstance方法的典型用法代码示例。如果您正苦于以下问题:Java HepProgramBuilder.addRuleInstance方法的具体用法?Java HepProgramBuilder.addRuleInstance怎么用?Java HepProgramBuilder.addRuleInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.plan.hep.HepProgramBuilder的用法示例。


在下文中一共展示了HepProgramBuilder.addRuleInstance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCommonSubExpression

import org.apache.calcite.plan.hep.HepProgramBuilder; //导入方法依赖的package包/类
/** Tests that if two relational expressions are equivalent, the planner
 * notices, and only applies the rule once. */
@Test public void testCommonSubExpression() {
  // In the following,
  //   (select 1 from dept where abs(-1)=20)
  // occurs twice, but it's a common sub-expression, so the rule should only
  // apply once.
  HepProgramBuilder programBuilder = HepProgram.builder();
  programBuilder.addRuleInstance(FilterToCalcRule.INSTANCE);

  final HepTestListener listener = new HepTestListener(0);
  HepPlanner planner = new HepPlanner(programBuilder.build());
  planner.addListener(listener);

  final String sql = "(select 1 from dept where abs(-1)=20)\n"
      + "union all\n"
      + "(select 1 from dept where abs(-1)=20)";
  planner.setRoot(tester.convertSqlToRel(sql).rel);
  RelNode bestRel = planner.findBestExp();

  assertThat(bestRel.getInput(0).equals(bestRel.getInput(1)), is(true));
  assertThat(listener.getApplyTimes() == 1, is(true));
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:HepPlannerTest.java

示例2: testSubprogram

import org.apache.calcite.plan.hep.HepProgramBuilder; //导入方法依赖的package包/类
@Test public void testSubprogram() throws Exception {
  // Verify that subprogram gets re-executed until fixpoint.
  // In this case, the first time through we limit it to generate
  // only one calc; the second time through it will generate
  // a second calc, and then merge them.
  HepProgramBuilder subprogramBuilder = HepProgram.builder();
  subprogramBuilder.addMatchOrder(HepMatchOrder.TOP_DOWN);
  subprogramBuilder.addMatchLimit(1);
  subprogramBuilder.addRuleInstance(ProjectToCalcRule.INSTANCE);
  subprogramBuilder.addRuleInstance(CalcMergeRule.INSTANCE);

  HepProgramBuilder programBuilder = HepProgram.builder();
  programBuilder.addSubprogram(subprogramBuilder.build());

  checkPlanning(
      programBuilder.build(),
      "select upper(ename) from (select lower(ename) as ename from emp)");
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:HepPlannerTest.java

示例3: testGC

import org.apache.calcite.plan.hep.HepProgramBuilder; //导入方法依赖的package包/类
@Test public void testGC() throws Exception {
  HepProgramBuilder programBuilder = HepProgram.builder();
  programBuilder.addMatchOrder(HepMatchOrder.TOP_DOWN);
  programBuilder.addRuleInstance(CalcMergeRule.INSTANCE);
  programBuilder.addRuleInstance(ProjectToCalcRule.INSTANCE);
  programBuilder.addRuleInstance(FilterToCalcRule.INSTANCE);

  HepPlanner planner = new HepPlanner(programBuilder.build());
  planner.setRoot(
      tester.convertSqlToRel("select upper(name) from dept where deptno=20").rel);
  planner.findBestExp();
  // Reuse of HepPlanner (should trigger GC).
  planner.setRoot(
      tester.convertSqlToRel("select upper(name) from dept where deptno=20").rel);
  planner.findBestExp();
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:HepPlannerTest.java

示例4: hep

import org.apache.calcite.plan.hep.HepProgramBuilder; //导入方法依赖的package包/类
/** Creates a program that executes a list of rules in a HEP planner. */
public static Program hep(Iterable<? extends RelOptRule> rules,
                          boolean noDag, RelMetadataProvider metadataProvider) {
  final HepProgramBuilder builder = HepProgram.builder();
  for (RelOptRule rule : rules) {
    builder.addRuleInstance(rule);
  }
  return of(builder.build(), noDag, metadataProvider);
}
 
开发者ID:apache,项目名称:kylin,代码行数:10,代码来源:Programs.java

示例5: hep

import org.apache.calcite.plan.hep.HepProgramBuilder; //导入方法依赖的package包/类
/** Creates a program that executes a list of rules in a HEP planner. */
public static Program hep(Iterable<? extends RelOptRule> rules,
    boolean noDag, RelMetadataProvider metadataProvider) {
  final HepProgramBuilder builder = HepProgram.builder();
  for (RelOptRule rule : rules) {
    builder.addRuleInstance(rule);
  }
  return of(builder.build(), noDag, metadataProvider);
}
 
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:Programs.java

示例6: testMatchLimitOneTopDown

import org.apache.calcite.plan.hep.HepProgramBuilder; //导入方法依赖的package包/类
@Test public void testMatchLimitOneTopDown() throws Exception {
  // Verify that only the top union gets rewritten.

  HepProgramBuilder programBuilder = HepProgram.builder();
  programBuilder.addMatchOrder(HepMatchOrder.TOP_DOWN);
  programBuilder.addMatchLimit(1);
  programBuilder.addRuleInstance(UnionToDistinctRule.INSTANCE);

  checkPlanning(
      programBuilder.build(), UNION_TREE);
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:HepPlannerTest.java

示例7: testMatchLimitOneBottomUp

import org.apache.calcite.plan.hep.HepProgramBuilder; //导入方法依赖的package包/类
@Test public void testMatchLimitOneBottomUp() throws Exception {
  // Verify that only the bottom union gets rewritten.

  HepProgramBuilder programBuilder = HepProgram.builder();
  programBuilder.addMatchLimit(1);
  programBuilder.addMatchOrder(HepMatchOrder.BOTTOM_UP);
  programBuilder.addRuleInstance(UnionToDistinctRule.INSTANCE);

  checkPlanning(
      programBuilder.build(), UNION_TREE);
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:HepPlannerTest.java

示例8: testMatchUntilFixpoint

import org.apache.calcite.plan.hep.HepProgramBuilder; //导入方法依赖的package包/类
@Test public void testMatchUntilFixpoint() throws Exception {
  // Verify that both unions get rewritten.

  HepProgramBuilder programBuilder = HepProgram.builder();
  programBuilder.addMatchLimit(HepProgram.MATCH_UNTIL_FIXPOINT);
  programBuilder.addRuleInstance(UnionToDistinctRule.INSTANCE);

  checkPlanning(
      programBuilder.build(), UNION_TREE);
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:HepPlannerTest.java

示例9: testGroup

import org.apache.calcite.plan.hep.HepProgramBuilder; //导入方法依赖的package包/类
@Test public void testGroup() throws Exception {
  // Verify simultaneous application of a group of rules.
  // Intentionally add them in the wrong order to make sure
  // that order doesn't matter within the group.
  HepProgramBuilder programBuilder = HepProgram.builder();
  programBuilder.addGroupBegin();
  programBuilder.addRuleInstance(CalcMergeRule.INSTANCE);
  programBuilder.addRuleInstance(ProjectToCalcRule.INSTANCE);
  programBuilder.addRuleInstance(FilterToCalcRule.INSTANCE);
  programBuilder.addGroupEnd();

  checkPlanning(
      programBuilder.build(),
      "select upper(name) from dept where deptno=20");
}
 
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:HepPlannerTest.java

示例10: checkRuleApplyCount

import org.apache.calcite.plan.hep.HepProgramBuilder; //导入方法依赖的package包/类
private long checkRuleApplyCount(HepMatchOrder matchOrder) {
  final HepProgramBuilder programBuilder = HepProgram.builder();
  programBuilder.addMatchOrder(matchOrder);
  programBuilder.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE);
  programBuilder.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE);

  final HepTestListener listener = new HepTestListener(0);
  HepPlanner planner = new HepPlanner(programBuilder.build());
  planner.addListener(listener);
  planner.setRoot(tester.convertSqlToRel(COMPLEX_UNION_TREE).rel);
  planner.findBestExp();
  return listener.getApplyTimes();
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:HepPlannerTest.java

示例11: checkPlanning

import org.apache.calcite.plan.hep.HepProgramBuilder; //导入方法依赖的package包/类
/**
 * Checks the plan for a SQL statement before/after executing a given rule.
 *
 * @param rule Planner rule
 * @param sql  SQL query
 */
protected void checkPlanning(
    RelOptRule rule,
    String sql) {
  HepProgramBuilder programBuilder = HepProgram.builder();
  programBuilder.addRuleInstance(rule);

  checkPlanning(
      programBuilder.build(),
      sql);
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:RelOptTestBase.java


注:本文中的org.apache.calcite.plan.hep.HepProgramBuilder.addRuleInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。