Package org.apache.tinkerpop.gremlin.gql
Class ExtensionStep
java.lang.Object
org.apache.tinkerpop.gremlin.gql.ExtensionStep
A single join step in a compiled
GqlMatchPlan. An ExtensionStep describes
how to extend a partial match by traversing one edge from an already-bound vertex
(the anchor) to a new candidate vertex.
The planner emits one ExtensionStep per QueryEdge in the
QueryGraph, ordered so that the anchor variable is always bound before the
step is executed.
Fields:
anchorVariable: the variable name of the already-bound vertex from which traversal begins; nevernulledgeLabel: optional label constraint on the edge;nullmeans any label is accepteddirection: traversal direction relative to the anchor vertexedgeVariable: optional variable name to which the matching edge is boundtargetLabel: optional label constraint on the target vertextargetVariable: optional variable name to which the target vertex is boundtargetPredicates: property equality predicates on the target vertex, derived from the inline filter map on the correspondingQueryVertexestimatedCost: static selectivity estimate set by the planner; lower values indicate a more selective step that should be tried first when multiple steps are simultaneously eligible. Computed asmin(edgeLabelCount, indexedPropertyCount), scaled by the maximum number of hops for a quantified step.minHops,maxHops,quantified: the hop bounds and whether the pattern edge carried a quantifieranchoredAtPatternTarget: whether the anchor is the pattern edge's right-hand (target) node, so the step walks the pattern edge from right to left
At runtime, the executor maintains adaptive counters (recordAttempt() /
recordHit()) so that selectivityRatio() reflects observed throughput.
The executor uses this ratio, with estimatedCost and then plain-before-quantified as
tiebreakers, to choose among simultaneously eligible steps.
-
Constructor Summary
ConstructorsConstructorDescriptionExtensionStep(String anchorVariable, String edgeLabel, Direction direction, String edgeVariable, List<PropertyPredicate> edgePredicates, String targetLabel, String targetVariable, List<PropertyPredicate> targetPredicates, long estimatedCost, int minHops, int maxHops, boolean quantified, boolean anchoredAtPatternTarget) -
Method Summary
Modifier and TypeMethodDescriptionThe variable name of the already-bound vertex used as the starting point for this step.The traversal direction from the anchor vertex.The edge label constraint, ornullfor any label.Property equality predicates that the traversed edge must satisfy.The variable name to which the matching edge is bound, ornull.longStatic cost estimate set by the planner.intReturns the maximum number of hops this step traverses, orQueryEdge.UNBOUNDEDfor the open-ended quantifier forms ({m,}and+).intReturns the minimum number of hops this step traverses.The label constraint on the target vertex, ornullfor any label.Property equality predicates that the target vertex must satisfy, derived from the inline filter map on the targetQueryVertex.The variable name to which the matching target vertex is bound, ornull.booleanReturnstrueif this step's anchor is the pattern edge's target (right-hand) node, so the step walks the pattern edge from right to left.booleanReturnstrueif this step's edge variable is a group variable, which binds an orderedList<Edge>.booleanReturnstrueif the pattern edge carried a quantifier (e.g.toString()
-
Constructor Details
-
ExtensionStep
public ExtensionStep(String anchorVariable, String edgeLabel, Direction direction, String edgeVariable, List<PropertyPredicate> edgePredicates, String targetLabel, String targetVariable, List<PropertyPredicate> targetPredicates, long estimatedCost, int minHops, int maxHops, boolean quantified, boolean anchoredAtPatternTarget)
-
-
Method Details
-
getAnchorVariable
The variable name of the already-bound vertex used as the starting point for this step. -
getEdgeLabel
The edge label constraint, ornullfor any label. -
getDirection
The traversal direction from the anchor vertex. -
getEdgeVariable
The variable name to which the matching edge is bound, ornull. -
getEdgePredicates
Property equality predicates that the traversed edge must satisfy. Empty if no filter was specified on the edge pattern element. -
getTargetLabel
The label constraint on the target vertex, ornullfor any label. -
getTargetVariable
The variable name to which the matching target vertex is bound, ornull. -
getTargetPredicates
Property equality predicates that the target vertex must satisfy, derived from the inline filter map on the targetQueryVertex. Empty if no filter was specified. -
getEstimatedCost
public long getEstimatedCost()Static cost estimate set by the planner. Lower values indicate a more selective step. Computed asmin(edgeLabelCount, indexedPropertyCount)at plan compile time. For a quantified step that value is multiplied bygetMaxHops(), saturating atLong.MAX_VALUE, and an unbounded quantified step costsLong.MAX_VALUE. -
getMinHops
public int getMinHops()Returns the minimum number of hops this step traverses. For a plain, non-quantified single-hop step this is1. -
getMaxHops
public int getMaxHops()Returns the maximum number of hops this step traverses, orQueryEdge.UNBOUNDEDfor the open-ended quantifier forms ({m,}and+). For a plain, non-quantified single-hop step this is1. -
isQuantified
public boolean isQuantified()Returnstrueif the pattern edge carried a quantifier (e.g.{1,3},{1},+,{2,}), as opposed to a plain edge. This reflects the presence of the quantifier in the query, not the hop bounds, so{1}and{1,1}are quantified. Every quantified step is executed as a walk with per-walk edge uniqueness. -
isEdgeVariableGroup
public boolean isEdgeVariableGroup()Returnstrueif this step's edge variable is a group variable, which binds an orderedList<Edge>. That is the case exactly when the step is quantified and its edge is named. -
isAnchoredAtPatternTarget
public boolean isAnchoredAtPatternTarget()Returnstrueif this step's anchor is the pattern edge's target (right-hand) node, so the step walks the pattern edge from right to left. For a quantified step, the group variable's list is still in pattern order, left to right, so its edges are listed in reverse of the order in which the walk traverses them. This is not the same as a flippedgetDirection(): an undirected edge keepsDirection.BOTHwhen anchored at either end. -
toString
-