org.apache.calcite.plan.RelOptListener Java Examples
The following examples show how to use
org.apache.calcite.plan.RelOptListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VolcanoPlannerTest.java From calcite with Apache License 2.0 | 6 votes |
private void checkEvent( List<RelOptListener.RelEvent> eventList, int iEvent, Class expectedEventClass, RelNode expectedRel, Class<? extends RelOptRule> expectedRuleClass) { assertTrue(iEvent < eventList.size()); RelOptListener.RelEvent event = eventList.get(iEvent); assertSame( expectedEventClass, event.getClass()); if (expectedRel != null) { assertSame( expectedRel, event.getRel()); } if (expectedRuleClass != null) { RelOptListener.RuleEvent ruleEvent = (RelOptListener.RuleEvent) event; assertSame( expectedRuleClass, ruleEvent.getRuleCall().getRule().getClass()); } }
Example #2
Source File: RelSet.java From Bats with Apache License 2.0 | 5 votes |
private void postEquivalenceEvent(VolcanoPlanner planner, RelNode rel) { RelOptListener.RelEquivalenceEvent event = new RelOptListener.RelEquivalenceEvent( planner, rel, "equivalence class " + id, false); planner.listener.relEquivalenceFound(event); }
Example #3
Source File: RelSubset.java From Bats with Apache License 2.0 | 5 votes |
/** * Recursively builds a tree consisting of the cheapest plan at each node. */ RelNode buildCheapestPlan(VolcanoPlanner planner) { CheapestPlanReplacer replacer = new CheapestPlanReplacer(planner); final RelNode cheapest = replacer.visit(this, -1, null); if (planner.listener != null) { RelOptListener.RelChosenEvent event = new RelOptListener.RelChosenEvent( planner, null); planner.listener.relChosen(event); } return cheapest; }
Example #4
Source File: VolcanoPlanner.java From Bats with Apache License 2.0 | 5 votes |
public void addListener(RelOptListener newListener) { // TODO jvs 6-Apr-2006: new superclass AbstractRelOptPlanner // now defines a multicast listener; just need to hook it in if (listener != null) { throw Util.needToImplement("multiple VolcanoPlanner listeners"); } listener = newListener; }
Example #5
Source File: RelSet.java From calcite with Apache License 2.0 | 5 votes |
private void postEquivalenceEvent(VolcanoPlanner planner, RelNode rel) { RelOptListener.RelEquivalenceEvent event = new RelOptListener.RelEquivalenceEvent( planner, rel, "equivalence class " + id, false); planner.getListener().relEquivalenceFound(event); }
Example #6
Source File: RelSubset.java From calcite with Apache License 2.0 | 5 votes |
/** * Recursively builds a tree consisting of the cheapest plan at each node. */ RelNode buildCheapestPlan(VolcanoPlanner planner) { CheapestPlanReplacer replacer = new CheapestPlanReplacer(planner); final RelNode cheapest = replacer.visit(this, -1, null); if (planner.getListener() != null) { RelOptListener.RelChosenEvent event = new RelOptListener.RelChosenEvent( planner, null); planner.getListener().relChosen(event); } return cheapest; }
Example #7
Source File: VolcanoPlannerTest.java From calcite with Apache License 2.0 | 4 votes |
/** * Tests whether planner correctly notifies listeners of events. */ @Disabled @Test void testListener() { TestListener listener = new TestListener(); VolcanoPlanner planner = new VolcanoPlanner(); planner.addListener(listener); planner.addRelTraitDef(ConventionTraitDef.INSTANCE); planner.addRule(new PhysLeafRule()); RelOptCluster cluster = newCluster(planner); NoneLeafRel leafRel = new NoneLeafRel( cluster, "a"); RelNode convertedRel = planner.changeTraits( leafRel, cluster.traitSetOf(PHYS_CALLING_CONVENTION)); planner.setRoot(convertedRel); RelNode result = planner.chooseDelegate().findBestExp(); assertTrue(result instanceof PhysLeafRel); List<RelOptListener.RelEvent> eventList = listener.getEventList(); // add node checkEvent( eventList, 0, RelOptListener.RelEquivalenceEvent.class, leafRel, null); // internal subset checkEvent( eventList, 1, RelOptListener.RelEquivalenceEvent.class, null, null); // before rule checkEvent( eventList, 2, RelOptListener.RuleAttemptedEvent.class, leafRel, PhysLeafRule.class); // before rule checkEvent( eventList, 3, RelOptListener.RuleProductionEvent.class, result, PhysLeafRule.class); // result of rule checkEvent( eventList, 4, RelOptListener.RelEquivalenceEvent.class, result, null); // after rule checkEvent( eventList, 5, RelOptListener.RuleProductionEvent.class, result, PhysLeafRule.class); // after rule checkEvent( eventList, 6, RelOptListener.RuleAttemptedEvent.class, leafRel, PhysLeafRule.class); // choose plan checkEvent( eventList, 7, RelOptListener.RelChosenEvent.class, result, null); // finish choosing plan checkEvent( eventList, 8, RelOptListener.RelChosenEvent.class, null, null); }