Interface Traversal<S,E>
- All Superinterfaces:
AutoCloseable,Cloneable,Iterator<E>,Serializable
- All Known Subinterfaces:
GraphTraversal<S,,E> GraphTraversal.Admin<S,,E> Traversal.Admin<S,E>
A
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).- Author:
- Marko A. Rodriguez (http://markorodriguez.com)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic classA collection ofExceptiontypes associated with Traversal execution.static class -
Method Summary
Modifier and TypeMethodDescriptiondefault Traversal.Admin<S,E> asAdmin()Get access to administrative methods of the traversal via its accompanyingTraversal.Admin.default voidclose()Releases resources opened in any steps that implementAutoCloseable.discard()Filter all traversers in the traversal.default org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanationexplain()Return aTraversalExplanationthat shows how this traversal will mutate with each appliedTraversalStrategy.default <C extends Collection<E>>
Cfill(C collection) Add all the results of the traversal to the provided collection.default <E2> voidforEachRemaining(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 voidforEachRemaining(Consumer<? super E> action) default <A,B> Traversal<A, B> iterate()Iterate all theTraverserinstances in the traversal.next(int amount) Get the next n-number of results from the traversal.default voidprofile()Profile the traversal.default <T> CompletableFuture<T>Starts a promise to execute a function on the currentTraversalthat will be completed in the future.default org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet<E>Put all the results into aBulkSet.toList()Put all the results into anArrayList.toSet()Put all the results into aHashSet.toStream()Return the traversal as aStream.tryNext()Return anOptionalof the next E object in the traversal.
-
Method Details
-
asAdmin
Get access to administrative methods of the traversal via its accompanyingTraversal.Admin.- Returns:
- the admin of this traversal
-
tryNext
Return anOptionalof the next E object in the traversal. If the traversal is empty, then anOptional.empty()is returned.- Returns:
- an optional of the next object in the traversal
-
next
Get the next n-number of results from the traversal. If the traversal has less than n-results, then only that number of results are returned.- Parameters:
amount- the number of results to get- Returns:
- the n-results in a
List
-
toList
Put all the results into anArrayList.- Returns:
- the results in a list
-
toSet
Put all the results into aHashSet.- Returns:
- the results in a set
-
toBulkSet
Put all the results into aBulkSet. This can reduce both time and space when aggregating results by ensuring a weighted set.- Returns:
- the results in a bulk set
-
toStream
Return the traversal as aStream.- Returns:
- the traversal as a stream.
-
promise
Starts a promise to execute a function on the currentTraversalthat will be completed in the future. Note that this method can only be used if theTraversalis constructed usingAnonymousTraversalSource.withRemote(Configuration). Calling this method otherwise will yield anIllegalStateException. -
fill
Add all the results of the traversal to the provided collection.- Parameters:
collection- the collection to fill- Returns:
- the collection now filled
-
iterate
Iterate all theTraverserinstances 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.- Returns:
- the fully drained traversal
-
discard
Filter all traversers in the traversal. Formerly namednone()prior to 3.8.0.- Since:
- 3.8.0
- See Also:
-
profile
Profile the traversal.- Returns:
- the updated traversal with respective
ProfileSideEffectStep.
-
explain
default org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation explain()Return aTraversalExplanationthat shows how this traversal will mutate with each appliedTraversalStrategy.- Returns:
- a traversal explanation
-
forEachRemaining
A traversal can be rewritten such that its defined end type E may yield objects of a different type. This helper method allows for the casting of the output to the known the type.- Type Parameters:
E2- the known output type of the traversal- Parameters:
endType- the true output type of the traversalconsumer- aConsumerto process each output
-
forEachRemaining
- Specified by:
forEachRemainingin interfaceIterator<S>
-
close
Releases resources opened in any steps that implementAutoCloseable. If this method is overridden,the implementer should invokenotifyClose().- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
notifyClose
default void notifyClose()
-