Class ExtensionStep

java.lang.Object
org.apache.tinkerpop.gremlin.gql.ExtensionStep

public final class ExtensionStep extends Object
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; never null
  • edgeLabel: optional label constraint on the edge; null means any label is accepted
  • direction: traversal direction relative to the anchor vertex
  • edgeVariable: optional variable name to which the matching edge is bound
  • targetLabel: optional label constraint on the target vertex
  • targetVariable: optional variable name to which the target vertex is bound
  • targetPredicates: property equality predicates on the target vertex, derived from the inline filter map on the corresponding QueryVertex
  • estimatedCost: 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 as min(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 quantifier
  • anchoredAtPatternTarget: 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 Details

  • Method Details

    • getAnchorVariable

      public String getAnchorVariable()
      The variable name of the already-bound vertex used as the starting point for this step.
    • getEdgeLabel

      public String getEdgeLabel()
      The edge label constraint, or null for any label.
    • getDirection

      public Direction getDirection()
      The traversal direction from the anchor vertex.
    • getEdgeVariable

      public String getEdgeVariable()
      The variable name to which the matching edge is bound, or null.
    • getEdgePredicates

      public List<PropertyPredicate> getEdgePredicates()
      Property equality predicates that the traversed edge must satisfy. Empty if no filter was specified on the edge pattern element.
    • getTargetLabel

      public String getTargetLabel()
      The label constraint on the target vertex, or null for any label.
    • getTargetVariable

      public String getTargetVariable()
      The variable name to which the matching target vertex is bound, or null.
    • getTargetPredicates

      public List<PropertyPredicate> getTargetPredicates()
      Property equality predicates that the target vertex must satisfy, derived from the inline filter map on the target QueryVertex. 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 as min(edgeLabelCount, indexedPropertyCount) at plan compile time. For a quantified step that value is multiplied by getMaxHops(), saturating at Long.MAX_VALUE, and an unbounded quantified step costs Long.MAX_VALUE.
    • getMinHops

      public int getMinHops()
      Returns the minimum number of hops this step traverses. For a plain, non-quantified single-hop step this is 1.
    • getMaxHops

      public int getMaxHops()
      Returns the maximum number of hops this step traverses, or QueryEdge.UNBOUNDED for the open-ended quantifier forms ({m,} and +). For a plain, non-quantified single-hop step this is 1.
    • isQuantified

      public boolean isQuantified()
      Returns true if 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()
      Returns true if this step's edge variable is a group variable, which binds an ordered List<Edge>. That is the case exactly when the step is quantified and its edge is named.
    • isAnchoredAtPatternTarget

      public boolean isAnchoredAtPatternTarget()
      Returns true if 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 flipped getDirection(): an undirected edge keeps Direction.BOTH when anchored at either end.
    • toString

      public String toString()
      Overrides:
      toString in class Object