Repository: tinkerpop
Updated Branches:
  refs/heads/TRAVIS-TEST 9f289d989 -> b67196298 (forced update)


CTR: Implemented `Traversal::invalidateTraverserRequirements`.

This was necessary to allow traversal-mutating strategies (e.g. 
`SubgraphStrategy`) to invalidate the already cached traverser requirements.

foo

foo

foo


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

Branch: refs/heads/TRAVIS-TEST
Commit: b67196298361b5225387f2ca339c54dee9a292ec
Parents: 6e0ccd8
Author: Daniel Kuppitz <daniel_kupp...@hotmail.com>
Authored: Tue Mar 13 11:33:06 2018 -0700
Committer: Daniel Kuppitz <daniel_kupp...@hotmail.com>
Committed: Tue Mar 13 13:11:12 2018 -0700

----------------------------------------------------------------------
 .../remote/traversal/AbstractRemoteTraversal.java        |  5 +++++
 .../tinkerpop/gremlin/process/traversal/Traversal.java   |  7 +++++++
 .../traversal/lambda/AbstractLambdaTraversal.java        |  7 +++++++
 .../traversal/strategy/decoration/SubgraphStrategy.java  | 11 ++++++++++-
 .../gremlin/process/traversal/util/DefaultTraversal.java |  5 +++++
 5 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b6719629/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/AbstractRemoteTraversal.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/AbstractRemoteTraversal.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/AbstractRemoteTraversal.java
index 0c6a7aa..480d1fc 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/AbstractRemoteTraversal.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/AbstractRemoteTraversal.java
@@ -88,6 +88,11 @@ public abstract class AbstractRemoteTraversal<S,E> 
implements RemoteTraversal<S,
     }
 
     @Override
+    public void invalidateTraverserRequirements() {
+        throw new UnsupportedOperationException("Remote traversals do not 
support this method");
+    }
+
+    @Override
     public void setSideEffects(final TraversalSideEffects sideEffects) {
         throw new UnsupportedOperationException("Remote traversals do not 
support this method");
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b6719629/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
index 220c995..7a6ddce 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traversal.java
@@ -426,6 +426,13 @@ public interface Traversal<S, E> extends Iterator<E>, 
Serializable, Cloneable, A
         public Set<TraverserRequirement> getTraverserRequirements();
 
         /**
+         * Invalidates the set of all {@link TraverserRequirement}s for this 
traversal.
+         */
+        public default void invalidateTraverserRequirements() {
+
+        };
+
+        /**
          * Call the {@link Step#reset} method on every step in the traversal.
          */
         public default void reset() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b6719629/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/AbstractLambdaTraversal.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/AbstractLambdaTraversal.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/AbstractLambdaTraversal.java
index 8f910a0..84e1896 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/AbstractLambdaTraversal.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/AbstractLambdaTraversal.java
@@ -184,6 +184,13 @@ public abstract class AbstractLambdaTraversal<S, E> 
implements Traversal.Admin<S
     }
 
     @Override
+    public void invalidateTraverserRequirements() {
+        if (null != this.bypassTraversal) {
+            this.bypassTraversal.invalidateTraverserRequirements();
+        }
+    }
+
+    @Override
     public int hashCode() {
         return null == this.bypassTraversal ? this.getClass().hashCode() : 
this.bypassTraversal.hashCode();
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b6719629/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..7968363 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;
@@ -170,6 +171,7 @@ public final class SubgraphStrategy extends 
AbstractTraversalStrategy<TraversalS
         }
 
         // turn g.V().out() to g.V().outE().inV() only if there is an edge 
predicate otherwise
+        boolean invalidateTraverserRequirements = false;
         for (final VertexStep<?> step : vertexSteps) {
             if (step.returnsEdge())
                 continue;
@@ -177,7 +179,8 @@ public final class SubgraphStrategy extends 
AbstractTraversalStrategy<TraversalS
                 TraversalHelper.insertAfterStep(new 
TraversalFilterStep<>(traversal, (Traversal) this.vertexCriterion.clone()), 
step, traversal);
             } else {
                 final VertexStep<Edge> someEStep = new VertexStep<>(traversal, 
Edge.class, step.getDirection(), step.getEdgeLabels());
-                final Step<Edge, Vertex> someVStep = step.getDirection() == 
Direction.BOTH ?
+                final boolean addsPathRequirement;
+                final Step<Edge, Vertex> someVStep = (addsPathRequirement = 
step.getDirection() == Direction.BOTH) ?
                         new EdgeOtherVertexStep(traversal) :
                         new EdgeVertexStep(traversal, 
step.getDirection().opposite());
 
@@ -189,9 +192,15 @@ public final class SubgraphStrategy extends 
AbstractTraversalStrategy<TraversalS
                     TraversalHelper.insertAfterStep(new 
TraversalFilterStep<>(traversal, this.edgeCriterion.clone()), someEStep, 
traversal);
                 if (null != this.vertexCriterion)
                     TraversalHelper.insertAfterStep(new 
TraversalFilterStep<>(traversal, this.vertexCriterion.clone()), someVStep, 
traversal);
+
+                invalidateTraverserRequirements |= addsPathRequirement;
             }
         }
 
+        if (invalidateTraverserRequirements) {
+            traversal.invalidateTraverserRequirements();
+        }
+
         // turn g.V().properties() to g.V().properties().xxx
         // turn g.V().values() to g.V().properties().xxx.value()
         if (null != this.vertexPropertyCriterion) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b6719629/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
index 585a82b..57c271b 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
@@ -166,6 +166,11 @@ public class DefaultTraversal<S, E> implements 
Traversal.Admin<S, E> {
     }
 
     @Override
+    public void invalidateTraverserRequirements() {
+        this.requirements = null;
+    }
+
+    @Override
     public List<Step> getSteps() {
         return this.unmodifiableSteps;
     }

Reply via email to