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/97141dab Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/97141dab Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/97141dab Branch: refs/heads/master Commit: 97141dab3ea3b187e1c1bd93bd12f8afa6a3b601 Parents: 3182a06 Author: Marko A. Rodriguez <okramma...@gmail.com> Authored: Fri Mar 17 13:04:58 2017 -0600 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Wed Mar 29 11:22:58 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/97141dab/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 926aa18..5731497 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. * Fixed a step id compilation bug in `AddVertexStartStep`, `AddVertexStep`, `AddEdgeStep`, and `AddPropertyStep`. * De-registered metrics on Gremlin Server shutdown. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/97141dab/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<>();