use of org.apache.calcite.plan.hep.HepProgram in project flink by apache.
the class FlinkRelDecorrelator method decorrelate.
private RelNode decorrelate(RelNode root) {
// first adjust count() expression if any
HepProgram program = HepProgram.builder().addRuleInstance(new AdjustProjectForCountAggregateRule(false)).addRuleInstance(new AdjustProjectForCountAggregateRule(true)).addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(FilterProjectTransposeRule.INSTANCE).addRuleInstance(FilterCorrelateRule.INSTANCE).build();
HepPlanner planner = createPlanner(program);
planner.setRoot(root);
root = planner.findBestExp();
// Perform decorrelation.
map.clear();
final Frame frame = getInvoke(root, null);
if (frame != null) {
// has been rewritten; apply rules post-decorrelation
final HepProgram program2 = HepProgram.builder().addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(FilterJoinRule.JOIN).build();
final HepPlanner planner2 = createPlanner(program2);
final RelNode newRoot = frame.r;
planner2.setRoot(newRoot);
return planner2.findBestExp();
}
return root;
}
use of org.apache.calcite.plan.hep.HepProgram in project hive by apache.
the class HiveRelDecorrelator method decorrelate.
private RelNode decorrelate(RelNode root) {
// first adjust count() expression if any
HepProgram program = HepProgram.builder().addRuleInstance(new AdjustProjectForCountAggregateRule(false)).addRuleInstance(new AdjustProjectForCountAggregateRule(true)).addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(FilterProjectTransposeRule.INSTANCE).build();
HepPlanner planner = createPlanner(program);
planner.setRoot(root);
root = planner.findBestExp();
// Perform decorrelation.
map.clear();
final Frame frame = getInvoke(root, null);
if (frame != null) {
// has been rewritten; apply rules post-decorrelation
final HepProgram program2 = HepProgram.builder().addRuleInstance(FilterJoinRule.FILTER_ON_JOIN).addRuleInstance(FilterJoinRule.JOIN).build();
final HepPlanner planner2 = createPlanner(program2);
final RelNode newRoot = frame.r;
planner2.setRoot(newRoot);
return planner2.findBestExp();
}
assert (valueGen.isEmpty());
return root;
}
use of org.apache.calcite.plan.hep.HepProgram in project hive by apache.
the class HiveRelDecorrelator method removeCorrelationViaRule.
public RelNode removeCorrelationViaRule(RelNode root) {
HepProgram program = HepProgram.builder().addRuleInstance(new RemoveSingleAggregateRule()).addRuleInstance(new RemoveCorrelationForScalarProjectRule()).addRuleInstance(new RemoveCorrelationForScalarAggregateRule()).build();
HepPlanner planner = createPlanner(program);
planner.setRoot(root);
return planner.findBestExp();
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelDecorrelator method removeCorrelationViaRule.
public RelNode removeCorrelationViaRule(RelNode root) {
final RelBuilderFactory f = relBuilderFactory();
HepProgram program = HepProgram.builder().addRuleInstance(new RemoveSingleAggregateRule(f)).addRuleInstance(new RemoveCorrelationForScalarProjectRule(f)).addRuleInstance(new RemoveCorrelationForScalarAggregateRule(f)).build();
HepPlanner planner = createPlanner(program);
planner.setRoot(root);
return planner.findBestExp();
}
use of org.apache.calcite.plan.hep.HepProgram in project calcite by apache.
the class RelDecorrelator method decorrelate.
private RelNode decorrelate(RelNode root) {
// first adjust count() expression if any
final RelBuilderFactory f = relBuilderFactory();
HepProgram program = HepProgram.builder().addRuleInstance(new AdjustProjectForCountAggregateRule(false, f)).addRuleInstance(new AdjustProjectForCountAggregateRule(true, f)).addRuleInstance(new FilterJoinRule.FilterIntoJoinRule(true, f, FilterJoinRule.TRUE_PREDICATE)).addRuleInstance(new FilterProjectTransposeRule(Filter.class, Project.class, true, true, f)).addRuleInstance(new FilterCorrelateRule(f)).build();
HepPlanner planner = createPlanner(program);
planner.setRoot(root);
root = planner.findBestExp();
// Perform decorrelation.
map.clear();
final Frame frame = getInvoke(root, null);
if (frame != null) {
// has been rewritten; apply rules post-decorrelation
final HepProgram program2 = HepProgram.builder().addRuleInstance(new FilterJoinRule.FilterIntoJoinRule(true, f, FilterJoinRule.TRUE_PREDICATE)).addRuleInstance(new FilterJoinRule.JoinConditionPushRule(f, FilterJoinRule.TRUE_PREDICATE)).build();
final HepPlanner planner2 = createPlanner(program2);
final RelNode newRoot = frame.r;
planner2.setRoot(newRoot);
return planner2.findBestExp();
}
return root;
}
Aggregations