Class DefaultTraversal<S,E>
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal<S,E>
-
- All Implemented Interfaces:
Serializable,AutoCloseable,Cloneable,Iterator<E>,Traversal<S,E>,Traversal.Admin<S,E>
- Direct Known Subclasses:
DefaultCredentialTraversal,DefaultGraphTraversal,ScriptTraversal
public class DefaultTraversal<S,E> extends Object implements Traversal.Admin<S,E>
- Author:
- Marko A. Rodriguez (http://markorodriguez.com)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.process.traversal.Traversal
Traversal.Admin<S,E>, Traversal.Exceptions, Traversal.Symbols
-
-
Field Summary
Fields Modifier and Type Field Description protected Bytecodebytecodeprotected booleanclosedprotected TraversalSourcegprotected TraverserGeneratorgeneratorprotected Graphgraphprotected booleanlockedprotected TraversalParentparentprotected Set<TraverserRequirement>requirementsprotected TraversalSideEffectssideEffectsprotected List<Step>stepsprotected TraversalStrategiesstrategiesprotected List<Step>unmodifiableSteps
-
Constructor Summary
Constructors Constructor Description DefaultTraversal()DefaultTraversal(Bytecode bytecode)DefaultTraversal(TraversalSource traversalSource)DefaultTraversal(TraversalSource traversalSource, Traversal.Admin<S,E> traversal)DefaultTraversal(Graph graph)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddStart(Traverser.Admin<S> start)Add a singleTraverser.Adminobject to the head of the traversal.voidaddStarts(Iterator<Traverser.Admin<S>> starts)Add an iterator ofTraverser.Adminobjects to the head/start of the traversal.<S2,E2>
Traversal.Admin<S2,E2>addStep(int index, Step<?,?> step)Add aStepto an arbitrary point in the traversal.voidapplyStrategies()Apply the registeredTraversalStrategiesto the traversal.Traversal.Admin<S,E>asAdmin()Get access to administrative methods of the traversal via its accompanyingTraversal.Admin.DefaultTraversal<S,E>clone()Cloning is used to duplicate the traversal typically in OLAP environments.booleanequals(Object other)BytecodegetBytecode()Get theBytecodeassociated with the construction of this traversal.Step<?,E>getEndStep()Get the end/tail of the traversal.Optional<Graph>getGraph()TraversalParentgetParent()Get theTraversalParentStepthat is the parent of this traversal.TraversalSideEffectsgetSideEffects()Get theTraversalSideEffectsassociated with the traversal.Step<S,?>getStartStep()Get the start/head of the traversal.List<Step>getSteps()Get theStepinstances associated with this traversal.TraversalStrategiesgetStrategies()Get theTraversalStrategiesassociated with this traversal.Optional<TraversalSource>getTraversalSource()Gets theTraversalSourcethat spawned theTraversalinstance initially if present.TraverserGeneratorgetTraverserGenerator()Get theTraverserGeneratorassociated with this traversal.Set<TraverserRequirement>getTraverserRequirements()Get the set of allTraverserRequirements for this traversal.inthashCode()booleanhasNext()booleanisClosed()Determines if the traversal has been fully iterated and resources released.booleanisLocked()When the traversal has had itsTraversalStrategiesapplied to it, it is locked.voidlock()Lock the traversal and perform any final adjustments to it after strategy application.Enext()Traverser.Admin<E>nextTraverser()voidnotifyClose()Gets a callback fromTraversal.close()for additional operations specific to theTraversalimplementation.<S2,E2>
Traversal.Admin<S2,E2>removeStep(int index)Remove aStepfrom the traversal.voidreset()Call theStep.reset()method on every step in the traversal.voidsetGraph(Graph graph)voidsetLocked(boolean locked)Allow the locked property of the traversal to be directly set by those who know what they are doing.voidsetParent(TraversalParent step)Set theTraversalParentStepthat is the parent of this traversal.voidsetSideEffects(TraversalSideEffects sideEffects)Set theTraversalSideEffectsof this traversal.voidsetStrategies(TraversalStrategies strategies)Set theTraversalStrategiesto be used by this traversal at evaluation time.StringtoString()-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.tinkerpop.gremlin.process.traversal.Traversal
close, explain, fill, forEachRemaining, forEachRemaining, iterate, next, none, profile, promise, toBulkSet, toList, toSet, toStream, tryNext
-
Methods inherited from interface org.apache.tinkerpop.gremlin.process.traversal.Traversal.Admin
addStep, equals, getTraverserSetSupplier, isRoot, removeStep
-
-
-
-
Field Detail
-
graph
protected transient Graph graph
-
g
protected transient TraversalSource g
-
parent
protected TraversalParent parent
-
sideEffects
protected TraversalSideEffects sideEffects
-
strategies
protected TraversalStrategies strategies
-
generator
protected transient TraverserGenerator generator
-
requirements
protected Set<TraverserRequirement> requirements
-
locked
protected boolean locked
-
closed
protected boolean closed
-
bytecode
protected Bytecode bytecode
-
-
Constructor Detail
-
DefaultTraversal
public DefaultTraversal(Graph graph)
-
DefaultTraversal
public DefaultTraversal(TraversalSource traversalSource)
-
DefaultTraversal
public DefaultTraversal(TraversalSource traversalSource, Traversal.Admin<S,E> traversal)
-
DefaultTraversal
public DefaultTraversal()
-
DefaultTraversal
public DefaultTraversal(Bytecode bytecode)
-
-
Method Detail
-
getBytecode
public Bytecode getBytecode()
Description copied from interface:Traversal.AdminGet theBytecodeassociated with the construction of this traversal.- Specified by:
getBytecodein interfaceTraversal.Admin<S,E>- Returns:
- the byte code representation of the traversal
-
asAdmin
public Traversal.Admin<S,E> asAdmin()
Description copied from interface:TraversalGet access to administrative methods of the traversal via its accompanyingTraversal.Admin.
-
getTraverserGenerator
public TraverserGenerator getTraverserGenerator()
Description copied from interface:Traversal.AdminGet theTraverserGeneratorassociated with this traversal. The traversal generator createsTraverserinstances that are respective of the traversal'sTraverserRequirement.- Specified by:
getTraverserGeneratorin interfaceTraversal.Admin<S,E>- Returns:
- the generator of traversers
-
applyStrategies
public void applyStrategies() throws IllegalStateExceptionDescription copied from interface:Traversal.AdminApply the registeredTraversalStrategiesto the traversal. Once the strategies are applied, the traversal is "locked" and can no longer have steps added to it. The order of operations for strategy applications should be: globally id steps, apply each strategy in turn to root traversal, then recursively to nested traversals.- Specified by:
applyStrategiesin interfaceTraversal.Admin<S,E>- Throws:
IllegalStateException- if theTraversalStrategieshave already been applied
-
getTraverserRequirements
public Set<TraverserRequirement> getTraverserRequirements()
Description copied from interface:Traversal.AdminGet the set of allTraverserRequirements for this traversal.- Specified by:
getTraverserRequirementsin interfaceTraversal.Admin<S,E>- Returns:
- the features of a traverser that are required to execute properly in this traversal
-
getSteps
public List<Step> getSteps()
Description copied from interface:Traversal.AdminGet theStepinstances associated with this traversal. The steps are ordered according to their linked list structure as defined byStep.getPreviousStep()andStep.getNextStep().- Specified by:
getStepsin interfaceTraversal.Admin<S,E>- Returns:
- the ordered steps of the traversal
-
nextTraverser
public Traverser.Admin<E> nextTraverser()
- Specified by:
nextTraverserin interfaceTraversal.Admin<S,E>
-
reset
public void reset()
Description copied from interface:Traversal.AdminCall theStep.reset()method on every step in the traversal.- Specified by:
resetin interfaceTraversal.Admin<S,E>
-
addStart
public void addStart(Traverser.Admin<S> start)
Description copied from interface:Traversal.AdminAdd a singleTraverser.Adminobject to the head of the traversal. Users should typically not need to call this method. For dynamic inject of data, they should useInjectStep.- Specified by:
addStartin interfaceTraversal.Admin<S,E>- Parameters:
start- a traverser to add to the traversal
-
addStarts
public void addStarts(Iterator<Traverser.Admin<S>> starts)
Description copied from interface:Traversal.AdminAdd an iterator ofTraverser.Adminobjects to the head/start of the traversal. Users should typically not need to call this method. For dynamic inject of data, they should useInjectStep.- Specified by:
addStartsin interfaceTraversal.Admin<S,E>- Parameters:
starts- an iterators of traversers
-
getStartStep
public Step<S,?> getStartStep()
Description copied from interface:Traversal.AdminGet the start/head of the traversal. If the traversal is empty, then anEmptyStepinstance is returned.- Specified by:
getStartStepin interfaceTraversal.Admin<S,E>- Returns:
- the start step of the traversal
-
getEndStep
public Step<?,E> getEndStep()
Description copied from interface:Traversal.AdminGet the end/tail of the traversal. If the traversal is empty, then anEmptyStepinstance is returned.- Specified by:
getEndStepin interfaceTraversal.Admin<S,E>- Returns:
- the end step of the traversal
-
clone
public DefaultTraversal<S,E> clone()
Description copied from interface:Traversal.AdminCloning is used to duplicate the traversal typically in OLAP environments.
-
isLocked
public boolean isLocked()
Description copied from interface:Traversal.AdminWhen the traversal has had itsTraversalStrategiesapplied to it, it is locked.- Specified by:
isLockedin interfaceTraversal.Admin<S,E>- Returns:
- whether the traversal is locked
-
setLocked
public void setLocked(boolean locked)
Allow the locked property of the traversal to be directly set by those who know what they are doing. Are you sure you know what you're doing?
-
lock
public void lock()
Description copied from interface:Traversal.AdminLock the traversal and perform any final adjustments to it after strategy application.- Specified by:
lockin interfaceTraversal.Admin<S,E>
-
isClosed
public boolean isClosed()
Determines if the traversal has been fully iterated and resources released.
-
notifyClose
public void notifyClose()
Description copied from interface:TraversalGets a callback fromTraversal.close()for additional operations specific to theTraversalimplementation. A good implementation will useTraversal.close()to release resources in steps and this method to release resources specific to theTraversalimplementations.- Specified by:
notifyClosein interfaceTraversal<S,E>
-
setSideEffects
public void setSideEffects(TraversalSideEffects sideEffects)
Description copied from interface:Traversal.AdminSet theTraversalSideEffectsof this traversal.- Specified by:
setSideEffectsin interfaceTraversal.Admin<S,E>- Parameters:
sideEffects- the sideEffects to set for this traversal.
-
getSideEffects
public TraversalSideEffects getSideEffects()
Description copied from interface:Traversal.AdminGet theTraversalSideEffectsassociated with the traversal. This method should not be called externally for purposes of retrieving side-effects as traversal results. Traversal results should only be returned by way of the execution of the traversal itself. Should a side-effect of a traversal be needed it should only be obtained by usingGraphTraversal.cap(String, String...)so that the side-effect can be included as part of the traversal iteration. Relying on this method to get side-effects in these situations may not result in consistent behavior across all types of executions and environments (e.g. remoting).- Specified by:
getSideEffectsin interfaceTraversal.Admin<S,E>- Returns:
- The traversal sideEffects
-
setStrategies
public void setStrategies(TraversalStrategies strategies)
Description copied from interface:Traversal.AdminSet theTraversalStrategiesto be used by this traversal at evaluation time.- Specified by:
setStrategiesin interfaceTraversal.Admin<S,E>- Parameters:
strategies- the strategies to use on this traversal
-
getStrategies
public TraversalStrategies getStrategies()
Description copied from interface:Traversal.AdminGet theTraversalStrategiesassociated with this traversal.- Specified by:
getStrategiesin interfaceTraversal.Admin<S,E>- Returns:
- the strategies associated with this traversal
-
addStep
public <S2,E2> Traversal.Admin<S2,E2> addStep(int index, Step<?,?> step) throws IllegalStateException
Description copied from interface:Traversal.AdminAdd aStepto an arbitrary point in the traversal.- Specified by:
addStepin interfaceTraversal.Admin<S,E>- Type Parameters:
S2- the new start type of the traversal (if the added step was a start step)E2- the new end type of the traversal (if the added step was an end step)- Parameters:
index- the location in the traversal to insert the stepstep- the step to add- Returns:
- the newly modulated traversal
- Throws:
IllegalStateException- if theTraversalStrategieshave already been applied
-
removeStep
public <S2,E2> Traversal.Admin<S2,E2> removeStep(int index) throws IllegalStateException
Description copied from interface:Traversal.AdminRemove aStepfrom the traversal.- Specified by:
removeStepin interfaceTraversal.Admin<S,E>- Type Parameters:
S2- the new start type of the traversal (if the removed step was a start step)E2- the new end type of the traversal (if the removed step was an end step)- Parameters:
index- the location in the traversal of the step to be evicted- Returns:
- the newly modulated traversal
- Throws:
IllegalStateException- if theTraversalStrategieshave already been applied
-
setParent
public void setParent(TraversalParent step)
Description copied from interface:Traversal.AdminSet theTraversalParentStepthat is the parent of this traversal. Traversals can be nested and this is the means by which the traversal tree is connected. If there is no parent, then it should be aEmptyStep.- Specified by:
setParentin interfaceTraversal.Admin<S,E>- Parameters:
step- the traversal holder parent step orEmptyStepif it has no parent
-
getParent
public TraversalParent getParent()
Description copied from interface:Traversal.AdminGet theTraversalParentStepthat is the parent of this traversal. Traversals can be nested and this is the means by which the traversal tree is walked.- Specified by:
getParentin interfaceTraversal.Admin<S,E>- Returns:
- the traversal holder parent step or
EmptyStepif it has no parent.
-
getGraph
public Optional<Graph> getGraph()
Description copied from interface:Traversal.Admin- Specified by:
getGraphin interfaceTraversal.Admin<S,E>
-
getTraversalSource
public Optional<TraversalSource> getTraversalSource()
Description copied from interface:Traversal.AdminGets theTraversalSourcethat spawned theTraversalinstance initially if present. ThisTraversalSourceshould have spawned from the associatedGraphreturned fromTraversal.Admin.getGraph().- Specified by:
getTraversalSourcein interfaceTraversal.Admin<S,E>
-
setGraph
public void setGraph(Graph graph)
- Specified by:
setGraphin interfaceTraversal.Admin<S,E>
-
-