Interface GqlExecutor

All Known Implementing Classes:
DefaultGqlExecutor

public interface GqlExecutor
Executes a GqlMatchPlan against a graph and returns result rows.

Each result row is an Element[] whose indices correspond to the variable indices defined in the plan; use GqlMatchPlan.getVariables() to map indices back to variable names. The seed variable is always at index 0.

DefaultGqlExecutor is the reference implementation. It iterates seed vertices via a full scan or an index lookup when Graph.Index is available, then performs DFS backtracking over the plan's extension steps using the TinkerPop Graph API (Vertex.edges(), Edge.inVertex(), etc.).

When to implement this interface

This is the primary customization point for providers with a native query or traversal engine. Such a provider can keep DefaultGqlPlanner — getting free GQL MATCH parsing and cardinality-guided join ordering driven by the countVerticesByLabel, countEdgesByLabel, and Graph.Index overrides already on the graph — and replace only the executor to translate the resulting GqlMatchPlan into native operations instead of iterating Graph.vertices().

The contract for implementors:

  • Iterate seed vertex candidates matching the plan's seed label and predicates.
  • For each seed, extend the partial match through the plan's extension steps in an order that keeps every step's anchor variable bound before that step executes.
  • Emit one Element[] per complete match, with each slot filled according to GqlMatchPlan.getVariables(), seed variable at index 0.
  • Return results lazily — do not materialise the full result set in memory.
  • Method Details

    • execute

      Iterator<Element[]> execute(GqlMatchPlan plan)
      Executes the plan with no parameter bindings.
      Parameters:
      plan - the compiled execution plan
      Returns:
      a lazy iterator of binding arrays
    • execute

      Iterator<Element[]> execute(GqlMatchPlan plan, Map<String,Object> params)
      Executes the plan with the given parameter bindings.
      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