CTR: Fixed strategy lifecycle issues caused by `PathRetractionStrategy`. Fix 
taken from `tp33/`.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/8a76583c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/8a76583c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/8a76583c

Branch: refs/heads/TINKERPOP-1897
Commit: 8a76583c9e783e15b4cdf0167e6b32940a525c00
Parents: 373eba1
Author: Daniel Kuppitz <daniel_kupp...@hotmail.com>
Authored: Thu Mar 22 08:30:40 2018 -0700
Committer: Daniel Kuppitz <daniel_kupp...@hotmail.com>
Committed: Thu Mar 22 08:30:40 2018 -0700

----------------------------------------------------------------------
 .../strategy/decoration/SubgraphStrategy.java          | 13 +++++++++++++
 .../optimization/IncidentToAdjacentStrategy.java       | 12 +++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8a76583c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategy.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategy.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategy.java
index e0d260f..508e9c6 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategy.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategy.java
@@ -43,6 +43,7 @@ import 
org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep;
 import 
org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
 import 
org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
+import 
org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
 import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 import org.apache.tinkerpop.gremlin.structure.Direction;
@@ -148,6 +149,18 @@ public final class SubgraphStrategy extends 
AbstractTraversalStrategy<TraversalS
             traversal.getStartStep().removeLabel(MARKER);
             return;
         }
+        for (final Step step : traversal.getSteps()) {
+            if (step instanceof TraversalParent) {
+                for (final Traversal.Admin t : ((TraversalParent) 
step).getLocalChildren()) {
+                    this.apply(t);
+                    t.getStartStep().addLabel(MARKER);
+                }
+                for (final Traversal.Admin t : ((TraversalParent) 
step).getGlobalChildren()) {
+                    this.apply(t);
+                    t.getStartStep().addLabel(MARKER);
+                }
+            }
+        }
         //
         final List<GraphStep> graphSteps = 
TraversalHelper.getStepsOfAssignableClass(GraphStep.class, traversal);
         final List<VertexStep> vertexSteps = 
TraversalHelper.getStepsOfAssignableClass(VertexStep.class, traversal);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8a76583c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategy.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategy.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategy.java
index 1c96cf8..8389112 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategy.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategy.java
@@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder;
+import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
 import 
org.apache.tinkerpop.gremlin.process.traversal.step.filter.PathFilterStep;
 import 
org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeOtherVertexStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeVertexStep;
@@ -132,6 +133,10 @@ public final class IncidentToAdjacentStrategy extends 
AbstractTraversalStrategy<
         final Collection<Pair<VertexStep, Step>> stepsToReplace = new 
ArrayList<>();
         Step prev = null;
         for (final Step curr : traversal.getSteps()) {
+            if (curr instanceof TraversalParent) {
+                ((TraversalParent) 
curr).getLocalChildren().forEach(this::apply);
+                ((TraversalParent) 
curr).getGlobalChildren().forEach(this::apply);
+            }
             if (isOptimizable(prev, curr)) {
                 stepsToReplace.add(Pair.with((VertexStep) prev, curr));
             }
@@ -148,4 +153,9 @@ public final class IncidentToAdjacentStrategy extends 
AbstractTraversalStrategy<
     public Set<Class<? extends OptimizationStrategy>> applyPrior() {
         return Collections.singleton(IdentityRemovalStrategy.class);
     }
-}
+
+    @Override
+    public Set<Class<? extends OptimizationStrategy>> applyPost() {
+        return Collections.singleton(PathRetractionStrategy.class);
+    }
+}
\ No newline at end of file

Reply via email to