Class RuleMatchVisualizer
java.lang.Object
org.apache.calcite.plan.visualizer.RuleMatchVisualizer
- All Implemented Interfaces:
EventListener
,RelOptListener
This is a tool to visualize the rule match process of a RelOptPlanner.
// create the visualizer RuleMatchVisualizer viz = new RuleMatchVisualizer("/path/to/output/dir", "file-name-suffix"); viz.attachTo(planner) planner.findBestExpr(); // extra step for HepPlanner: write the output to files // a VolcanoPlanner will call it automatically viz.writeToFile();
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.plan.RelOptListener
RelOptListener.RelChosenEvent, RelOptListener.RelDiscardedEvent, RelOptListener.RelEquivalenceEvent, RelOptListener.RelEvent, RelOptListener.RuleAttemptedEvent, RelOptListener.RuleEvent, RelOptListener.RuleProductionEvent
-
Field Summary
-
Constructor Summary
ConstructorDescriptionUse this constructor when the result shall not be written to disk.RuleMatchVisualizer
(String outputDirectory, String outputSuffix) Use this constructor to save the result on disk at the end of the planning phase. -
Method Summary
Modifier and TypeMethodDescriptionvoid
attachTo
(RelOptPlanner planner) Attaches the visualizer to the planner.void
Notifies this listener that a relational expression has been chosen as part of the final implementation of the query plan.void
Notifies this listener that a relational expression is no longer of interest to the planner.void
Notifies this listener that a relational expression has been registered with a particular equivalence class after an equivalence has been either detected or asserted.void
Notifies this listener that an optimizer rule is being applied to a particular relational expression.void
Notifies this listener that an optimizer rule has been successfully applied to a particular relational expression, resulting in a new equivalent expression (relEquivalenceFound will also be called unless the new expression is identical to an existing one).void
setIncludeIntermediateCosts
(boolean includeIntermediateCosts) Output intermediate costs, including all cost updates.void
setIncludeTransitiveEdges
(boolean includeTransitiveEdges) Output edges from a subset to the nodes of all subsets that satisfy it.void
Writes the HTML and JS files of the rule match visualization.
-
Field Details
-
DEFAULT_SET
- See Also:
-
-
Constructor Details
-
RuleMatchVisualizer
Use this constructor to save the result on disk at the end of the planning phase.Note: when using HepPlanner,
writeToFile()
needs to be called manually. -
RuleMatchVisualizer
public RuleMatchVisualizer()Use this constructor when the result shall not be written to disk.
-
-
Method Details
-
attachTo
Attaches the visualizer to the planner. Must be called before applying the rules. Must be called exactly once. -
setIncludeTransitiveEdges
public void setIncludeTransitiveEdges(boolean includeTransitiveEdges) Output edges from a subset to the nodes of all subsets that satisfy it. -
setIncludeIntermediateCosts
public void setIncludeIntermediateCosts(boolean includeIntermediateCosts) Output intermediate costs, including all cost updates. -
ruleAttempted
Description copied from interface:RelOptListener
Notifies this listener that an optimizer rule is being applied to a particular relational expression. This rule is called twice; once before the rule is invoked, and once after. Note that the rel attribute of the event is always the old expression.- Specified by:
ruleAttempted
in interfaceRelOptListener
- Parameters:
event
- details about the event
-
relChosen
Description copied from interface:RelOptListener
Notifies this listener that a relational expression has been chosen as part of the final implementation of the query plan. After the plan is complete, this is called one more time with null for the rel.- Specified by:
relChosen
in interfaceRelOptListener
- Parameters:
event
- details about the event
-
ruleProductionSucceeded
Description copied from interface:RelOptListener
Notifies this listener that an optimizer rule has been successfully applied to a particular relational expression, resulting in a new equivalent expression (relEquivalenceFound will also be called unless the new expression is identical to an existing one). This rule is called twice; once before registration of the new rel, and once after. Note that the rel attribute of the event is always the new expression; to get the old expression, use event.getRuleCall().rels[0].- Specified by:
ruleProductionSucceeded
in interfaceRelOptListener
- Parameters:
event
- details about the event
-
relDiscarded
Description copied from interface:RelOptListener
Notifies this listener that a relational expression is no longer of interest to the planner.- Specified by:
relDiscarded
in interfaceRelOptListener
- Parameters:
event
- details about the event
-
relEquivalenceFound
Description copied from interface:RelOptListener
Notifies this listener that a relational expression has been registered with a particular equivalence class after an equivalence has been either detected or asserted. Equivalence classes may be either logical (all expressions which yield the same result set) or physical (all expressions which yield the same result set with a particular calling convention).- Specified by:
relEquivalenceFound
in interfaceRelOptListener
- Parameters:
event
- details about the event
-
getJsonStringResult
-
writeToFile
public void writeToFile()Writes the HTML and JS files of the rule match visualization.The old files with the same name will be replaced.
-