Class MergeStep<S,E,C>
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep<S,E>
-
- org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep<S,E>
-
- org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeStep<S,E,C>
-
- All Implemented Interfaces:
Serializable
,AutoCloseable
,Cloneable
,Iterator<Traverser.Admin<E>>
,Step<S,E>
,Configuring
,Deleting<Event>
,Mutating<Event>
,Parameterizing
,TraversalOptionParent<Merge,S,C>
,TraversalParent
,Writing<Event>
- Direct Known Subclasses:
MergeEdgeStep
,MergeVertexStep
public abstract class MergeStep<S,E,C> extends FlatMapStep<S,E> implements Writing<Event>, Deleting<Event>, TraversalOptionParent<Merge,S,C>
Abstract base class for themergeV/E()
implementations.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected CallbackRegistry<Event>
callbackRegistry
protected boolean
first
protected boolean
isStart
protected Traversal.Admin<S,Map>
mergeTraversal
protected Traversal.Admin<S,Map>
onCreateTraversal
protected Traversal.Admin<S,Map<String,?>>
onMatchTraversal
-
Fields inherited from class org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep
id, labels, nextEnd, nextStep, previousStep, starts, traversal, traverserStepIdAndLabelsSetByChild
-
-
Constructor Summary
Constructors Constructor Description MergeStep(Traversal.Admin traversal, boolean isStart)
MergeStep(Traversal.Admin traversal, boolean isStart, Map mergeMap)
MergeStep(Traversal.Admin traversal, boolean isStart, Traversal.Admin mergeTraversal)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addChildOption(Merge token, Traversal.Admin<S,C> traversalOption)
MergeStep<S,E,C>
clone()
Cloning is used to duplicate steps for the purpose of traversal optimization and OLTP replication.void
configure(Object... keyValues)
This implementation should only be used as a mechanism for supportingPartitionStrategy
.protected abstract Iterator<E>
flatMap(Traverser.Admin<S> traverser)
protected abstract Set
getAllowedTokens()
CallbackRegistry<Event>
getCallbackRegistry()
protected Graph
getGraph()
<S,C>
List<Traversal.Admin<S,C>>getLocalChildren()
Traversal.Admin<S,Map>
getMergeTraversal()
Gets the traversal that will be used to provide theMap
that will be used to search for elements.CallbackRegistry<Event>
getMutatingCallbackRegistry()
Gets the callback registry for events that the step raises.Traversal.Admin<S,Map>
getOnCreateTraversal()
Gets the traversal that will be used to provide theMap
that will be used to create elements that do not match the search criteria ofgetMergeTraversal()
.Traversal.Admin<S,Map<String,?>>
getOnMatchTraversal()
Gets the traversal that will be used to provide theMap
that will be used to modify elements that match the search criteria ofgetMergeTraversal()
.Parameters
getParameters()
Gets the parameters on the step.Set<TraverserRequirement>
getRequirements()
Provide the necessaryTraverserRequirement
that must be met by the traverser in order for the step to function properly.int
hashCode()
boolean
isFirst()
Determine if this is the first pass throughprocessNextStart()
.boolean
isStart()
Determines if this is a start step.protected Map
materializeMap(Traverser.Admin<S> traverser, Traversal.Admin<S,?> mapTraversal)
null Map == empty Mapprotected Traverser.Admin<E>
processNextStart()
void
reset()
Reset the state of the step such that it has no incoming starts.protected CloseableIterator<Vertex>
searchVertices(Map search)
Translate the Map into a g.V() traversal against the supplied graph.protected GraphTraversal
searchVerticesLabelConstraint(GraphTraversal t, String label)
protected GraphTraversal
searchVerticesPropertyConstraints(GraphTraversal t, Map search)
protected GraphTraversal
searchVerticesTraversal(Graph graph, Object id)
void
setTraversal(Traversal.Admin<?,?> parentTraversal)
Set theTraversal
that this step is contained within.String
toString()
protected void
validate(Map map, boolean ignoreTokens)
protected static void
validate(Map map, boolean ignoreTokens, Set allowedTokens, String op)
protected void
validateNoOverrides(Map<?,?> mergeMap, Map<?,?> onCreateMap)
Prohibit overrides to the existence criteria (id/label/from/to) in onCreate.-
Methods inherited from class org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep
closeIterator
-
Methods inherited from class org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep
addLabel, addStart, addStarts, equals, getId, getLabels, getNextStep, getPreviousStep, getStarts, getTraversal, hasNext, hasStarts, isTraverserStepIdAndLabelsSetByChild, next, prepareTraversalForNextStep, removeLabel, setId, setNextStep, setPreviousStep
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Methods inherited from interface org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent
addGlobalChild, addLocalChild, asStep, close, getGlobalChildren, getSelfAndChildRequirements, integrateChild, removeGlobalChild, removeLocalChild, replaceLocalChild
-
-
-
-
Field Detail
-
isStart
protected final boolean isStart
-
first
protected boolean first
-
mergeTraversal
protected Traversal.Admin<S,Map> mergeTraversal
-
onCreateTraversal
protected Traversal.Admin<S,Map> onCreateTraversal
-
onMatchTraversal
protected Traversal.Admin<S,Map<String,?>> onMatchTraversal
-
callbackRegistry
protected CallbackRegistry<Event> callbackRegistry
-
-
Constructor Detail
-
MergeStep
public MergeStep(Traversal.Admin traversal, boolean isStart)
-
MergeStep
public MergeStep(Traversal.Admin traversal, boolean isStart, Map mergeMap)
-
MergeStep
public MergeStep(Traversal.Admin traversal, boolean isStart, Traversal.Admin mergeTraversal)
-
-
Method Detail
-
getMergeTraversal
public Traversal.Admin<S,Map> getMergeTraversal()
Gets the traversal that will be used to provide theMap
that will be used to search for elements. ThisMap
also will be used as the default data set to be used to create the element if the search is not successful.
-
getOnCreateTraversal
public Traversal.Admin<S,Map> getOnCreateTraversal()
Gets the traversal that will be used to provide theMap
that will be used to create elements that do not match the search criteria ofgetMergeTraversal()
.
-
getOnMatchTraversal
public Traversal.Admin<S,Map<String,?>> getOnMatchTraversal()
Gets the traversal that will be used to provide theMap
that will be used to modify elements that match the search criteria ofgetMergeTraversal()
.
-
isStart
public boolean isStart()
Determines if this is a start step.
-
isFirst
public boolean isFirst()
Determine if this is the first pass throughprocessNextStart()
.
-
getCallbackRegistry
public CallbackRegistry<Event> getCallbackRegistry()
-
addChildOption
public void addChildOption(Merge token, Traversal.Admin<S,C> traversalOption)
Description copied from interface:TraversalOptionParent
The child as defined by the token it takes, likePick
orMerge
. This traversal may be of local or global scope depending on the step implementation that works withoption()
.- Specified by:
addChildOption
in interfaceTraversalOptionParent<S,E,C>
-
getLocalChildren
public <S,C> List<Traversal.Admin<S,C>> getLocalChildren()
- Specified by:
getLocalChildren
in interfaceTraversalParent
-
configure
public void configure(Object... keyValues)
This implementation should only be used as a mechanism for supportingPartitionStrategy
. Using this withGraphTraversal.with(String,Object)
will have an ill effect of simply acting like a call toGraphTraversal.property(Object, Object, Object...)
. No mutating steps currently support use ofGraphTraversal.with(String,Object)
so perhaps it's best to not start with that now.- Specified by:
configure
in interfaceConfiguring
-
getParameters
public Parameters getParameters()
Description copied from interface:Parameterizing
Gets the parameters on the step.- Specified by:
getParameters
in interfaceParameterizing
-
processNextStart
protected Traverser.Admin<E> processNextStart()
- Overrides:
processNextStart
in classFlatMapStep<S,E>
-
getGraph
protected Graph getGraph()
-
getMutatingCallbackRegistry
public CallbackRegistry<Event> getMutatingCallbackRegistry()
Description copied from interface:Mutating
Gets the callback registry for events that the step raises.- Specified by:
getMutatingCallbackRegistry
in interfaceMutating<S>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractStep<S,E>
-
reset
public void reset()
Description copied from interface:Step
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.
-
getRequirements
public Set<TraverserRequirement> getRequirements()
Description copied from interface:Step
Provide the necessaryTraverserRequirement
that must be met by the traverser in order for the step to function properly. The provided default implements returns an empty set.- Specified by:
getRequirements
in interfaceStep<S,E>
- Returns:
- the set of requirements
-
toString
public String toString()
- Overrides:
toString
in classAbstractStep<S,E>
-
setTraversal
public void setTraversal(Traversal.Admin<?,?> parentTraversal)
Description copied from interface:Step
Set theTraversal
that this step is contained within.- Specified by:
setTraversal
in interfaceStep<S,E>
- Overrides:
setTraversal
in classAbstractStep<S,E>
- Parameters:
parentTraversal
- the new traversal for this step
-
clone
public MergeStep<S,E,C> clone()
Description copied from interface:Step
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 whenStep.reset()
is called. Moreover, the previous and next steps should be set toEmptyStep
.
-
validate
protected void validate(Map map, boolean ignoreTokens)
-
validate
protected static void validate(Map map, boolean ignoreTokens, Set allowedTokens, String op)
-
validateNoOverrides
protected void validateNoOverrides(Map<?,?> mergeMap, Map<?,?> onCreateMap)
Prohibit overrides to the existence criteria (id/label/from/to) in onCreate.
-
materializeMap
protected Map materializeMap(Traverser.Admin<S> traverser, Traversal.Admin<S,?> mapTraversal)
null Map == empty Map
-
searchVertices
protected CloseableIterator<Vertex> searchVertices(Map search)
Translate the Map into a g.V() traversal against the supplied graph. Graph providers will presumably optimize this traversal to use whatever indices are present and appropriate for efficiency. Callers are responsible for closing this iterator when finished.
-
searchVerticesTraversal
protected GraphTraversal searchVerticesTraversal(Graph graph, Object id)
-
searchVerticesLabelConstraint
protected GraphTraversal searchVerticesLabelConstraint(GraphTraversal t, String label)
-
searchVerticesPropertyConstraints
protected GraphTraversal searchVerticesPropertyConstraints(GraphTraversal t, Map search)
-
flatMap
protected abstract Iterator<E> flatMap(Traverser.Admin<S> traverser)
- Specified by:
flatMap
in classFlatMapStep<S,E>
-
getAllowedTokens
protected abstract Set getAllowedTokens()
-
-