andreachild commented on code in PR #3209:
URL: https://github.com/apache/tinkerpop/pull/3209#discussion_r2370983854
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AbstractMergeElementStepPlaceholder.java:
##########
@@ -65,14 +67,67 @@ protected Traverser.Admin<E> processNextStart() throws
NoSuchElementException {
@Override
public AbstractMergeElementStepPlaceholder<S, E> clone() {
- return (AbstractMergeElementStepPlaceholder<S, E>) super.clone();
+ AbstractMergeElementStepPlaceholder<S, E> clone =
(AbstractMergeElementStepPlaceholder<S, E>) super.clone();
+ if (mergeTraversal != null){
+ clone.setMerge(mergeTraversal.clone());
+ }
+ if (onMatchTraversal != null) {
+ clone.setOnMatch(onMatchTraversal.clone());
+ }
+ if (onCreateTraversal != null) {
+ clone.setOnCreate(onCreateTraversal.clone());
+ }
+
+ // deep clone properties
+ clone.properties = new HashMap<>();
+ for (Map.Entry<Object, List<Object>> entry :
this.properties.entrySet()) {
+ final Object key = entry.getKey();
+ final List<Object> oldValues = entry.getValue();
+ final List<Object> newValues = new ArrayList<>(oldValues.size());
+ for (Object v : oldValues) {
+ if (v instanceof Traversal) {
+ newValues.add(((Traversal<?, ?>) v).asAdmin().clone());
+ } else if (v instanceof GValue) {
+ try {
+ newValues.add(((GValue) v).clone());
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ newValues.add(v);
+ }
+ }
+ clone.properties.put(key, newValues);
+ }
+ return clone;
}
@Override
public Set<TraverserRequirement> getRequirements() {
return super.getRequirements();
}
+ @Override
+ public void setTraversal(final Traversal.Admin<?, ?> parentTraversal) {
+ super.setTraversal(parentTraversal);
+ this.getLocalChildren().forEach(this::integrateChild);
Review Comment:
Can you clarify why `setTraversal` needs to call `integrateChild` but the
constructor which calls `super(traversal)` does not need to call
`integrateChild`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]