Class GqlDeclarativeMatchStrategy
- All Implemented Interfaces:
Serializable,Comparable<Class<? extends TraversalStrategy>>,TraversalStrategy<TraversalStrategy.ProviderOptimizationStrategy>,TraversalStrategy.ProviderOptimizationStrategy
TraversalStrategy.ProviderOptimizationStrategy that replaces every
DeclarativeMatchStep in a traversal with a concrete GqlMatchStep backed
by a DefaultGqlPlanner and DefaultGqlExecutor.
Singleton usage (recommended)
The no-arg instance() singleton maintains a static
ConcurrentHashMap keyed by graph identity. The first traversal executed against
a given Graph instance allocates one DefaultGqlPlanner and one
DefaultGqlExecutor for that graph; all subsequent traversals reuse them, so the
planner's parse cache is shared across all traversals on the same graph.
Graph providers should register the singleton in their global strategy cache:
TraversalStrategies.GlobalCache.registerStrategies(
AcmeGraph.class,
TraversalStrategies.GlobalCache.getStrategies(Graph.class).clone()
.addStrategies(GqlDeclarativeMatchStrategy.instance()));
When the graph is closed call evict(Graph) to release the cached pair:
@Override
public void close() {
GqlDeclarativeMatchStrategy.evict(this);
// ... other cleanup
}
Custom planner / executor
Providers that supply their own GqlPlanner or GqlExecutor implementations
can use create(GqlPlanner, GqlExecutor) to construct a per-instance strategy. That
strategy instance holds the supplied objects directly and does not interact with the shared
cache.
OLAP / GraphComputer limitation
match(String) is not supported in OLAP (GraphComputer) mode.
The strategy's apply(org.apache.tinkerpop.gremlin.process.traversal.Traversal.Admin<?, ?>) method detects a graph-computer traversal context via
TraversalHelper.onGraphComputer(org.apache.tinkerpop.gremlin.process.traversal.Traversal.Admin<?, ?>)
and returns immediately without replacing the placeholder step. Attempting to execute
match(String) in OLAP mode will therefore result in an
UnsupportedOperationException at traversal execution time.
The limitation exists because TinkerGQL execution relies on direct, lazy vertex and edge
iteration against an OLTP graph (seed scans, DFS backtracking), which has no equivalent in
the scatter-gather message-passing model of OLAP. Providers seeking to support declarative
pattern matching in OLAP would need to implement it as a
VertexProgram.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy
TraversalStrategy.DecorationStrategy, TraversalStrategy.FinalizationStrategy, TraversalStrategy.OptimizationStrategy, TraversalStrategy.ProviderOptimizationStrategy, TraversalStrategy.VerificationStrategy -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(Traversal.Admin<?, ?> traversal) The transformation the strategy applies to the traversal.static GqlDeclarativeMatchStrategycreate(GqlPlanner planner, GqlExecutor executor) Creates a per-instance strategy with explicit planner and executor objects.static voidRemoves the cachedGqlPlanner/GqlExecutorpair for the given graph instance.static GqlDeclarativeMatchStrategyinstance()Returns the singleton strategy that usesDefaultGqlPlannerandDefaultGqlExecutorcached per graph instance.Methods inherited from class org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy
equals, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy
applyPost, applyPrior, getConfigurationMethods inherited from interface org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy.ProviderOptimizationStrategy
compareTo, getTraversalCategory
-
Method Details
-
instance
Returns the singleton strategy that usesDefaultGqlPlannerandDefaultGqlExecutorcached per graph instance. This is the recommended way for providers to register TinkerGQL support. -
create
Creates a per-instance strategy with explicit planner and executor objects. Use this when you want to supply custom implementations; the strategy holdsplannerandexecutordirectly and does not interact with the shared cache.- Parameters:
planner- the planner to use for every traversal that goes through this strategyexecutor- the executor to use for every traversal that goes through this strategy- Returns:
- a new strategy instance
-
evict
Removes the cachedGqlPlanner/GqlExecutorpair for the given graph instance. Graph implementations should call this from theirclose()method to release the cache entry and allow the planner and executor to be garbage-collected.- Parameters:
graph- the graph whose cached pair should be removed
-
apply
Description copied from interface:TraversalStrategyThe transformation the strategy applies to the traversal.- Specified by:
applyin interfaceTraversalStrategy<TraversalStrategy.ProviderOptimizationStrategy>
-