Interface TraversalStrategy<S extends TraversalStrategy>
- All Superinterfaces:
Comparable<Class<? extends TraversalStrategy>>,Serializable
- All Known Subinterfaces:
TraversalStrategy.DecorationStrategy,TraversalStrategy.FinalizationStrategy,TraversalStrategy.OptimizationStrategy,TraversalStrategy.ProviderOptimizationStrategy,TraversalStrategy.VerificationStrategy
- All Known Implementing Classes:
AbstractTraversalStrategy,AbstractWarningVerificationStrategy,AdjacentToIncidentStrategy,ByModulatorOptimizationStrategy,ComputerFinalizationStrategy,ComputerVerificationStrategy,ConnectiveStrategy,CountStrategy,EarlyLimitStrategy,EdgeLabelVerificationStrategy,ElementIdStrategy,EventStrategy,FilterRankingStrategy,GqlDeclarativeMatchStrategy,GraphFilterStrategy,GValueReductionStrategy,HaltedTraverserStrategy,IdentityRemovalStrategy,IncidentToAdjacentStrategy,InlineFilterStrategy,LambdaRestrictionStrategy,LazyBarrierStrategy,MatchAlgorithmStrategy,MatchPredicateStrategy,MessagePassingReductionStrategy,OptionsStrategy,OrderLimitStrategy,PartitionStrategy,PathProcessorStrategy,PathRetractionStrategy,ProductiveByStrategy,ProfileStrategy,ProviderGValueReductionStrategy,ReadOnlyStrategy,ReferenceElementStrategy,RemoteStrategy,RepeatUnrollStrategy,RequirementsStrategy,ReservedKeysVerificationStrategy,SackStrategy,SeedStrategy,SideEffectStrategy,StandardVerificationStrategy,SubgraphStrategy,TinkerGraphCountStrategy,TinkerGraphStepStrategy,TraversalStrategyProxy,VertexProgramRestrictionStrategy,VertexProgramStrategy
public interface TraversalStrategy<S extends TraversalStrategy>
extends Serializable, Comparable<Class<? extends TraversalStrategy>>
A
TraversalStrategy defines a particular atomic operation for mutating a Traversal prior to its
evaluation. There are 5 pre-defined "traversal categories": TraversalStrategy.DecorationStrategy, TraversalStrategy.OptimizationStrategy,
TraversalStrategy.ProviderOptimizationStrategy, TraversalStrategy.FinalizationStrategy, and TraversalStrategy.VerificationStrategy.
Strategies within a category are sorted amongst themselves, and then category sorts are applied in the ordered
specified previously. That is, decorations are applied, then optimizations, then provider optimizations, then
finalizations, and finally, verifications. If a strategy does not fit within the specified categories, then it can
simply implement TraversalStrategy and can have priors/posts that span categories.
A traversal strategy should be a final class as various internal operations on a strategy are based on its ability to
be assigned to more general classes. A traversal strategy should typically be stateless with a public static
instance() method. However, at limit, a traversal strategy can have a state-defining constructor
(typically via a "builder"), but that state cannot mutate once instantiated.
Given that a traversal strategy can completely rewrite a traversal, it must take into account the
GValueManager state while doing so. The GValueManager maintains a record of "pinned" and "free"
variables. When a new traversal is created, all variables are considered free, as any value may be substituted for
a variable without restriction. Strategies may rewrite a traversal in a manner which is valid for the current value
of a GValue, but would lead to incorrect behaviour if that variable were later updated arbitrarily. An
example of this is EarlyLimitStrategy, which will replace a traversal such as
`limit(GValue.of("x", 5)).valueMap().range(5, 10)` with simply `discard()`, as the limit and range prevent the
traversal from being productive. This optimization is not generalizable to any values of `x` however, as any value of
`x` greater than 5 is expected to produce results. In cases such as these, the strategy must ensure that the variable
`x` is "pinned" in the GValueManager, to indicate it is no longer free to be updated arbitrarily.- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Matthias Broecheler (me@matthiasb.com)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceImplemented by strategies that adds "application logic" to the traversal (e.g.static interfaceImplemented by strategies that do final behaviors that require a fully compiled traversal to work (e.g.static interfaceImplemented by strategies that rewrite the traversal to be more efficient, but with the same semantics (e.g.static interfaceImplemented by strategies that rewrite the traversal to be more efficient, but with the same semantics.static interfaceImplemented by strategies where there is no more behavioral tweaking of the traversal required. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(Traversal.Admin<?, ?> traversal) The transformation the strategy applies to the traversal.The set of strategies that must be executed after this strategy is executed.The set of strategies that must be executed before this strategy is executed.default intcompareTo(Class<? extends TraversalStrategy> otherTraversalCategory) default org.apache.commons.configuration2.ConfigurationGet the configuration representation of this strategy.The type of traversal strategy -- i.e.
-
Method Details
-
apply
The transformation the strategy applies to the traversal. -
applyPrior
The set of strategies that must be executed before this strategy is executed. If there are no ordering requirements, the default implementation returns an empty set.- Returns:
- the set of strategies that must be executed prior to this one.
-
applyPost
The set of strategies that must be executed after this strategy is executed. If there are no ordering requirements, the default implementation returns an empty set.- Returns:
- the set of strategies that must be executed post this one
-
getTraversalCategory
The type of traversal strategy -- i.e.TraversalStrategy.DecorationStrategy,TraversalStrategy.OptimizationStrategy,TraversalStrategy.FinalizationStrategy, orTraversalStrategy.VerificationStrategy.- Returns:
- the traversal strategy category class
-
getConfiguration
default org.apache.commons.configuration2.Configuration getConfiguration()Get the configuration representation of this strategy. This is useful for converting a strategy into a serialized form.- Returns:
- the configuration used to create this strategy
-
compareTo
- Specified by:
compareToin interfaceComparable<S extends TraversalStrategy>
-