Class GraphTraversalSource
- java.lang.Object
- 
- org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
 
- 
- All Implemented Interfaces:
- AutoCloseable,- Cloneable,- TraversalSource
 - Direct Known Subclasses:
- CredentialTraversalSourceDsl
 
 public class GraphTraversalSource extends Object implements TraversalSource AGraphTraversalSourceis the primary DSL of the Gremlin traversal machine. It provides access to all the configurations and steps for Turing complete graph computing. Any DSL can be constructed based on the methods of bothGraphTraversalSourceandGraphTraversal.- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Stephen Mallette (http://stephen.genoprime.com)
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classGraphTraversalSource.Symbols
 - 
Field SummaryFields Modifier and Type Field Description protected Bytecodebytecodeprotected RemoteConnectionconnectionprotected Graphgraphprotected TraversalStrategiesstrategies
 - 
Constructor SummaryConstructors Constructor Description GraphTraversalSource(RemoteConnection connection)GraphTraversalSource(Graph graph)GraphTraversalSource(Graph graph, TraversalStrategies traversalStrategies)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphTraversal<Edge,Edge>addE(String label)Spawns aGraphTraversalby adding an edge with the specified label.GraphTraversal<Edge,Edge>addE(Traversal<?,String> edgeLabelTraversal)Spawns aGraphTraversalby adding a edge with a label as specified by the providedTraversal.GraphTraversal<Vertex,Vertex>addV()Spawns aGraphTraversalby adding a vertex with the default label.GraphTraversal<Vertex,Vertex>addV(String vertexLabel)Spawns aGraphTraversalby adding a vertex with the specified label.GraphTraversal<Vertex,Vertex>addV(Traversal<?,String> vertexLabelTraversal)Spawns aGraphTraversalby adding a vertex with the label as determined by aTraversal.<S> GraphTraversal<S,S>call()Spawns aGraphTraversalstarting with a list of available services.<S> GraphTraversal<S,S>call(String service)Spawns aGraphTraversalstarting with values produced by the specified service call with no parameters.<S> GraphTraversal<S,S>call(String service, Map params)Spawns aGraphTraversalstarting with values produced by the specified service call with the specified static parameters.<S> GraphTraversal<S,S>call(String service, Map params, Traversal<S,Map> childTraversal)Spawns aGraphTraversalstarting with values produced by the specified service call with both static and dynamic parameters produced by the specified child traversal.<S> GraphTraversal<S,S>call(String service, Traversal<S,Map> childTraversal)Spawns aGraphTraversalstarting with values produced by the specified service call with dynamic parameters produced by the specified child traversal.GraphTraversalSourceclone()The clone-method should be used to create immutable traversal sources with each call to a configuration "withXXX"-method.voidclose()If there is an underlyingRemoteConnectionit will be closed by this method.GraphTraversal<Edge,Edge>E(Object... edgeIds)Spawns aGraphTraversalstarting with all edges or some subset of edges as specified by their unique identifier.Optional<Class<?>>getAnonymousTraversalClass()BytecodegetBytecode()Get theBytecodeassociated with the current state of this traversal source.GraphgetGraph()Get theGraphassociated with this traversal source.TraversalStrategiesgetStrategies()Get theTraversalStrategiesassociated with this traversal source.<S> GraphTraversal<S,S>inject(S... starts)Spawns aGraphTraversalstarting it with arbitrary values.<S> GraphTraversal<S,S>io(String file)Performs a read or write based operation on theGraphbacking thisGraphTraversalSource.GraphTraversal<Edge,Edge>mergeE(Map<?,Object> searchCreate)Spawns aGraphTraversalby doing a merge (i.e.GraphTraversal<Edge,Edge>mergeE(Traversal<?,Map<Object,Object>> searchCreate)Spawns aGraphTraversalby doing a merge (i.e.GraphTraversal<Vertex,Vertex>mergeV(Map<Object,Object> searchCreate)Spawns aGraphTraversalby doing a merge (i.e.<S> GraphTraversal<S,Vertex>mergeV(Traversal<?,Map<Object,Object>> searchCreate)Spawns aGraphTraversalby doing a merge (i.e.StringtoString()Transactiontx()Proxies calls through to the underlyingGraph.tx()or to theRemoteConnection.tx().GraphTraversal<Vertex,Vertex>V(Object... vertexIds)Spawns aGraphTraversalstarting with all vertices or some subset of vertices as specified by their unique identifier.GraphTraversalSourcewith(String key)Provides a configuration to a traversal in the form of a key which is the same aswith(key, true).GraphTraversalSourcewith(String key, Object value)Provides a configuration to a traversal in the form of a key value pair.GraphTraversalSourcewithBulk(boolean useBulk)GraphTraversalSourcewithComputer()Add the standardGraphComputerof the graph that will be used to execute the traversal.GraphTraversalSourcewithComputer(Class<? extends GraphComputer> graphComputerClass)Add aGraphComputerclass used to execute the traversal.GraphTraversalSourcewithComputer(Computer computer)Add aComputerthat will generate aGraphComputerfrom theGraphthat will be used to execute the traversal.GraphTraversalSourcewithoutStrategies(Class<? extends TraversalStrategy>... traversalStrategyClasses)Remove an arbitrary collection ofTraversalStrategyclasses from the traversal source.GraphTraversalSourcewithPath()<A> GraphTraversalSourcewithSack(A initialValue)Add a sack to be used throughout the life of a spawnedTraversal.<A> GraphTraversalSourcewithSack(A initialValue, BinaryOperator<A> mergeOperator)Add a sack to be used throughout the life of a spawnedTraversal.<A> GraphTraversalSourcewithSack(A initialValue, UnaryOperator<A> splitOperator)Add a sack to be used throughout the life of a spawnedTraversal.<A> GraphTraversalSourcewithSack(A initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator)Add a sack to be used throughout the life of a spawnedTraversal.<A> GraphTraversalSourcewithSack(Supplier<A> initialValue)Add a sack to be used throughout the life of a spawnedTraversal.<A> GraphTraversalSourcewithSack(Supplier<A> initialValue, BinaryOperator<A> mergeOperator)Add a sack to be used throughout the life of a spawnedTraversal.<A> GraphTraversalSourcewithSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator)Add a sack to be used throughout the life of a spawnedTraversal.<A> GraphTraversalSourcewithSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator)Add a sack to be used throughout the life of a spawnedTraversal.<A> GraphTraversalSourcewithSideEffect(String key, A initialValue)Add a sideEffect to be used throughout the life of a spawnedTraversal.<A> GraphTraversalSourcewithSideEffect(String key, A initialValue, BinaryOperator<A> reducer)Add a sideEffect to be used throughout the life of a spawnedTraversal.<A> GraphTraversalSourcewithSideEffect(String key, Supplier<A> initialValue)Add a sideEffect to be used throughout the life of a spawnedTraversal.<A> GraphTraversalSourcewithSideEffect(String key, Supplier<A> initialValue, BinaryOperator<A> reducer)Add a sideEffect to be used throughout the life of a spawnedTraversal.GraphTraversalSourcewithStrategies(TraversalStrategy... traversalStrategies)Add an arbitrary collection ofTraversalStrategyinstances to the traversal source.
 
- 
- 
- 
Field Detail- 
connectionprotected transient RemoteConnection connection 
 - 
graphprotected final Graph graph 
 - 
strategiesprotected TraversalStrategies strategies 
 - 
bytecodeprotected Bytecode bytecode 
 
- 
 - 
Constructor Detail- 
GraphTraversalSourcepublic GraphTraversalSource(Graph graph, TraversalStrategies traversalStrategies) 
 - 
GraphTraversalSourcepublic GraphTraversalSource(Graph graph) 
 - 
GraphTraversalSourcepublic GraphTraversalSource(RemoteConnection connection) 
 
- 
 - 
Method Detail- 
getAnonymousTraversalClasspublic Optional<Class<?>> getAnonymousTraversalClass() - Specified by:
- getAnonymousTraversalClassin interface- TraversalSource
 
 - 
getStrategiespublic TraversalStrategies getStrategies() Description copied from interface:TraversalSourceGet theTraversalStrategiesassociated with this traversal source.- Specified by:
- getStrategiesin interface- TraversalSource
- Returns:
- the traversal strategies of the traversal source
 
 - 
getGraphpublic Graph getGraph() Description copied from interface:TraversalSourceGet theGraphassociated with this traversal source.- Specified by:
- getGraphin interface- TraversalSource
- Returns:
- the graph of the traversal source
 
 - 
getBytecodepublic Bytecode getBytecode() Description copied from interface:TraversalSourceGet theBytecodeassociated with the current state of this traversal source.- Specified by:
- getBytecodein interface- TraversalSource
- Returns:
- the traversal source byte code
 
 - 
clonepublic GraphTraversalSource clone() Description copied from interface:TraversalSourceThe 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.- Specified by:
- clonein interface- TraversalSource
- Overrides:
- clonein class- Object
- Returns:
- the cloned traversal source
 
 - 
withpublic GraphTraversalSource 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.- Specified by:
- within interface- TraversalSource
- Parameters:
- key- the key of the configuration to apply to a traversal
- Returns:
- a new traversal source with the included configuration
 
 - 
withpublic GraphTraversalSource 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 anOptionsStrategymanually and then add withTraversalSource.withStrategies(TraversalStrategy[]).- Specified by:
- within interface- TraversalSource
- Parameters:
- key- the key of the configuration to apply to a traversal
- value- the value of the configuration to apply to a traversal
- Returns:
- a new traversal source with the included configuration
 
 - 
withStrategiespublic GraphTraversalSource withStrategies(TraversalStrategy... traversalStrategies) Add an arbitrary collection ofTraversalStrategyinstances to the traversal source.- Specified by:
- withStrategiesin interface- TraversalSource
- Parameters:
- traversalStrategies- a collection of traversal strategies to add
- Returns:
- a new traversal source with updated strategies
 
 - 
withoutStrategiespublic GraphTraversalSource withoutStrategies(Class<? extends TraversalStrategy>... traversalStrategyClasses) Remove an arbitrary collection ofTraversalStrategyclasses from the traversal source.- Specified by:
- withoutStrategiesin interface- TraversalSource
- Parameters:
- traversalStrategyClasses- a collection of traversal strategy classes to remove
- Returns:
- a new traversal source with updated strategies
 
 - 
withComputerpublic GraphTraversalSource withComputer(Computer computer) Add aComputerthat will generate aGraphComputerfrom theGraphthat will be used to execute the traversal. This adds aVertexProgramStrategyto the strategies.- Specified by:
- withComputerin interface- TraversalSource
- Parameters:
- computer- a builder to generate a graph computer from the graph
- Returns:
- a new traversal source with updated strategies
 
 - 
withComputerpublic GraphTraversalSource withComputer(Class<? extends GraphComputer> graphComputerClass) Add aGraphComputerclass used to execute the traversal. This adds aVertexProgramStrategyto the strategies.- Specified by:
- withComputerin interface- TraversalSource
- Parameters:
- graphComputerClass- the graph computer class
- Returns:
- a new traversal source with updated strategies
 
 - 
withComputerpublic GraphTraversalSource withComputer() Add the standardGraphComputerof the graph that will be used to execute the traversal. This adds aVertexProgramStrategyto the strategies.- Specified by:
- withComputerin interface- TraversalSource
- Returns:
- a new traversal source with updated strategies
 
 - 
withSideEffectpublic <A> GraphTraversalSource withSideEffect(String key, Supplier<A> initialValue, BinaryOperator<A> reducer) Add a sideEffect to be used throughout the life of a spawnedTraversal. This adds aSideEffectStrategyto the strategies.- Specified by:
- withSideEffectin interface- TraversalSource
- Parameters:
- key- the key of the sideEffect
- initialValue- a supplier that produces the initial value of the sideEffect
- reducer- a reducer to merge sideEffect mutations into a single result
- Returns:
- a new traversal source with updated strategies
 
 - 
withSideEffectpublic <A> GraphTraversalSource withSideEffect(String key, A initialValue, BinaryOperator<A> reducer) Add a sideEffect to be used throughout the life of a spawnedTraversal. This adds aSideEffectStrategyto the strategies.- Specified by:
- withSideEffectin interface- TraversalSource
- Parameters:
- key- the key of the sideEffect
- initialValue- the initial value of the sideEffect
- reducer- a reducer to merge sideEffect mutations into a single result
- Returns:
- a new traversal source with updated strategies
 
 - 
withSideEffectpublic <A> GraphTraversalSource withSideEffect(String key, A initialValue) Add a sideEffect to be used throughout the life of a spawnedTraversal. This adds aSideEffectStrategyto the strategies.- Specified by:
- withSideEffectin interface- TraversalSource
- Parameters:
- key- the key of the sideEffect
- initialValue- the initial value of the sideEffect
- Returns:
- a new traversal source with updated strategies
 
 - 
withSideEffectpublic <A> GraphTraversalSource withSideEffect(String key, Supplier<A> initialValue) Add a sideEffect to be used throughout the life of a spawnedTraversal. This adds aSideEffectStrategyto the strategies.- Specified by:
- withSideEffectin interface- TraversalSource
- Parameters:
- key- the key of the sideEffect
- initialValue- a supplier that produces the initial value of the sideEffect
- Returns:
- a new traversal source with updated strategies
 
 - 
withSackpublic <A> GraphTraversalSource withSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator) Add a sack to be used throughout the life of a spawnedTraversal. This adds aSackStrategyto the strategies.- Specified by:
- withSackin interface- TraversalSource
- Parameters:
- initialValue- a supplier that produces the initial value of the sideEffect
- splitOperator- the sack split operator
- mergeOperator- the sack merge operator
- Returns:
- a new traversal source with updated strategies
 
 - 
withSackpublic <A> GraphTraversalSource withSack(A initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator) Add a sack to be used throughout the life of a spawnedTraversal. This adds aSackStrategyto the strategies.- Specified by:
- withSackin interface- TraversalSource
- Parameters:
- initialValue- the initial value of the sideEffect
- splitOperator- the sack split operator
- mergeOperator- the sack merge operator
- Returns:
- a new traversal source with updated strategies
 
 - 
withSackpublic <A> GraphTraversalSource withSack(A initialValue) Add a sack to be used throughout the life of a spawnedTraversal. This adds aSackStrategyto the strategies.- Specified by:
- withSackin interface- TraversalSource
- Parameters:
- initialValue- the initial value of the sideEffect
- Returns:
- a new traversal source with updated strategies
 
 - 
withSackpublic <A> GraphTraversalSource withSack(Supplier<A> initialValue) Add a sack to be used throughout the life of a spawnedTraversal. This adds aSackStrategyto the strategies.- Specified by:
- withSackin interface- TraversalSource
- Parameters:
- initialValue- a supplier that produces the initial value of the sideEffect
- Returns:
- a new traversal source with updated strategies
 
 - 
withSackpublic <A> GraphTraversalSource withSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator) Add a sack to be used throughout the life of a spawnedTraversal. This adds aSackStrategyto the strategies.- Specified by:
- withSackin interface- TraversalSource
- Parameters:
- initialValue- a supplier that produces the initial value of the sideEffect
- splitOperator- the sack split operator
- Returns:
- a new traversal source with updated strategies
 
 - 
withSackpublic <A> GraphTraversalSource withSack(A initialValue, UnaryOperator<A> splitOperator) Add a sack to be used throughout the life of a spawnedTraversal. This adds aSackStrategyto the strategies.- Specified by:
- withSackin interface- TraversalSource
- Parameters:
- initialValue- the initial value of the sideEffect
- splitOperator- the sack split operator
- Returns:
- a new traversal source with updated strategies
 
 - 
withSackpublic <A> GraphTraversalSource withSack(Supplier<A> initialValue, BinaryOperator<A> mergeOperator) Add a sack to be used throughout the life of a spawnedTraversal. This adds aSackStrategyto the strategies.- Specified by:
- withSackin interface- TraversalSource
- Parameters:
- initialValue- a supplier that produces the initial value of the sideEffect
- mergeOperator- the sack merge operator
- Returns:
- a new traversal source with updated strategies
 
 - 
withSackpublic <A> GraphTraversalSource withSack(A initialValue, BinaryOperator<A> mergeOperator) Add a sack to be used throughout the life of a spawnedTraversal. This adds aSackStrategyto the strategies.- Specified by:
- withSackin interface- TraversalSource
- Parameters:
- initialValue- the initial value of the sideEffect
- mergeOperator- the sack merge operator
- Returns:
- a new traversal source with updated strategies
 
 - 
withBulkpublic GraphTraversalSource withBulk(boolean useBulk) 
 - 
withPathpublic GraphTraversalSource withPath() 
 - 
addVpublic GraphTraversal<Vertex,Vertex> addV(String vertexLabel) Spawns aGraphTraversalby adding a vertex with the specified label. If thelabelisnullthen it will default toVertex.DEFAULT_LABEL.- Since:
- 3.1.0-incubating
 
 - 
addVpublic GraphTraversal<Vertex,Vertex> addV(Traversal<?,String> vertexLabelTraversal) Spawns aGraphTraversalby adding a vertex with the label as determined by aTraversal. If thevertexLabelTraversalisnullthen it will default toVertex.DEFAULT_LABEL.- Since:
- 3.3.1
 
 - 
addVpublic GraphTraversal<Vertex,Vertex> addV() Spawns aGraphTraversalby adding a vertex with the default label.- Since:
- 3.1.0-incubating
 
 - 
addEpublic GraphTraversal<Edge,Edge> addE(String label) Spawns aGraphTraversalby adding an edge with the specified label.- Since:
- 3.1.0-incubating
 
 - 
addEpublic GraphTraversal<Edge,Edge> addE(Traversal<?,String> edgeLabelTraversal) Spawns aGraphTraversalby adding a edge with a label as specified by the providedTraversal.- Since:
- 3.3.1
 
 - 
mergeVpublic GraphTraversal<Vertex,Vertex> mergeV(Map<Object,Object> searchCreate) Spawns aGraphTraversalby doing a merge (i.e. upsert) style operation for anVertexusing aMapas an argument. TheMaprepresents search criteria and will match each of the supplied key/value pairs where the keys may beStringproperty values or a value ofT. If a match is not made it will use that search criteria to create the newVertex.- Parameters:
- searchCreate- This- Mapcan have a key of- Tor a- String.
- Since:
- 3.6.0
 
 - 
mergeVpublic <S> GraphTraversal<S,Vertex> mergeV(Traversal<?,Map<Object,Object>> searchCreate) Spawns aGraphTraversalby doing a merge (i.e. upsert) style operation for anVertexusing aMapas an argument. TheMaprepresents search criteria and will match each of the supplied key/value pairs where the keys may beStringproperty values or a value ofT. If a match is not made it will use that search criteria to create the newVertex.
 - 
mergeEpublic GraphTraversal<Edge,Edge> mergeE(Map<?,Object> searchCreate) Spawns aGraphTraversalby doing a merge (i.e. upsert) style operation for anEdgeusing aMapas an argument.
 - 
mergeEpublic GraphTraversal<Edge,Edge> mergeE(Traversal<?,Map<Object,Object>> searchCreate) Spawns aGraphTraversalby doing a merge (i.e. upsert) style operation for anEdgeusing aMapas an argument.
 - 
injectpublic <S> GraphTraversal<S,S> inject(S... starts) Spawns aGraphTraversalstarting it with arbitrary values.
 - 
Vpublic GraphTraversal<Vertex,Vertex> V(Object... vertexIds) Spawns aGraphTraversalstarting with all vertices or some subset of vertices as specified by their unique identifier.- Since:
- 3.0.0-incubating
 
 - 
Epublic GraphTraversal<Edge,Edge> E(Object... edgeIds) Spawns aGraphTraversalstarting with all edges or some subset of edges as specified by their unique identifier.- Since:
- 3.0.0-incubating
 
 - 
callpublic <S> GraphTraversal<S,S> call() Spawns aGraphTraversalstarting with a list of available services.- Since:
- 3.6.0
 
 - 
callpublic <S> GraphTraversal<S,S> call(String service) Spawns aGraphTraversalstarting with values produced by the specified service call with no parameters.- Parameters:
- service- the name of the service call
- Since:
- 3.6.0
 
 - 
callpublic <S> GraphTraversal<S,S> call(String service, Map params) Spawns aGraphTraversalstarting with values produced by the specified service call with the specified static parameters.- Parameters:
- service- the name of the service call
- params- static parameter map (no nested traversals)
- Since:
- 3.6.0
 
 - 
callpublic <S> GraphTraversal<S,S> call(String service, Traversal<S,Map> childTraversal) Spawns aGraphTraversalstarting with values produced by the specified service call with dynamic parameters produced by the specified child traversal.- Parameters:
- service- the name of the service call
- childTraversal- a traversal that will produce a Map of parameters for the service call when invoked.
- Since:
- 3.6.0
 
 - 
callpublic <S> GraphTraversal<S,S> call(String service, Map params, Traversal<S,Map> childTraversal) Spawns aGraphTraversalstarting with values produced by the specified service call with both static and dynamic parameters produced by the specified child traversal. These parameters will be merged at execution time per the provider implementation. Reference implementation merges dynamic into static (dynamic will overwrite static).- Parameters:
- service- the name of the service call
- params- static parameter map (no nested traversals)
- childTraversal- a traversal that will produce a Map of parameters for the service call when invoked.
- Since:
- 3.6.0
 
 - 
iopublic <S> GraphTraversal<S,S> io(String file) Performs a read or write based operation on theGraphbacking thisGraphTraversalSource. This step can be accompanied by theGraphTraversal.with(String, Object)modulator for further configuration and must be accompanied by aGraphTraversal.read()orGraphTraversal.write()modulator step which will terminate the traversal.- Parameters:
- file- the name of file for which the read or write will apply - note that the context of how this parameter is used is wholly dependent on the implementation
- Returns:
- the traversal with the IoStepadded
- Since:
- 3.4.0
- See Also:
- Reference Documentation - IO Step, Reference Documentation - Read Step, Reference Documentation - Write Step
 
 - 
txpublic Transaction tx() Proxies calls through to the underlyingGraph.tx()or to theRemoteConnection.tx().
 - 
closepublic void close() throws ExceptionIf there is an underlyingRemoteConnectionit will be closed by this method.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- TraversalSource
- Throws:
- Exception
 
 
- 
 
-