Class GraphTraversalSource

  • All Implemented Interfaces:
    AutoCloseable, Cloneable, TraversalSource

    public class GraphTraversalSource
    extends Object
    implements TraversalSource
    A 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.
    Author:
    Marko A. Rodriguez (http://markorodriguez.com), Stephen Mallette (http://stephen.genoprime.com)
    • Field Detail

      • connection

        protected transient org.apache.tinkerpop.gremlin.process.remote.RemoteConnection connection
      • graph

        protected final Graph graph
    • Constructor Detail

      • GraphTraversalSource

        public GraphTraversalSource​(Graph graph)
      • GraphTraversalSource

        public GraphTraversalSource​(org.apache.tinkerpop.gremlin.process.remote.RemoteConnection connection)
    • Method Detail

      • clone

        public GraphTraversalSource clone()
        Description copied from interface: TraversalSource
        The clone-method should be used to create immutable traversal sources with each call to a configuration "withXXX"-method. The clone-method should clone the Bytecode, TraversalStrategies, mutate the cloned strategies accordingly, and then return the cloned traversal source leaving the original unaltered.
        Specified by:
        clone in interface TraversalSource
        Overrides:
        clone in class Object
        Returns:
        the cloned traversal source
      • with

        public GraphTraversalSource with​(String key)
        Provides a configuration to a traversal in the form of a key which is the same as 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.
        Specified by:
        with in interface TraversalSource
        Parameters:
        key - the key of the configuration to apply to a traversal
        Returns:
        a new traversal source with the included configuration
      • with

        public 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 an OptionsStrategy manually and then add with TraversalSource.withStrategies(TraversalStrategy[]).
        Specified by:
        with in 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
      • withComputer

        public GraphTraversalSource withComputer​(Computer computer)
        Add a Computer that will generate a GraphComputer from the Graph that will be used to execute the traversal. This adds a VertexProgramStrategy to the strategies.
        Specified by:
        withComputer in interface TraversalSource
        Parameters:
        computer - a builder to generate a graph computer from the graph
        Returns:
        a new traversal source with updated strategies
      • withComputer

        public GraphTraversalSource withComputer​(Class<? extends GraphComputer> graphComputerClass)
        Add a GraphComputer class used to execute the traversal. This adds a VertexProgramStrategy to the strategies.
        Specified by:
        withComputer in interface TraversalSource
        Parameters:
        graphComputerClass - the graph computer class
        Returns:
        a new traversal source with updated strategies
      • withComputer

        public GraphTraversalSource withComputer()
        Add the standard GraphComputer of the graph that will be used to execute the traversal. This adds a VertexProgramStrategy to the strategies.
        Specified by:
        withComputer in interface TraversalSource
        Returns:
        a new traversal source with updated strategies
      • withSideEffect

        public <A> GraphTraversalSource withSideEffect​(String key,
                                                       Supplier<A> initialValue,
                                                       BinaryOperator<A> reducer)
        Add a sideEffect to be used throughout the life of a spawned Traversal. This adds a SideEffectStrategy to the strategies.
        Specified by:
        withSideEffect in 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
      • withSideEffect

        public <A> GraphTraversalSource withSideEffect​(String key,
                                                       A initialValue,
                                                       BinaryOperator<A> reducer)
        Add a sideEffect to be used throughout the life of a spawned Traversal. This adds a SideEffectStrategy to the strategies.
        Specified by:
        withSideEffect in 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
      • withSideEffect

        public <A> GraphTraversalSource withSideEffect​(String key,
                                                       A initialValue)
        Add a sideEffect to be used throughout the life of a spawned Traversal. This adds a SideEffectStrategy to the strategies.
        Specified by:
        withSideEffect in interface TraversalSource
        Parameters:
        key - the key of the sideEffect
        initialValue - the initial value of the sideEffect
        Returns:
        a new traversal source with updated strategies
      • withSideEffect

        public <A> GraphTraversalSource withSideEffect​(String key,
                                                       Supplier<A> initialValue)
        Add a sideEffect to be used throughout the life of a spawned Traversal. This adds a SideEffectStrategy to the strategies.
        Specified by:
        withSideEffect in 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
      • withSack

        public <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. This adds a SackStrategy to the strategies.
        Specified by:
        withSack in 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
      • withSack

        public <A> GraphTraversalSource withSack​(A initialValue,
                                                 UnaryOperator<A> splitOperator,
                                                 BinaryOperator<A> mergeOperator)
        Add a sack to be used throughout the life of a spawned Traversal. This adds a SackStrategy to the strategies.
        Specified by:
        withSack in 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
      • withSack

        public <A> GraphTraversalSource withSack​(A initialValue)
        Add a sack to be used throughout the life of a spawned Traversal. This adds a SackStrategy to the strategies.
        Specified by:
        withSack in interface TraversalSource
        Parameters:
        initialValue - the initial value of the sideEffect
        Returns:
        a new traversal source with updated strategies
      • withSack

        public <A> GraphTraversalSource withSack​(Supplier<A> initialValue)
        Add a sack to be used throughout the life of a spawned Traversal. This adds a SackStrategy to the strategies.
        Specified by:
        withSack in interface TraversalSource
        Parameters:
        initialValue - a supplier that produces the initial value of the sideEffect
        Returns:
        a new traversal source with updated strategies
      • withSack

        public <A> GraphTraversalSource withSack​(Supplier<A> initialValue,
                                                 UnaryOperator<A> splitOperator)
        Add a sack to be used throughout the life of a spawned Traversal. This adds a SackStrategy to the strategies.
        Specified by:
        withSack in 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
      • withSack

        public <A> GraphTraversalSource withSack​(A initialValue,
                                                 UnaryOperator<A> splitOperator)
        Add a sack to be used throughout the life of a spawned Traversal. This adds a SackStrategy to the strategies.
        Specified by:
        withSack in interface TraversalSource
        Parameters:
        initialValue - the initial value of the sideEffect
        splitOperator - the sack split operator
        Returns:
        a new traversal source with updated strategies
      • withSack

        public <A> GraphTraversalSource withSack​(Supplier<A> initialValue,
                                                 BinaryOperator<A> mergeOperator)
        Add a sack to be used throughout the life of a spawned Traversal. This adds a SackStrategy to the strategies.
        Specified by:
        withSack in 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
      • withSack

        public <A> GraphTraversalSource withSack​(A initialValue,
                                                 BinaryOperator<A> mergeOperator)
        Add a sack to be used throughout the life of a spawned Traversal. This adds a SackStrategy to the strategies.
        Specified by:
        withSack in interface TraversalSource
        Parameters:
        initialValue - the initial value of the sideEffect
        mergeOperator - the sack merge operator
        Returns:
        a new traversal source with updated strategies
      • tx

        public Transaction tx()
        Proxies calls through to the underlying Graph.tx() or to the RemoteConnection.tx().