General steps, step-modulators, and predicates
TinkerPop general steps, step-modulators, and predicates
Apache TinkerPopTM has five general step types:
-
map(Traversal<S,E>) or map(Function<Traverser<S>, E>)
Maps the traverser to some object of type
E
for the next step to process. -
flatMap(Traversal<S,E>) or flatMap(Function<Traverser<S>, Iterator<E>)
Maps the traverser to an iterator of
E
objects that are streamed to the next step. -
filter(Traversal<?, ?>) or filter(Predicate<Traverser<S>>)
Maps the traverser to either true or false, and where false will not pass the traverser to the next step.
-
sideEffect(Traversal<S, S>) or sideEffect(Consumer<Traverser<S>>)
Performs some operation on the traverser and passes it to the next step.
-
branch(Traversal<S, M>) or branch(Function<Traverser<S>, M>)
Splits the traverser to all the traversals indexed by the
M
token.
All other steps in the reference can be categorized as one of these steps or a variant, such as a terminal
step that completes a traversal.
In addition, steps have step-modulators
, a helper step that assists a step:
-
as()
Provide a label to the step that can later be accessed by steps and data structures that make use of such labels.
-
by()
If a step is able to accept traversals, functions, or comparators, then
by()
is the means by which they are added. -
emit()
If
emit()
is placed afterrepeat()
, it is evaluated on the traversers leaving the repeat-traversal. Ifemit()
is placed beforerepeat()
, it is evaluated on the traversers prior to entering the repeat-traversal. -
from()
Adds a string or traversal to a traversal to point the traversal FROM the next supplied step.
-
option()
Provide a option to a branch() or choose() step.
-
to()
Adds a string or traversal to a traversal to point the traversal TO the next supplied step.
-
until()
If
until()
comes afterrepeat()
it is do/while looping. Ifuntil()
comes beforerepeat()
it is while/do looping.
Within steps, predicates are used to determine relationships between data:
-
eq(object)
Check if an incoming object is equal to the provided object.
-
neq(object)
Check if an incoming object is not equal to the provided object.
-
lt(number)
Check if an incoming number is less than the provided number.
-
lte(number)
Check if an incoming number is less than or equal the provided number.
-
gt(number)
Check if an incoming number is greater than the provided number.
-
gte(number)
Check if an incoming number is greater than or equal the provided number.
-
inside(number, number)
Check if an incoming number is inside the range of the provided numbers.
-
outside(number, number)
Check if an incoming number is outside the range of the provided numbers.
-
between(number, number)
Check if an incoming number is greater than or equal to the first provided number and less than the second provided number.
-
within(objects…)
Check if an incoming object is within an array of provided objects.
-
without(objects…)
Check if an incoming object is not within an array of provided objects.