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
public interface Step<S,E> extends Iterator<Traverser.Admin<E>>, Serializable, Cloneable
AStepdenotes a unit of computation within aTraversal. A step takes an incoming object and yields an outgoing object. Steps are chained together in aTraversalto yield a lazy function chain of computation. In the constructor of a Step, never store explicit sideEffect objects inTraversalSideEffects. If a sideEffect needs to be registered with theTraversal, use SideEffects.registerSupplier().
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddLabel(String label)Add 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.voidclearLabels()Removes all labels on the step.Step<S,E>clone()Cloning is used to duplicate steps for the purpose of traversal optimization and OLTP replication.default booleanequals(Step other, boolean compareIds)Compare the current step with another step.StringgetId()Get the unique id of this step.Set<String>getLabels()Get the labels of this step.Step<E,?>getNextStep()Get the next step to the current step.Step<?,S>getPreviousStep()Get the step prior to the current step.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.<A,B>
Traversal.Admin<A,B>getTraversal()Get theTraversal.Adminthat this step is contained within.booleanhasStarts()Determines 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.voidsetId(String id)Get 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 Detail
-
addStarts
void addStarts(Iterator<Traverser.Admin<S>> starts)
Add an iterator ofTraverser.Adminobjects of type S to the step.- Parameters:
starts- The iterator of objects to add
-
addStart
void addStart(Traverser.Admin<S> start)
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
void setPreviousStep(Step<?,S> step)
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
Step<?,S> getPreviousStep()
Get the step prior to the current step.- Returns:
- The previous step
-
setNextStep
void setNextStep(Step<E,?> step)
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
-
getTraversal
<A,B> Traversal.Admin<A,B> 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
void setTraversal(Traversal.Admin<?,?> traversal)
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
Step<S,E> 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
Set<String> 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
void addLabel(String label)
Add a label to this step.- Parameters:
label- the label to add to this step
-
removeLabel
void removeLabel(String label)
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
void setId(String id)
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
default boolean equals(Step other, boolean compareIds)
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
-
-