added MARKER model to PathRetractionStrategy to reduce recurssive lookups of 
invalidating steps. Again, we really need Traversal.metdata to make this more 
'pure'.


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

Branch: refs/heads/TINKERPOP-1642
Commit: 3929a6748e3b54692c0d103319965dd0d47ba3e1
Parents: d39ef5c
Author: Marko A. Rodriguez <[email protected]>
Authored: Fri Mar 17 13:04:58 2017 -0600
Committer: Stephen Mallette <[email protected]>
Committed: Mon Mar 27 12:00:20 2017 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                   |  3 ++-
 .../optimization/PathRetractionStrategy.java         | 15 +++++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3929a674/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 2636f98..9736dc5 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,7 +26,8 @@ 
image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-* `ProfileStrategy` now uses the marker-model to reduce recrussive lookups of 
`ProfileSideEffectStep`.
+* `PathRetractionStrategy` now uses the marker-model to reduce recursive 
lookups of invalidating steps.
+* `ProfileStrategy` now uses the marker-model to reduce recursive lookups of 
`ProfileSideEffectStep`.
 * `Mutating` steps now implement `Scoping` interface.
 * De-registered metrics on Gremlin Server shutdown.
 * Added "help" command option on `:remote config` for plugins that support 
that feature in the Gremlin Console.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3929a674/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java
index 56f9f66..443e4e3 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategy.java
@@ -37,6 +37,7 @@ import 
org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversal
 import 
org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
 import org.apache.tinkerpop.gremlin.process.traversal.util.PathUtil;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
+import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.javatuples.Pair;
 
 import java.util.ArrayList;
@@ -58,6 +59,7 @@ public final class PathRetractionStrategy extends 
AbstractTraversalStrategy<Trav
     // these strategies do strong rewrites involving path labeling and thus, 
should run prior to PathRetractionStrategy
     private static final Set<Class<? extends OptimizationStrategy>> PRIORS = 
new HashSet<>(Arrays.asList(
             RepeatUnrollStrategy.class, MatchPredicateStrategy.class, 
PathProcessorStrategy.class));
+    private static final String MARKER = 
Graph.Hidden.hide("gremlin.pathRetraction");
 
     private final int standardBarrierSize;
 
@@ -74,11 +76,16 @@ public final class PathRetractionStrategy extends 
AbstractTraversalStrategy<Trav
         // do not apply this strategy if there are lambdas as you can't 
introspect to know what path information the lambdas are using
         // do not apply this strategy if a PATH requirement step is being used 
(in the future, we can do PATH requirement lookhead to be more intelligent 
about its usage)
         // do not apply this strategy if a VertexProgramStep is present with 
LABELED_PATH requirements
-        if (TraversalHelper.anyStepRecursively(step -> step instanceof 
LambdaHolder ||
-                        
step.getRequirements().contains(TraverserRequirement.PATH) ||
-                        (step instanceof VertexProgramStep && 
step.getRequirements().contains(TraverserRequirement.LABELED_PATH)),
-                TraversalHelper.getRootTraversal(traversal)))
+        if ((traversal.getParent() instanceof EmptyStep || 
traversal.getParent() instanceof VertexProgramStep) &&
+                TraversalHelper.anyStepRecursively(step -> step instanceof 
LambdaHolder ||
+                                                   
step.getRequirements().contains(TraverserRequirement.PATH) ||
+                                                   (step instanceof 
VertexProgramStep && 
step.getRequirements().contains(TraverserRequirement.LABELED_PATH)),traversal))
+            TraversalHelper.applyTraversalRecursively(t -> 
t.getEndStep().addLabel(MARKER), traversal);
+
+        if (traversal.getEndStep().getLabels().contains(MARKER)) {
+            traversal.getEndStep().removeLabel(MARKER);
             return;
+        }
 
         final boolean onGraphComputer = 
TraversalHelper.onGraphComputer(traversal);
         final Set<String> foundLabels = new HashSet<>();

Reply via email to