Class DefaultGqlExecutor

java.lang.Object
org.apache.tinkerpop.gremlin.gql.DefaultGqlExecutor
All Implemented Interfaces:
GqlExecutor

public final class DefaultGqlExecutor extends Object implements GqlExecutor
Executes a GqlMatchPlan against any TinkerPop Graph using a DFS backtracking pattern matching algorithm.

Algorithm

  1. Seed iteration — vertices are scanned from the graph (or looked up via Graph.Index when available), filtered by the seed label and seed property predicates. Each matching vertex is bound to the seed variable and used as the starting point for DFS extension.
  2. DFS extensionextend(org.apache.tinkerpop.gremlin.structure.Element[], org.apache.tinkerpop.gremlin.gql.GqlMatchPlan, java.util.Map<java.lang.String, java.lang.Object>, java.util.List<org.apache.tinkerpop.gremlin.gql.ExtensionStep>, java.util.ArrayDeque<org.apache.tinkerpop.gremlin.structure.Element[]>) is called recursively with a shared Element[] binding array. Steps are selected from the remaining list using DAG eligibility (anchor variable already bound), with BFS order as the tiebreaker.
  3. Lazy deliveryexecute(org.apache.tinkerpop.gremlin.gql.GqlMatchPlan) returns an Iterator that advances the DFS one seed vertex at a time.

Index access is provided via Graph.index(). When Graph.Index.countVertexIndex(String, Object) returns a value less than Long.MAX_VALUE for a seed predicate key, an index lookup replaces the full vertex scan. When all counts equal Long.MAX_VALUE (no index), a full scan is used.

  • Constructor Details

    • DefaultGqlExecutor

      public DefaultGqlExecutor(Graph graph)
  • Method Details

    • execute

      public Iterator<Element[]> execute(GqlMatchPlan plan)
      Returns a lazy Iterator of result rows using an empty params map.
      Specified by:
      execute in interface GqlExecutor
      Parameters:
      plan - the compiled execution plan
      Returns:
      a lazy iterator of binding arrays
    • execute

      public Iterator<Element[]> execute(GqlMatchPlan plan, Map<String,Object> params)
      Returns a lazy Iterator of result rows. Each row is an Element[] whose indices correspond to the variable index defined in the GqlMatchPlan.
      Specified by:
      execute in interface GqlExecutor
      Parameters:
      plan - the compiled execution plan
      params - parameter bindings for $name references in property predicates; may be empty if the query contains no parameter references
      Returns:
      a lazy iterator of binding arrays