tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject tinkerpop git commit: Made IncidentToAdjacentStrategy skip all traversals that contain steps with a `PATH` requirement. [Forced Update!]
Date Fri, 11 Nov 2016 02:06:09 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1545 0aa410c7a -> 50e0fa97a (forced update)


Made IncidentToAdjacentStrategy skip all traversals that contain steps with a `PATH` requirement.


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

Branch: refs/heads/TINKERPOP-1545
Commit: 50e0fa97aa81ffd856033e776d348c4cbe7eea4f
Parents: 1e554ca
Author: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Authored: Fri Nov 11 00:00:03 2016 +0100
Committer: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Committed: Fri Nov 11 03:05:23 2016 +0100

----------------------------------------------------------------------
 .../strategy/optimization/IncidentToAdjacentStrategy.java   | 9 +++------
 .../optimization/IncidentToAdjacentStrategyTest.java        | 2 ++
 2 files changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/50e0fa97/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 712110d4..71aeda9 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
@@ -24,19 +24,17 @@ 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.map.EdgeOtherVertexStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeVertexStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.PathStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep;
 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.TraversalHelper;
 import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.javatuples.Pair;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.Set;
 
 /**
@@ -63,7 +61,6 @@ public final class IncidentToAdjacentStrategy extends AbstractTraversalStrategy<
         implements TraversalStrategy.OptimizationStrategy {
 
     private static final IncidentToAdjacentStrategy INSTANCE = new IncidentToAdjacentStrategy();
-    private static final Set<Class> INVALIDATING_STEP_CLASSES = new HashSet<>(Arrays.asList(PathStep.class,
LambdaHolder.class));
 
     private IncidentToAdjacentStrategy() {
     }
@@ -71,8 +68,8 @@ public final class IncidentToAdjacentStrategy extends AbstractTraversalStrategy<
     @Override
     public void apply(Traversal.Admin<?, ?> traversal) {
         final Traversal.Admin root = TraversalHelper.getRootTraversal(traversal);
-        if (TraversalHelper.hasStepOfAssignableClassRecursively(INVALIDATING_STEP_CLASSES,
root))
-            return;
+        if (TraversalHelper.anyStepRecursively(s -> s instanceof LambdaHolder
+                || s.getRequirements().contains(TraverserRequirement.PATH), root) return;
         final Collection<Pair<VertexStep, Step>> stepsToReplace = new ArrayList<>();
         Step prev = null;
         for (final Step curr : traversal.getSteps()) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/50e0fa97/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategyTest.java
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategyTest.java
index 45f583e..3207dc3 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/IncidentToAdjacentStrategyTest.java
@@ -129,6 +129,8 @@ public class IncidentToAdjacentStrategyTest {
                     {__.bothE().outV(), __.bothE().outV()},
                     {__.outE().as("a").inV(), __.outE().as("a").inV()}, // todo: this can
be optimized, but requires a lot more checks
                     {__.outE().inV().path(), __.outE().inV().path()},
+                    {__.outE().inV().simplePath(), __.outE().inV().simplePath()},
+                    {__.outE().inV().tree(), __.outE().inV().tree()},
                     {__.outE().inV().map(lambda), __.outE().inV().map(lambda)},
                     {__.union(__.outE().inV(), __.inE().outV()).path(), __.union(__.outE().inV(),
__.inE().outV()).path()},
                     {__.as("a").outE().inV().as("b"), __.as("a").out().as("b")}});


Mime
View raw message