public interface Traversal<S,E> extends Iterator<E>, Serializable, Cloneable, AutoCloseable
Traversal
represents a directed walk over a Graph
.
This is the base interface for all traversal's, where each extending interface is seen as a domain specific language.
For example, GraphTraversal
is a domain specific language for traversing a graph using "graph concepts" (e.g. vertices, edges).
Another example may represent the graph using "social concepts" (e.g. people, cities, artifacts).
A Traversal
is evaluated in one of two ways: iterator-based OLTP or GraphComputer
-based OLAP.
OLTP traversals leverage an iterator and are executed within a single JVM (with data access allowed to be remote).
OLAP traversals leverage GraphComputer
and are executed between multiple JVMs (and/or cores).Modifier and Type | Interface and Description |
---|---|
static interface |
Traversal.Admin<S,E> |
static class |
Traversal.Exceptions
A collection of
Exception types associated with Traversal execution. |
static class |
Traversal.Symbols |
Modifier and Type | Method and Description |
---|---|
default Traversal.Admin<S,E> |
asAdmin()
Get access to administrative methods of the traversal via its accompanying
Traversal.Admin . |
default void |
close()
Releases resources opened in any steps that implement
AutoCloseable . |
default org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation |
explain()
Return a
TraversalExplanation that shows how this traversal will mutate with each applied TraversalStrategy . |
default <C extends Collection<E>> |
fill(C collection)
Add all the results of the traversal to the provided collection.
|
default <E2> void |
forEachRemaining(Class<E2> endType,
Consumer<E2> consumer)
A traversal can be rewritten such that its defined end type E may yield objects of a different type.
|
default void |
forEachRemaining(Consumer<? super E> action) |
default <A,B> Traversal<A,B> |
iterate()
Iterate all the
Traverser instances in the traversal. |
default List<E> |
next(int amount)
Get the next n-number of results from the traversal.
|
default Traversal<S,E> |
none()
Filter all traversers in the traversal.
|
default Traversal<S,org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics> |
profile()
Profile the traversal.
|
default <T> CompletableFuture<T> |
promise(Function<Traversal<S,E>,T> traversalFunction)
Starts a promise to execute a function on the current
Traversal that will be completed in the future. |
default org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet<E> |
toBulkSet()
Put all the results into a
BulkSet . |
default List<E> |
toList()
Put all the results into an
ArrayList . |
default Set<E> |
toSet()
Put all the results into a
HashSet . |
default Stream<E> |
toStream()
Return the traversal as a
Stream . |
default Optional<E> |
tryNext()
Return an
Optional of the next E object in the traversal. |
default Traversal.Admin<S,E> asAdmin()
Traversal.Admin
.default Optional<E> tryNext()
Optional
of the next E object in the traversal.
If the traversal is empty, then an Optional.empty()
is returned.default List<E> next(int amount)
amount
- the number of results to getList
default List<E> toList()
ArrayList
.default org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet<E> toBulkSet()
BulkSet
.
This can reduce both time and space when aggregating results by ensuring a weighted set.default Stream<E> toStream()
Stream
.default <T> CompletableFuture<T> promise(Function<Traversal<S,E>,T> traversalFunction)
Traversal
that will be completed in the future.
Note that this method can only be used if the Traversal
is constructed using
TraversalSource.withRemote(Configuration)
. Calling this method otherwise will yield an
IllegalStateException
.default <C extends Collection<E>> C fill(C collection)
collection
- the collection to filldefault <A,B> Traversal<A,B> iterate()
Traverser
instances in the traversal.
What is returned is the empty traversal.
It is assumed that what is desired from the computation is are the sideEffects yielded by the traversal.default Traversal<S,E> none()
NoneStep
.default Traversal<S,org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics> profile()
ProfileSideEffectStep
.default org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation explain()
TraversalExplanation
that shows how this traversal will mutate with each applied TraversalStrategy
.default <E2> void forEachRemaining(Class<E2> endType, Consumer<E2> consumer)
E2
- the known output type of the traversalendType
- the true output type of the traversalconsumer
- a Consumer
to process each outputdefault void forEachRemaining(Consumer<? super E> action)
forEachRemaining
in interface Iterator<E>
default void close() throws Exception
AutoCloseable
.close
in interface AutoCloseable
Exception
Copyright © 2013–2018 Apache Software Foundation. All rights reserved.