public class GraphTraversalSource extends Object implements TraversalSource
GraphTraversalSource
is 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 both GraphTraversalSource
and GraphTraversal
.Modifier and Type | Class and Description |
---|---|
static class |
GraphTraversalSource.Symbols |
Modifier and Type | Field and Description |
---|---|
protected Bytecode |
bytecode |
protected RemoteConnection |
connection |
protected Graph |
graph |
protected TraversalStrategies |
strategies |
Constructor and Description |
---|
GraphTraversalSource(Graph graph) |
GraphTraversalSource(Graph graph,
TraversalStrategies traversalStrategies) |
GraphTraversalSource(RemoteConnection connection) |
Modifier and Type | Method and Description |
---|---|
GraphTraversal<Edge,Edge> |
addE(String label)
Spawns a
GraphTraversal by adding an edge with the specified label. |
GraphTraversal<Edge,Edge> |
addE(Traversal<?,String> edgeLabelTraversal)
Spawns a
GraphTraversal by adding a edge with a label as specified by the provided Traversal . |
GraphTraversal<Vertex,Vertex> |
addV()
Spawns a
GraphTraversal by adding a vertex with the default label. |
GraphTraversal<Vertex,Vertex> |
addV(String vertexLabel)
Spawns a
GraphTraversal by adding a vertex with the specified label. |
GraphTraversal<Vertex,Vertex> |
addV(Traversal<?,String> vertexLabelTraversal)
Spawns a
GraphTraversal by adding a vertex with the label as determined by a Traversal . |
<S> GraphTraversal<S,S> |
call()
Spawns a
GraphTraversal starting with a list of available services. |
<S> GraphTraversal<S,S> |
call(String service)
Spawns a
GraphTraversal starting with values produced by the specified service call with no parameters. |
<S> GraphTraversal<S,S> |
call(String service,
Map params)
Spawns a
GraphTraversal starting 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 a
GraphTraversal starting 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 a
GraphTraversal starting with values produced by the specified service call with dynamic
parameters produced by the specified child traversal. |
GraphTraversalSource |
clone()
The clone-method should be used to create immutable traversal sources with each call to a configuration "withXXX"-method.
|
void |
close()
If there is an underlying
RemoteConnection it will be closed by this method. |
GraphTraversal<Edge,Edge> |
E(Object... edgeIds)
Spawns a
GraphTraversal starting with all edges or some subset of edges as specified by their unique
identifier. |
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. |
<S> GraphTraversal<S,S> |
inject(S... starts)
Spawns a
GraphTraversal starting it with arbitrary values. |
<S> GraphTraversal<S,S> |
io(String file)
Performs a read or write based operation on the
Graph backing this GraphTraversalSource . |
GraphTraversal<Edge,Edge> |
mergeE(Map<?,Object> searchCreate)
Spawns a
GraphTraversal by doing a merge (i.e. |
GraphTraversal<Edge,Edge> |
mergeE(Traversal<?,Map<Object,Object>> searchCreate)
Spawns a
GraphTraversal by doing a merge (i.e. |
GraphTraversal<Vertex,Vertex> |
mergeV(Map<Object,Object> searchCreate)
Spawns a
GraphTraversal by doing a merge (i.e. |
<S> GraphTraversal<S,Vertex> |
mergeV(Traversal<?,Map<Object,Object>> searchCreate)
Spawns a
GraphTraversal by doing a merge (i.e. |
String |
toString() |
Transaction |
tx()
Proxies calls through to the underlying
Graph.tx() or to the RemoteConnection.tx() . |
GraphTraversal<Vertex,Vertex> |
V(Object... vertexIds)
Spawns a
GraphTraversal starting with all vertices or some subset of vertices as specified by their
unique identifier. |
GraphTraversalSource |
with(String key)
Provides a configuration to a traversal in the form of a key which is the same as
with(key, true) . |
GraphTraversalSource |
with(String key,
Object value)
Provides a configuration to a traversal in the form of a key value pair.
|
GraphTraversalSource |
withBulk(boolean useBulk) |
GraphTraversalSource |
withComputer()
Add the standard
GraphComputer of the graph that will be used to execute the traversal. |
GraphTraversalSource |
withComputer(Class<? extends GraphComputer> graphComputerClass)
Add a
GraphComputer class used to execute the traversal. |
GraphTraversalSource |
withComputer(Computer computer)
Add a
Computer that will generate a GraphComputer from the Graph that will be used to execute the traversal. |
GraphTraversalSource |
withoutStrategies(Class<? extends TraversalStrategy>... traversalStrategyClasses)
Remove an arbitrary collection of
TraversalStrategy classes from the traversal source. |
GraphTraversalSource |
withPath() |
<A> GraphTraversalSource |
withSack(A initialValue)
Add a sack to be used throughout the life of a spawned
Traversal . |
<A> GraphTraversalSource |
withSack(A initialValue,
BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
<A> GraphTraversalSource |
withSack(A initialValue,
UnaryOperator<A> splitOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
<A> GraphTraversalSource |
withSack(A initialValue,
UnaryOperator<A> splitOperator,
BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
<A> GraphTraversalSource |
withSack(Supplier<A> initialValue)
Add a sack to be used throughout the life of a spawned
Traversal . |
<A> GraphTraversalSource |
withSack(Supplier<A> initialValue,
BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
<A> GraphTraversalSource |
withSack(Supplier<A> initialValue,
UnaryOperator<A> splitOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
<A> GraphTraversalSource |
withSack(Supplier<A> initialValue,
UnaryOperator<A> splitOperator,
BinaryOperator<A> mergeOperator)
Add a sack to be used throughout the life of a spawned
Traversal . |
<A> GraphTraversalSource |
withSideEffect(String key,
A initialValue)
Add a sideEffect to be used throughout the life of a spawned
Traversal . |
<A> GraphTraversalSource |
withSideEffect(String key,
A initialValue,
BinaryOperator<A> reducer)
Add a sideEffect to be used throughout the life of a spawned
Traversal . |
<A> GraphTraversalSource |
withSideEffect(String key,
Supplier<A> initialValue)
Add a sideEffect to be used throughout the life of a spawned
Traversal . |
<A> GraphTraversalSource |
withSideEffect(String key,
Supplier<A> initialValue,
BinaryOperator<A> reducer)
Add a sideEffect to be used throughout the life of a spawned
Traversal . |
GraphTraversalSource |
withStrategies(TraversalStrategy... traversalStrategies)
Add an arbitrary collection of
TraversalStrategy instances to the traversal source. |
protected transient RemoteConnection connection
protected final Graph graph
protected TraversalStrategies strategies
protected Bytecode bytecode
public GraphTraversalSource(Graph graph, TraversalStrategies traversalStrategies)
public GraphTraversalSource(Graph graph)
public GraphTraversalSource(RemoteConnection connection)
public Optional<Class<?>> getAnonymousTraversalClass()
getAnonymousTraversalClass
in interface TraversalSource
public TraversalStrategies getStrategies()
TraversalSource
TraversalStrategies
associated with this traversal source.getStrategies
in interface TraversalSource
public Graph getGraph()
TraversalSource
Graph
associated with this traversal source.getGraph
in interface TraversalSource
public Bytecode getBytecode()
TraversalSource
Bytecode
associated with the current state of this traversal source.getBytecode
in interface TraversalSource
public GraphTraversalSource clone()
TraversalSource
Bytecode
, TraversalStrategies
, mutate the cloned strategies accordingly,
and then return the cloned traversal source leaving the original unaltered.clone
in interface TraversalSource
clone
in class Object
public GraphTraversalSource with(String key)
with(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.with
in interface TraversalSource
key
- the key of the configuration to apply to a traversalpublic GraphTraversalSource with(String key, Object value)
OptionsStrategy
manually and then add with
TraversalSource.withStrategies(TraversalStrategy[])
.with
in interface TraversalSource
key
- the key of the configuration to apply to a traversalvalue
- the value of the configuration to apply to a traversalpublic GraphTraversalSource withStrategies(TraversalStrategy... traversalStrategies)
TraversalStrategy
instances to the traversal source.withStrategies
in interface TraversalSource
traversalStrategies
- a collection of traversal strategies to addpublic GraphTraversalSource withoutStrategies(Class<? extends TraversalStrategy>... traversalStrategyClasses)
TraversalStrategy
classes from the traversal source.withoutStrategies
in interface TraversalSource
traversalStrategyClasses
- a collection of traversal strategy classes to removepublic GraphTraversalSource 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.withComputer
in interface TraversalSource
computer
- a builder to generate a graph computer from the graphpublic GraphTraversalSource withComputer(Class<? extends GraphComputer> graphComputerClass)
GraphComputer
class used to execute the traversal.
This adds a VertexProgramStrategy
to the strategies.withComputer
in interface TraversalSource
graphComputerClass
- the graph computer classpublic GraphTraversalSource withComputer()
GraphComputer
of the graph that will be used to execute the traversal.
This adds a VertexProgramStrategy
to the strategies.withComputer
in interface TraversalSource
public <A> GraphTraversalSource withSideEffect(String key, Supplier<A> initialValue, BinaryOperator<A> reducer)
Traversal
.
This adds a SideEffectStrategy
to the strategies.withSideEffect
in interface TraversalSource
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 resultpublic <A> GraphTraversalSource withSideEffect(String key, A initialValue, BinaryOperator<A> reducer)
Traversal
.
This adds a SideEffectStrategy
to the strategies.withSideEffect
in interface TraversalSource
key
- the key of the sideEffectinitialValue
- the initial value of the sideEffectreducer
- a reducer to merge sideEffect mutations into a single resultpublic <A> GraphTraversalSource withSideEffect(String key, A initialValue)
Traversal
.
This adds a SideEffectStrategy
to the strategies.withSideEffect
in interface TraversalSource
key
- the key of the sideEffectinitialValue
- the initial value of the sideEffectpublic <A> GraphTraversalSource withSideEffect(String key, Supplier<A> initialValue)
Traversal
.
This adds a SideEffectStrategy
to the strategies.withSideEffect
in interface TraversalSource
key
- the key of the sideEffectinitialValue
- a supplier that produces the initial value of the sideEffectpublic <A> GraphTraversalSource withSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator)
Traversal
.
This adds a SackStrategy
to the strategies.withSack
in interface TraversalSource
initialValue
- a supplier that produces the initial value of the sideEffectsplitOperator
- the sack split operatormergeOperator
- the sack merge operatorpublic <A> GraphTraversalSource withSack(A initialValue, UnaryOperator<A> splitOperator, BinaryOperator<A> mergeOperator)
Traversal
.
This adds a SackStrategy
to the strategies.withSack
in interface TraversalSource
initialValue
- the initial value of the sideEffectsplitOperator
- the sack split operatormergeOperator
- the sack merge operatorpublic <A> GraphTraversalSource withSack(A initialValue)
Traversal
.
This adds a SackStrategy
to the strategies.withSack
in interface TraversalSource
initialValue
- the initial value of the sideEffectpublic <A> GraphTraversalSource withSack(Supplier<A> initialValue)
Traversal
.
This adds a SackStrategy
to the strategies.withSack
in interface TraversalSource
initialValue
- a supplier that produces the initial value of the sideEffectpublic <A> GraphTraversalSource withSack(Supplier<A> initialValue, UnaryOperator<A> splitOperator)
Traversal
.
This adds a SackStrategy
to the strategies.withSack
in interface TraversalSource
initialValue
- a supplier that produces the initial value of the sideEffectsplitOperator
- the sack split operatorpublic <A> GraphTraversalSource withSack(A initialValue, UnaryOperator<A> splitOperator)
Traversal
.
This adds a SackStrategy
to the strategies.withSack
in interface TraversalSource
initialValue
- the initial value of the sideEffectsplitOperator
- the sack split operatorpublic <A> GraphTraversalSource withSack(Supplier<A> initialValue, BinaryOperator<A> mergeOperator)
Traversal
.
This adds a SackStrategy
to the strategies.withSack
in interface TraversalSource
initialValue
- a supplier that produces the initial value of the sideEffectmergeOperator
- the sack merge operatorpublic <A> GraphTraversalSource withSack(A initialValue, BinaryOperator<A> mergeOperator)
Traversal
.
This adds a SackStrategy
to the strategies.withSack
in interface TraversalSource
initialValue
- the initial value of the sideEffectmergeOperator
- the sack merge operatorpublic GraphTraversalSource withBulk(boolean useBulk)
public GraphTraversalSource withPath()
public GraphTraversal<Vertex,Vertex> addV(String vertexLabel)
GraphTraversal
by adding a vertex with the specified label. If the label
is
null
then it will default to Vertex.DEFAULT_LABEL
.public GraphTraversal<Vertex,Vertex> addV(Traversal<?,String> vertexLabelTraversal)
GraphTraversal
by adding a vertex with the label as determined by a Traversal
. If the
vertexLabelTraversal
is null
then it will default to Vertex.DEFAULT_LABEL
.public GraphTraversal<Vertex,Vertex> addV()
GraphTraversal
by adding a vertex with the default label.public GraphTraversal<Edge,Edge> addE(String label)
GraphTraversal
by adding an edge with the specified label.public GraphTraversal<Edge,Edge> addE(Traversal<?,String> edgeLabelTraversal)
GraphTraversal
by adding a edge with a label as specified by the provided Traversal
.public GraphTraversal<Vertex,Vertex> mergeV(Map<Object,Object> searchCreate)
GraphTraversal
by doing a merge (i.e. upsert) style operation for an Vertex
using a
Map
as an argument. The Map
represents search criteria and will match each of the supplied
key/value pairs where the keys may be String
property values or a value of T
. If a match is not
made it will use that search criteria to create the new Vertex
.searchCreate
- This Map
can have a key of T
or a String
.public <S> GraphTraversal<S,Vertex> mergeV(Traversal<?,Map<Object,Object>> searchCreate)
GraphTraversal
by doing a merge (i.e. upsert) style operation for an Vertex
using a
Map
as an argument. The Map
represents search criteria and will match each of the supplied
key/value pairs where the keys may be String
property values or a value of T
. If a match is not
made it will use that search criteria to create the new Vertex
.public GraphTraversal<Edge,Edge> mergeE(Map<?,Object> searchCreate)
GraphTraversal
by doing a merge (i.e. upsert) style operation for an Edge
using a
Map
as an argument.public GraphTraversal<Edge,Edge> mergeE(Traversal<?,Map<Object,Object>> searchCreate)
GraphTraversal
by doing a merge (i.e. upsert) style operation for an Edge
using a
Map
as an argument.public <S> GraphTraversal<S,S> inject(S... starts)
GraphTraversal
starting it with arbitrary values.public GraphTraversal<Vertex,Vertex> V(Object... vertexIds)
GraphTraversal
starting with all vertices or some subset of vertices as specified by their
unique identifier.public GraphTraversal<Edge,Edge> E(Object... edgeIds)
GraphTraversal
starting with all edges or some subset of edges as specified by their unique
identifier.public <S> GraphTraversal<S,S> call()
GraphTraversal
starting with a list of available services.public <S> GraphTraversal<S,S> call(String service)
GraphTraversal
starting with values produced by the specified service call with no parameters.service
- the name of the service callpublic <S> GraphTraversal<S,S> call(String service, Map params)
GraphTraversal
starting with values produced by the specified service call with the specified
static parameters.service
- the name of the service callparams
- static parameter map (no nested traversals)public <S> GraphTraversal<S,S> call(String service, Traversal<S,Map> childTraversal)
GraphTraversal
starting with values produced by the specified service call with dynamic
parameters produced by the specified child traversal.service
- the name of the service callchildTraversal
- a traversal that will produce a Map of parameters for the service call when invoked.public <S> GraphTraversal<S,S> call(String service, Map params, Traversal<S,Map> childTraversal)
GraphTraversal
starting 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).service
- the name of the service callparams
- static parameter map (no nested traversals)childTraversal
- a traversal that will produce a Map of parameters for the service call when invoked.public <S> GraphTraversal<S,S> io(String file)
Graph
backing this GraphTraversalSource
. This
step can be accompanied by the GraphTraversal.with(String, Object)
modulator for further configuration
and must be accompanied by a GraphTraversal.read()
or GraphTraversal.write()
modulator step
which will terminate the traversal.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 implementationIoStep
addedpublic Transaction tx()
Graph.tx()
or to the RemoteConnection.tx()
.public void close() throws Exception
RemoteConnection
it will be closed by this method.close
in interface AutoCloseable
close
in interface TraversalSource
Exception
Copyright © 2013–2022 Apache Software Foundation. All rights reserved.