public interface TraversalSource extends Cloneable, AutoCloseable
TraversalSource
is used to create Traversal
instances.
A traversal source can generate any number of Traversal
instances.
A traversal source is primarily composed of a Graph
and a TraversalStrategies
.
Various withXXX
-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 unlike Traversal
and GraphComputer
, where chained methods configure the same instance.
Every traversal source implementation must maintain two constructors to enable proper reflection-based construction.
TraversalSource(Graph)
and TraversalSource(Graph,TraversalStrategies)
Modifier and Type | Interface and Description |
---|---|
static interface |
TraversalSource.Builder<C extends TraversalSource>
Deprecated.
As of release 3.2.0. Please use
Graph.traversal(Class) . |
static class |
TraversalSource.Symbols |
Modifier and Type | Field and Description |
---|---|
static String |
GREMLIN_REMOTE |
static String |
GREMLIN_REMOTE_CONNECTION_CLASS |
Modifier and Type | Method and 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 the
Bytecode associated with the current state of this traversal source. |
Graph |
getGraph()
Get the
Graph associated with this traversal source. |
TraversalStrategies |
getStrategies()
Get the
TraversalStrategies associated with this traversal source. |
default TraversalSource |
withBindings(Bindings bindings)
Deprecated.
As of release 3.2.4, replaced by use of
Bindings without reference to a TraversalSource . |
default TraversalSource |
withComputer()
Add the standard
GraphComputer of the graph that will be used to execute the traversal. |
default TraversalSource |
withComputer(Class<? extends GraphComputer> graphComputerClass)
Add a
GraphComputer class used to execute the traversal. |
default TraversalSource |
withComputer(Computer computer)
Add a
Computer that will generate a GraphComputer from the Graph that will be used to execute the traversal. |
default TraversalSource |
withoutStrategies(Class<? extends TraversalStrategy>... traversalStrategyClasses)
Remove an arbitrary collection of
TraversalStrategy classes from the traversal source. |
default TraversalSource |
withRemote(Configuration conf)
Configures the
TraversalSource as a "remote" to issue the Traversal for execution elsewhere. |
default <A> TraversalSource |
withSack(A initialValue)
Add a sack to be used throughout the life of a spawned
Traversal . |
default <A> TraversalSource |
withSack(A initialValue,
BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
default <A> TraversalSource |
withSack(A initialValue,
UnaryOperator<A> splitOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
default <A> TraversalSource |
withSack(A initialValue,
UnaryOperator<A> splitOperator,
BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
default <A> TraversalSource |
withSack(Supplier<A> initialValue)
Add a sack to be used throughout the life of a spawned
Traversal . |
default <A> TraversalSource |
withSack(Supplier<A> initialValue,
BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
default <A> TraversalSource |
withSack(Supplier<A> initialValue,
UnaryOperator<A> splitOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
default <A> TraversalSource |
withSack(Supplier<A> initialValue,
UnaryOperator<A> splitOperator,
BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
default <A> TraversalSource |
withSideEffect(String key,
A initialValue)
Add a sideEffect to be used throughout the life of a spawned
Traversal . |
default <A> TraversalSource |
withSideEffect(String key,
A initialValue,
BinaryOperator<A> reducer)
Add a sideEffect to be used throughout the life of a spawned
Traversal . |
default <A> TraversalSource |
withSideEffect(String key,
Supplier<A> initialValue)
Add a sideEffect to be used throughout the life of a spawned
Traversal . |
default <A> TraversalSource |
withSideEffect(String key,
Supplier<A> initialValue,
BinaryOperator<A> reducer)
Add a sideEffect to be used throughout the life of a spawned
Traversal . |
default TraversalSource |
withStrategies(TraversalStrategy... traversalStrategies)
Add an arbitrary collection of
TraversalStrategy instances to the traversal source. |
static final String GREMLIN_REMOTE
static final String GREMLIN_REMOTE_CONNECTION_CLASS
TraversalStrategies getStrategies()
TraversalStrategies
associated with this traversal source.Graph getGraph()
Graph
associated with this traversal source.Bytecode getBytecode()
Bytecode
associated with the current state of this traversal source.default TraversalSource withStrategies(TraversalStrategy... traversalStrategies)
TraversalStrategy
instances to the traversal source.traversalStrategies
- a collection of traversal strategies to adddefault TraversalSource withoutStrategies(Class<? extends TraversalStrategy>... traversalStrategyClasses)
TraversalStrategy
classes from the traversal source.traversalStrategyClasses
- a collection of traversal strategy classes to remove@Deprecated default TraversalSource withBindings(Bindings bindings)
Bindings
without reference to a TraversalSource
.Bindings
to create Bytecode.Binding
.
The bindings serve as a relay for ensure bound arguments are encoded as Bytecode.Binding
in Bytecode
.bindings
- the bindings instance to usedefault TraversalSource withComputer(Computer computer)
Computer
that will generate a GraphComputer
from the Graph
that will be used to execute the traversal.
This adds a VertexProgramStrategy
to the strategies.computer
- a builder to generate a graph computer from the graphdefault TraversalSource withComputer(Class<? extends GraphComputer> graphComputerClass)
GraphComputer
class used to execute the traversal.
This adds a VertexProgramStrategy
to the strategies.graphComputerClass
- the graph computer classdefault TraversalSource withComputer()
GraphComputer
of the graph that will be used to execute the traversal.
This adds a VertexProgramStrategy
to the strategies.default <A> TraversalSource withSideEffect(String key, Supplier<A> initialValue, BinaryOperator<A> reducer)
Traversal
.
This adds a SideEffectStrategy
to the strategies.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 resultdefault <A> TraversalSource withSideEffect(String key, A initialValue, BinaryOperator<A> reducer)
Traversal
.
This adds a SideEffectStrategy
to the strategies.key
- the key of the sideEffectinitialValue
- the initial value of the sideEffectreducer
- a reducer to merge sideEffect mutations into a single resultdefault <A> TraversalSource withSideEffect(String key, Supplier<A> initialValue)
Traversal
.
This adds a SideEffectStrategy
to the strategies.key
- the key of the sideEffectinitialValue
- a supplier that produces the initial value of the sideEffectdefault <A> TraversalSource withSideEffect(String key, A initialValue)
Traversal
.
This adds a SideEffectStrategy
to the strategies.key
- the key of the sideEffectinitialValue
- the initial value of the sideEffectdefault <A> TraversalSource withSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator)
Traversal
.
This adds a SackStrategy
to the strategies.initialValue
- a supplier that produces the initial value of the sideEffectsplitOperator
- the sack split operatormergeOperator
- the sack merge operatordefault <A> TraversalSource withSack(A initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator)
Traversal
.
This adds a SackStrategy
to the strategies.initialValue
- the initial value of the sideEffectsplitOperator
- the sack split operatormergeOperator
- the sack merge operatordefault <A> TraversalSource withSack(A initialValue)
Traversal
.
This adds a SackStrategy
to the strategies.initialValue
- the initial value of the sideEffectdefault <A> TraversalSource withSack(Supplier<A> initialValue)
Traversal
.
This adds a SackStrategy
to the strategies.initialValue
- a supplier that produces the initial value of the sideEffectdefault <A> TraversalSource withSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator)
Traversal
.
This adds a SackStrategy
to the strategies.initialValue
- a supplier that produces the initial value of the sideEffectsplitOperator
- the sack split operatordefault <A> TraversalSource withSack(A initialValue, UnaryOperator<A> splitOperator)
Traversal
.
This adds a SackStrategy
to the strategies.initialValue
- the initial value of the sideEffectsplitOperator
- the sack split operatordefault <A> TraversalSource withSack(Supplier<A> initialValue, BinaryOperator<A> mergeOperator)
Traversal
.
This adds a SackStrategy
to the strategies.initialValue
- a supplier that produces the initial value of the sideEffectmergeOperator
- the sack merge operatordefault <A> TraversalSource withSack(A initialValue, BinaryOperator<A> mergeOperator)
Traversal
.
This adds a SackStrategy
to the strategies.initialValue
- the initial value of the sideEffectmergeOperator
- the sack merge operatordefault TraversalSource withRemote(Configuration conf)
TraversalSource
as a "remote" to issue the Traversal
for execution elsewhere.
Expects key for GREMLIN_REMOTE_CONNECTION_CLASS
as well as any configuration required by
the underlying RemoteConnection
which will be instantiated. Note that the Configuration
object
is passed down without change to the creation of the RemoteConnection
instance.TraversalSource clone()
Bytecode
, TraversalStrategies
, mutate the cloned strategies accordingly,
and then return the cloned traversal source leaving the original unaltered.default void close() throws Exception
close
in interface AutoCloseable
Exception
Copyright © 2013–2017 Apache Software Foundation. All rights reserved.