public interface Traversal<S,E>
extends java.util.Iterator<E>, java.lang.Cloneable
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: TraversalEngine.STANDARD (OLTP) and TraversalEngine.COMPUTER (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. |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
OF
Used for reflection based access to the static "of" method of a Traversal.
|
| Modifier and Type | Method and Description |
|---|---|
Traversal.Admin<S,E> |
asAdmin()
Get access to administrative methods of the traversal via its accompanying
Traversal.Admin. |
Traversal<S,E> |
clone()
Cloning is used to duplicate the traversal typically in OLAP environments.
|
default <C extends java.util.Collection<E>> |
fill(C collection)
Add all the results of the traversal to the provided collection.
|
default <E2> void |
forEachRemaining(java.lang.Class<E2> endType,
java.util.function.Consumer<E2> consumer)
A traversal can be rewritten such that its defined end type E may yield objects of a different type.
|
default <A,B> Traversal<A,B> |
iterate()
Iterate all the
Traverser instances in the traversal. |
default java.util.List<E> |
next(int amount)
Get the next n-number of results from the traversal.
|
default Traversal<S,E> |
submit(GraphComputer computer)
Submit the traversal to a
GraphComputer for OLAP execution. |
default BulkSet<E> |
toBulkSet()
Put all the results into a
BulkSet. |
default java.util.List<E> |
toList()
Put all the results into an
ArrayList. |
default java.util.Set<E> |
toSet()
Put all the results into a
HashSet. |
default java.util.Optional<E> |
tryNext()
Return an
Optional of the next E object in the traversal. |
static final java.lang.String OF
Traversal.Admin<S,E> asAdmin()
Traversal.Admin.default Traversal<S,E> submit(GraphComputer computer)
GraphComputer for OLAP execution.
This method should apply the traversal strategies for TraversalEngine.COMPUTER.
Then register and execute the traversal via TraversalVertexProgram.
Then wrap the ComputerResult in a new Traversal containing a ComputerResultStep.computer - the GraphComputer to execute the traversal ondefault java.util.Optional<E> tryNext()
Optional of the next E object in the traversal.
If the traversal is empty, then an Optional.empty() is returned.default java.util.List<E> next(int amount)
amount - the number of results to getListdefault java.util.List<E> toList()
ArrayList.default java.util.Set<E> toSet()
HashSet.default BulkSet<E> toBulkSet()
BulkSet.
This can reduce both time and space when aggregating results by ensuring a weighted set.default <C extends java.util.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 <E2> void forEachRemaining(java.lang.Class<E2> endType,
java.util.function.Consumer<E2> consumer)
E2 - the known output type of the traversalendType - the true output type of the traversalconsumer - a Consumer to process each outputCopyright © 2013-2015 TinkerPop. All Rights Reserved.