Interface TraversalSource
-
- All Superinterfaces:
AutoCloseable
,Cloneable
- All Known Implementing Classes:
GraphTraversalSource
public interface TraversalSource extends Cloneable, AutoCloseable
ATraversalSource
is used to createTraversal
instances. A traversal source can generate any number ofTraversal
instances. A traversal source is primarily composed of aGraph
and aTraversalStrategies
. VariouswithXXX
-based methods are used to configure the traversal strategies (called "configurations"). Various other methods (dependent on the traversal source type) will then generate a traversal given the graph and configured strategies (called "spawns"). A traversal source is immutable in that fluent chaining of configurations create new traversal sources. This is unlikeTraversal
andGraphComputer
, where chained methods configure the same instance. Every traversal source implementation must maintain two constructors to enable proper reflection-based construction.TraversalSource(Graph)
andTraversalSource(Graph,TraversalStrategies)
- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Stephen Mallette (http://stephen.genoprime.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
TraversalSource.Symbols
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description TraversalSource
clone()
The clone-method should be used to create immutable traversal sources with each call to a configuration "withXXX"-method.default void
close()
default Optional<Class<?>>
getAnonymousTraversalClass()
Bytecode
getBytecode()
Get theBytecode
associated with the current state of this traversal source.Graph
getGraph()
Get theGraph
associated with this traversal source.TraversalStrategies
getStrategies()
Get theTraversalStrategies
associated with this traversal source.default TraversalSource
with(String key)
Provides a configuration to a traversal in the form of a key which is the same aswith(key, true)
.default TraversalSource
with(String key, Object value)
Provides a configuration to a traversal in the form of a key value pair.default TraversalSource
withComputer()
Add the standardGraphComputer
of the graph that will be used to execute the traversal.default TraversalSource
withComputer(Class<? extends GraphComputer> graphComputerClass)
Add aGraphComputer
class used to execute the traversal.default TraversalSource
withComputer(Computer computer)
Add aComputer
that will generate aGraphComputer
from theGraph
that will be used to execute the traversal.default TraversalSource
withoutStrategies(Class<? extends TraversalStrategy>... traversalStrategyClasses)
Remove an arbitrary collection ofTraversalStrategy
classes from the traversal source.default <A> TraversalSource
withSack(A initialValue)
Add a sack to be used throughout the life of a spawnedTraversal
.default <A> TraversalSource
withSack(A initialValue, BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawnedTraversal
.default <A> TraversalSource
withSack(A initialValue, UnaryOperator<A> splitOperator)
Add a sack to be used throughout the life of a spawnedTraversal
.default <A> TraversalSource
withSack(A initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawnedTraversal
.default <A> TraversalSource
withSack(Supplier<A> initialValue)
Add a sack to be used throughout the life of a spawnedTraversal
.default <A> TraversalSource
withSack(Supplier<A> initialValue, BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawnedTraversal
.default <A> TraversalSource
withSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator)
Add a sack to be used throughout the life of a spawnedTraversal
.default <A> TraversalSource
withSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawnedTraversal
.default <A> TraversalSource
withSideEffect(String key, A initialValue)
Add a sideEffect to be used throughout the life of a spawnedTraversal
.default <A> TraversalSource
withSideEffect(String key, A initialValue, BinaryOperator<A> reducer)
Add a sideEffect to be used throughout the life of a spawnedTraversal
.default <A> TraversalSource
withSideEffect(String key, Supplier<A> initialValue)
Add a sideEffect to be used throughout the life of a spawnedTraversal
.default <A> TraversalSource
withSideEffect(String key, Supplier<A> initialValue, BinaryOperator<A> reducer)
Add a sideEffect to be used throughout the life of a spawnedTraversal
.default TraversalSource
withStrategies(TraversalStrategy... traversalStrategies)
Add an arbitrary collection ofTraversalStrategy
instances to the traversal source.
-
-
-
Method Detail
-
getStrategies
TraversalStrategies getStrategies()
Get theTraversalStrategies
associated with this traversal source.- Returns:
- the traversal strategies of the traversal source
-
getGraph
Graph getGraph()
Get theGraph
associated with this traversal source.- Returns:
- the graph of the traversal source
-
getBytecode
Bytecode getBytecode()
Get theBytecode
associated with the current state of this traversal source.- Returns:
- the traversal source byte code
-
with
default TraversalSource with(String key)
Provides a configuration to a traversal in the form of a key which is the same aswith(key, true)
. The key of the configuration must be graph provider specific and therefore a configuration could be supplied that is not known to be valid until execution.- Parameters:
key
- the key of the configuration to apply to a traversal- Returns:
- a new traversal source with the included configuration
- Since:
- 3.4.0
-
with
default TraversalSource with(String key, Object value)
Provides a configuration to a traversal in the form of a key value pair. The key of the configuration must be graph provider specific and therefore a configuration could be supplied that is not known to be valid until execution. This is a handy shortcut for building anOptionsStrategy
manually and then add withwithStrategies(TraversalStrategy[])
.- Parameters:
key
- the key of the configuration to apply to a traversalvalue
- the value of the configuration to apply to a traversal- Returns:
- a new traversal source with the included configuration
- Since:
- 3.4.0
-
withStrategies
default TraversalSource withStrategies(TraversalStrategy... traversalStrategies)
Add an arbitrary collection ofTraversalStrategy
instances to the traversal source.- Parameters:
traversalStrategies
- a collection of traversal strategies to add- Returns:
- a new traversal source with updated strategies
-
withoutStrategies
default TraversalSource withoutStrategies(Class<? extends TraversalStrategy>... traversalStrategyClasses)
Remove an arbitrary collection ofTraversalStrategy
classes from the traversal source.- Parameters:
traversalStrategyClasses
- a collection of traversal strategy classes to remove- Returns:
- a new traversal source with updated strategies
-
withComputer
default TraversalSource withComputer(Computer computer)
Add aComputer
that will generate aGraphComputer
from theGraph
that will be used to execute the traversal. This adds aVertexProgramStrategy
to the strategies.- Parameters:
computer
- a builder to generate a graph computer from the graph- Returns:
- a new traversal source with updated strategies
-
withComputer
default TraversalSource withComputer(Class<? extends GraphComputer> graphComputerClass)
Add aGraphComputer
class used to execute the traversal. This adds aVertexProgramStrategy
to the strategies.- Parameters:
graphComputerClass
- the graph computer class- Returns:
- a new traversal source with updated strategies
-
withComputer
default TraversalSource withComputer()
Add the standardGraphComputer
of the graph that will be used to execute the traversal. This adds aVertexProgramStrategy
to the strategies.- Returns:
- a new traversal source with updated strategies
-
withSideEffect
default <A> TraversalSource withSideEffect(String key, Supplier<A> initialValue, BinaryOperator<A> reducer)
Add a sideEffect to be used throughout the life of a spawnedTraversal
. This adds aSideEffectStrategy
to the strategies.- Parameters:
key
- the key of the sideEffectinitialValue
- a supplier that produces the initial value of the sideEffectreducer
- a reducer to merge sideEffect mutations into a single result- Returns:
- a new traversal source with updated strategies
-
withSideEffect
default <A> TraversalSource withSideEffect(String key, A initialValue, BinaryOperator<A> reducer)
Add a sideEffect to be used throughout the life of a spawnedTraversal
. This adds aSideEffectStrategy
to the strategies.- Parameters:
key
- the key of the sideEffectinitialValue
- the initial value of the sideEffectreducer
- a reducer to merge sideEffect mutations into a single result- Returns:
- a new traversal source with updated strategies
-
withSideEffect
default <A> TraversalSource withSideEffect(String key, Supplier<A> initialValue)
Add a sideEffect to be used throughout the life of a spawnedTraversal
. This adds aSideEffectStrategy
to the strategies.- Parameters:
key
- the key of the sideEffectinitialValue
- a supplier that produces the initial value of the sideEffect- Returns:
- a new traversal source with updated strategies
-
withSideEffect
default <A> TraversalSource withSideEffect(String key, A initialValue)
Add a sideEffect to be used throughout the life of a spawnedTraversal
. This adds aSideEffectStrategy
to the strategies.- Parameters:
key
- the key of the sideEffectinitialValue
- the initial value of the sideEffect- Returns:
- a new traversal source with updated strategies
-
withSack
default <A> TraversalSource withSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawnedTraversal
. This adds aSackStrategy
to the strategies.- Parameters:
initialValue
- a supplier that produces the initial value of the sideEffectsplitOperator
- the sack split operatormergeOperator
- the sack merge operator- Returns:
- a new traversal source with updated strategies
-
withSack
default <A> TraversalSource withSack(A initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawnedTraversal
. This adds aSackStrategy
to the strategies.- Parameters:
initialValue
- the initial value of the sideEffectsplitOperator
- the sack split operatormergeOperator
- the sack merge operator- Returns:
- a new traversal source with updated strategies
-
withSack
default <A> TraversalSource withSack(A initialValue)
Add a sack to be used throughout the life of a spawnedTraversal
. This adds aSackStrategy
to the strategies.- Parameters:
initialValue
- the initial value of the sideEffect- Returns:
- a new traversal source with updated strategies
-
withSack
default <A> TraversalSource withSack(Supplier<A> initialValue)
Add a sack to be used throughout the life of a spawnedTraversal
. This adds aSackStrategy
to the strategies.- Parameters:
initialValue
- a supplier that produces the initial value of the sideEffect- Returns:
- a new traversal source with updated strategies
-
withSack
default <A> TraversalSource withSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator)
Add a sack to be used throughout the life of a spawnedTraversal
. This adds aSackStrategy
to the strategies.- Parameters:
initialValue
- a supplier that produces the initial value of the sideEffectsplitOperator
- the sack split operator- Returns:
- a new traversal source with updated strategies
-
withSack
default <A> TraversalSource withSack(A initialValue, UnaryOperator<A> splitOperator)
Add a sack to be used throughout the life of a spawnedTraversal
. This adds aSackStrategy
to the strategies.- Parameters:
initialValue
- the initial value of the sideEffectsplitOperator
- the sack split operator- Returns:
- a new traversal source with updated strategies
-
withSack
default <A> TraversalSource withSack(Supplier<A> initialValue, BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawnedTraversal
. This adds aSackStrategy
to the strategies.- Parameters:
initialValue
- a supplier that produces the initial value of the sideEffectmergeOperator
- the sack merge operator- Returns:
- a new traversal source with updated strategies
-
withSack
default <A> TraversalSource withSack(A initialValue, BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawnedTraversal
. This adds aSackStrategy
to the strategies.- Parameters:
initialValue
- the initial value of the sideEffectmergeOperator
- the sack merge operator- Returns:
- a new traversal source with updated strategies
-
clone
TraversalSource clone()
The clone-method should be used to create immutable traversal sources with each call to a configuration "withXXX"-method. The clone-method should clone theBytecode
,TraversalStrategies
, mutate the cloned strategies accordingly, and then return the cloned traversal source leaving the original unaltered.- Returns:
- the cloned traversal source
-
close
default void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
-