Class PlannerGraphProperty
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.temp.explain.PlannerGraphProperty
-
- All Implemented Interfaces:
PlannerProperty<PlannerGraph>
public class PlannerGraphProperty extends Object implements PlannerProperty<PlannerGraph>
Class to hold a graph for explain, optimization, and rewrite purposes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PlannerGraphProperty.NamedCluster
Class to represent an actual sub cluster of inside the planner graph.
-
Field Summary
Fields Modifier and Type Field Description static int
EMPTY_FLAGS
static int
FOR_EXPLAIN
Indicates if this property is computed for the purpose of creating an explain of the execution plan.static int
REMOVE_LOGICAL_EXPRESSIONS
static int
REMOVE_PLANS
static int
RENDER_SINGLE_GROUPS
Indicates ifExpressionRef
instances that contain exactly one variation are rendered.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static URI
createHtmlLauncher(String dotString)
For debugging only! This method locates a template html launcher file from the resources folder and writes a specific launcher html file into a temp directory.PlannerGraph
evaluateAtExpression(RelationalExpression expression, List<PlannerGraph> childGraphs)
Evaluate the property at the given expression, using the results of evaluating the property at its children.PlannerGraph
evaluateAtRef(ExpressionRef<? extends RelationalExpression> ref, List<PlannerGraph> memberResults)
Evaluate the property at the given reference, using the results of evaluating the property at its members.static String
explain(RelationalExpression relationalExpression)
Generate the explain of the planner expression that is passed in.static String
explain(RelationalExpression relationalExpression, Map<String,Attribute> additionalDescriptionMap)
Generate the explain of the planner expression that is passed in.static String
exportToDot(AbstractPlannerGraph<PlannerGraph.Node,PlannerGraph.Edge> plannerGraph)
Creates a serialized format of this graph as a dot-compatible definition.static String
exportToDot(AbstractPlannerGraph<PlannerGraph.Node,PlannerGraph.Edge> plannerGraph, Set<PlannerGraph.Node> queryPlannerNodes, Function<GraphExporter.ClusterProvider<PlannerGraph.Node,PlannerGraph.Edge>,Collection<GraphExporter.Cluster<PlannerGraph.Node,PlannerGraph.Edge>>> clusteringFunction)
Creates a serialized format of this graph as a dot-compatible definition.static String
exportToGml(PlannerGraph plannerGraph, Map<String,Attribute> additionalInfoMap)
Creates a serialized format of this graph as a gml-compatible definition.static PlannerGraphProperty
forExplain()
static PlannerGraphProperty
forInternalShow(boolean renderSingleGroups)
static PlannerGraphProperty
forInternalShow(boolean renderSingleGroups, boolean removePlans)
boolean
isForExplain()
boolean
removeLogicalExpressions()
boolean
removePlansIfPossible()
boolean
renderSingleGroups()
static String
show(boolean renderSingleGroups, GroupExpressionRef<? extends RelationalExpression> rootReference)
Show the planner expression that is passed in as a graph rendered in your default browser.static String
show(boolean renderSingleGroups, GroupExpressionRef<? extends RelationalExpression> queryPlanRootReference, Set<MatchCandidate> matchCandidates)
Show the planner expression that and all the match candidates rendered in your default browser.static String
show(boolean renderSingleGroups, RelationalExpression relationalExpression)
Show the planner expression that is passed in as a graph rendered in your default browser.static String
show(int flags, GroupExpressionRef<? extends RelationalExpression> rootReference)
Show the planner expression that is passed in as a graph rendered in your default browser.static String
show(int flags, RelationalExpression relationalExpression)
Show the planner expression that is passed in as a graph rendered in your default browser.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.apple.foundationdb.record.query.plan.temp.PlannerProperty
evaluateAtQuantifier, shouldVisit, shouldVisit, shouldVisit
-
-
-
-
Field Detail
-
EMPTY_FLAGS
public static final int EMPTY_FLAGS
- See Also:
- Constant Field Values
-
FOR_EXPLAIN
public static final int FOR_EXPLAIN
Indicates if this property is computed for the purpose of creating an explain of the execution plan.- See Also:
- Constant Field Values
-
RENDER_SINGLE_GROUPS
public static final int RENDER_SINGLE_GROUPS
Indicates ifExpressionRef
instances that contain exactly one variation are rendered.- See Also:
- Constant Field Values
-
REMOVE_PLANS
public static final int REMOVE_PLANS
- See Also:
- Constant Field Values
-
REMOVE_LOGICAL_EXPRESSIONS
public static final int REMOVE_LOGICAL_EXPRESSIONS
- See Also:
- Constant Field Values
-
-
Method Detail
-
show
@Nonnull public static String show(boolean renderSingleGroups, @Nonnull RelationalExpression relationalExpression)
Show the planner expression that is passed in as a graph rendered in your default browser.- Parameters:
renderSingleGroups
- iff true group references with just one member are not renderedrelationalExpression
- the planner expression to be rendered.- Returns:
- the word "done" (IntelliJ really likes a return of String).
-
show
@Nonnull public static String show(boolean renderSingleGroups, @Nonnull GroupExpressionRef<? extends RelationalExpression> rootReference)
Show the planner expression that is passed in as a graph rendered in your default browser.- Parameters:
renderSingleGroups
- iff true group references with just one member are not renderedrootReference
- the planner expression to be rendered.- Returns:
- the word "done" (IntelliJ really likes a return of String).
-
show
@Nonnull public static String show(int flags, @Nonnull RelationalExpression relationalExpression)
Show the planner expression that is passed in as a graph rendered in your default browser.- Parameters:
flags
- iff true group references with just one member are not renderedrelationalExpression
- the planner expression to be rendered.- Returns:
- the word "done" (IntelliJ really likes a return of String).
-
show
@Nonnull public static String show(int flags, @Nonnull GroupExpressionRef<? extends RelationalExpression> rootReference)
Show the planner expression that is passed in as a graph rendered in your default browser.- Parameters:
flags
- rendering optionsrootReference
- the planner expression to be rendered.- Returns:
- the word "done" (IntelliJ really likes a return of String).
-
show
@Nonnull public static String show(boolean renderSingleGroups, @Nonnull GroupExpressionRef<? extends RelationalExpression> queryPlanRootReference, @Nonnull Set<MatchCandidate> matchCandidates)
Show the planner expression that and all the match candidates rendered in your default browser. This also showsPartialMatch
es between references if they exist.- Parameters:
renderSingleGroups
- iff true group references with just one member are not renderedqueryPlanRootReference
- the planner expression to be rendered.matchCandidates
- a set of candidates for matching which should also be shown- Returns:
- the word "done" (IntelliJ really likes a return of String).
-
createHtmlLauncher
@Nonnull public static URI createHtmlLauncher(@Nonnull String dotString) throws Exception
For debugging only! This method locates a template html launcher file from the resources folder and writes a specific launcher html file into a temp directory. If wanted the caller can open the html in a browser of choice.- Parameters:
dotString
- -- a serialized planner graph- Returns:
- a URI pointing to an html file in a temp location which renders the graph
- Throws:
Exception
- -- thrown from methods called in here.
-
exportToDot
@Nonnull public static String exportToDot(@Nonnull AbstractPlannerGraph<PlannerGraph.Node,PlannerGraph.Edge> plannerGraph)
Creates a serialized format of this graph as a dot-compatible definition.- Parameters:
plannerGraph
- the planner graph we should export to dot- Returns:
- the graph as string in dot format.
-
exportToDot
@Nonnull public static String exportToDot(@Nonnull AbstractPlannerGraph<PlannerGraph.Node,PlannerGraph.Edge> plannerGraph, @Nonnull Set<PlannerGraph.Node> queryPlannerNodes, @Nonnull Function<GraphExporter.ClusterProvider<PlannerGraph.Node,PlannerGraph.Edge>,Collection<GraphExporter.Cluster<PlannerGraph.Node,PlannerGraph.Edge>>> clusteringFunction)
Creates a serialized format of this graph as a dot-compatible definition.- Parameters:
plannerGraph
- the planner graph we should export to dotqueryPlannerNodes
- set of nodes which is a subset of nodes ofplannerGraph
which represents the actual query graphclusteringFunction
- function to partition the planner graph into clusters. Clusters are not isolated sub-graphs in this context. It is possible and often desirable for a use case to define edges between nodes of clusters. Clusters are used by the dot exporter to- assign common attributes to all nodes and edges, e.g. like a common gray background
- assign a name that is displayed displayed
- cause the layout algorithm to pack the nodes in a cluster if they were one big node
- Returns:
- the graph as string in dot format.
-
explain
@Nonnull public static String explain(@Nonnull RelationalExpression relationalExpression)
Generate the explain of the planner expression that is passed in.- Parameters:
relationalExpression
- the planner expression to be explained.- Returns:
- the explain of the planner expression handing in as a string in GML format.
-
explain
@Nonnull public static String explain(@Nonnull RelationalExpression relationalExpression, @Nonnull Map<String,Attribute> additionalDescriptionMap)
Generate the explain of the planner expression that is passed in.- Parameters:
relationalExpression
- the planner expression to be explained.additionalDescriptionMap
- a map used to generate names and descriptions for operators.- Returns:
- the explain of the planner expression handing in as a string in GML format.
-
exportToGml
@Nonnull public static String exportToGml(@Nonnull PlannerGraph plannerGraph, @Nonnull Map<String,Attribute> additionalInfoMap)
Creates a serialized format of this graph as a gml-compatible definition.- Parameters:
plannerGraph
- the planner graph to be exportedadditionalInfoMap
- a map used to generate names and descriptions for operators.- Returns:
- the graph as string in gml format.
-
forExplain
public static PlannerGraphProperty forExplain()
-
forInternalShow
public static PlannerGraphProperty forInternalShow(boolean renderSingleGroups)
-
forInternalShow
public static PlannerGraphProperty forInternalShow(boolean renderSingleGroups, boolean removePlans)
-
isForExplain
public boolean isForExplain()
-
renderSingleGroups
public boolean renderSingleGroups()
-
removePlansIfPossible
public boolean removePlansIfPossible()
-
removeLogicalExpressions
public boolean removeLogicalExpressions()
-
evaluateAtExpression
@Nonnull public PlannerGraph evaluateAtExpression(@Nonnull RelationalExpression expression, @Nonnull List<PlannerGraph> childGraphs)
Description copied from interface:PlannerProperty
Evaluate the property at the given expression, using the results of evaluating the property at its children. Called on nodes in the graph in visit post-order of the depth-first traversal of the graph. That is, as each expression is visited (after all of its children have been visited, if applicable),evaluateAtExpression()
is called on that expression.- Specified by:
evaluateAtExpression
in interfacePlannerProperty<PlannerGraph>
- Parameters:
expression
- the cursor to visitchildGraphs
- the results of the property evaluated at the children ofexpression
- Returns:
- the value of property at the given expression
-
evaluateAtRef
@Nonnull public PlannerGraph evaluateAtRef(@Nonnull ExpressionRef<? extends RelationalExpression> ref, @Nonnull List<PlannerGraph> memberResults)
Description copied from interface:PlannerProperty
Evaluate the property at the given reference, using the results of evaluating the property at its members. Called on nodes in the graph in visit post-order of the depth-first traversal of the graph. That is, as each reference is visited (after all of its members have been visited, if applicable),evaluateAtRef()
is called on that reference.- Specified by:
evaluateAtRef
in interfacePlannerProperty<PlannerGraph>
- Parameters:
ref
- the expression reference to visitmemberResults
- the results of the property evaluated at the members ofref
- Returns:
- the value of property at the given reference
-
-