use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class HepPlannerTest method checkRuleApplyCount.
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();
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class HepPlannerTest method testGC.
@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();
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class HepPlannerTest method testMatchLimitOneBottomUp.
@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);
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class HepPlannerTest method testMatchUntilFixpoint.
@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);
}
use of org.apache.calcite.plan.hep.HepProgramBuilder in project calcite by apache.
the class HepPlannerTest method testGroup.
@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");
}
Aggregations