本文整理汇总了Java中org.apache.calcite.plan.hep.HepProgram.builder方法的典型用法代码示例。如果您正苦于以下问题:Java HepProgram.builder方法的具体用法?Java HepProgram.builder怎么用?Java HepProgram.builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.plan.hep.HepProgram
的用法示例。
在下文中一共展示了HepProgram.builder方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRuleClass
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的package包/类
@Test public void testRuleClass() throws Exception {
// Verify that an entire class of rules can be applied.
HepProgramBuilder programBuilder = HepProgram.builder();
programBuilder.addRuleClass(CoerceInputsRule.class);
HepPlanner planner =
new HepPlanner(
programBuilder.build());
planner.addRule(
new CoerceInputsRule(LogicalUnion.class, false,
RelFactories.LOGICAL_BUILDER));
planner.addRule(
new CoerceInputsRule(LogicalIntersect.class, false,
RelFactories.LOGICAL_BUILDER));
checkPlanning(planner,
"(select name from dept union select ename from emp)"
+ " intersect (select fname from customer.contact)");
}
示例2: testRuleDescription
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的package包/类
@Test public void testRuleDescription() throws Exception {
// Verify that a rule can be applied via its description.
HepProgramBuilder programBuilder = HepProgram.builder();
programBuilder.addRuleByDescription("FilterToCalcRule");
HepPlanner planner =
new HepPlanner(
programBuilder.build());
planner.addRule(FilterToCalcRule.INSTANCE);
checkPlanning(
planner,
"select name from sales.dept where deptno=12");
}
示例3: testCommonSubExpression
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的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));
}
示例4: testSubprogram
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的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)");
}
示例5: testGC
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的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();
}
示例6: hep
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的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);
}
示例7: hep
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的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);
}
示例8: testMatchLimitOneTopDown
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的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);
}
示例9: testMatchLimitOneBottomUp
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的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);
}
示例10: testMatchUntilFixpoint
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的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);
}
示例11: testGroup
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的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");
}
示例12: checkRuleApplyCount
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的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();
}
示例13: checkPlanning
import org.apache.calcite.plan.hep.HepProgram; //导入方法依赖的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);
}