Interface Step<S,E>
- Type Parameters:
S- The incoming object type of the stepE- The outgoing object type of the step
- All Superinterfaces:
Cloneable,Iterator<Traverser.Admin<E>>,Serializable
A
Step denotes a unit of computation within a Traversal.
A step takes an incoming object and yields an outgoing object.
Steps are chained together in a Traversal to yield a lazy function chain of computation.
In the constructor of a Step, never store explicit sideEffect objects in TraversalSideEffects.
If a sideEffect needs to be registered with the Traversal, use SideEffects.registerSupplier().-
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a label to this step.voidaddStart(Traverser.Admin<S> start) Add a singleTraverser.Adminto the step.voidaddStarts(Iterator<Traverser.Admin<S>> starts) Add an iterator ofTraverser.Adminobjects of type S to the step.voidRemoves all labels on the step.clone()Cloning is used to duplicate steps for the purpose of traversal optimization and OLTP replication.default booleanCompare the current step with another step.getId()Get the unique id of this step.Get the labels of this step.Get the next step to the current step.Get the step prior to the current step.default Set<org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement>Provide the necessaryTraverserRequirementthat must be met by the traverser in order for the step to function properly.<A,B> Traversal.Admin<A, B> Get theTraversal.Adminthat this step is contained within.booleanDetermines if starts objects are present without iterating forward.voidremoveLabel(String label) Remove a label from this step.voidreset()Reset the state of the step such that it has no incoming starts.voidGet the unique id of the step.voidsetNextStep(Step<E, ?> step) Set the step that is next to the current step.voidsetPreviousStep(Step<?, S> step) Set the step that is previous to the current step.voidsetTraversal(Traversal.Admin<?, ?> traversal) Set theTraversalthat this step is contained within.Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
addStarts
Add an iterator ofTraverser.Adminobjects of type S to the step.- Parameters:
starts- The iterator of objects to add
-
addStart
Add a singleTraverser.Adminto the step.- Parameters:
start- The traverser to add
-
hasStarts
boolean hasStarts()Determines if starts objects are present without iterating forward. This function has special applicability aroundReducingBarrierStepimplementations where they always returntruefor calls toIterator.hasNext(). Using this function gives insight to what the step itself is holding in its iterator without performing any sort of processing on the step itself. -
setPreviousStep
Set the step that is previous to the current step. Used for linking steps together to form a function chain.- Parameters:
step- the previous step of this step
-
getPreviousStep
Get the step prior to the current step.- Returns:
- The previous step
-
setNextStep
Set the step that is next to the current step. Used for linking steps together to form a function chain.- Parameters:
step- the next step of this step
-
getNextStep
Get the next step to the current step.- Returns:
- The next step
-
getTraversal
Get theTraversal.Adminthat this step is contained within.- Type Parameters:
A- The incoming object type of the traversalB- The outgoing object type of the traversal- Returns:
- The traversal of this step
-
setTraversal
Set theTraversalthat this step is contained within.- Parameters:
traversal- the new traversal for this step
-
reset
void reset()Reset the state of the step such that it has no incoming starts. Internal states are to be reset, but any sideEffect data structures are not to be recreated. -
clone
Cloning is used to duplicate steps for the purpose of traversal optimization and OLTP replication. When cloning a step, it is important that the steps, the cloned step is equivalent to the state of the step whenreset()is called. Moreover, the previous and next steps should be set toEmptyStep.- Returns:
- The cloned step
-
getLabels
Get the labels of this step. The labels are ordered by the order of the calls toaddLabel(java.lang.String).- Returns:
- the set of labels for this step
-
addLabel
Add a label to this step.- Parameters:
label- the label to add to this step
-
removeLabel
Remove a label from this step.- Parameters:
label- the label to remove from this step
-
clearLabels
void clearLabels()Removes all labels on the step. -
setId
Get the unique id of the step. These ids can change when strategies are applied and anonymous traversals are embedded in the parent traversal. A developer should typically not need to call this method.- Parameters:
id- the unique id of the step
-
getId
String getId()Get the unique id of this step.- Returns:
- the unique id of the step
-
getRequirements
default Set<org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement> getRequirements()Provide the necessaryTraverserRequirementthat must be met by the traverser in order for the step to function properly. The provided default implements returns an empty set.- Returns:
- the set of requirements
-
equals
Compare the current step with another step.- Parameters:
other- the other stepcompareIds- whether to compare step IDs or not- Returns:
- true if the steps are equal, otherwise false
-