You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by tw...@apache.org on 2017/03/16 20:43:34 UTC
tinkerpop git commit: TINKERPOP-1652 Disable PathRetractionStrategy
strategy if VertexProgramStep has LABELLED_PATH requirement [Forced Update!]
Repository: tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1652 a5e3c4f33 -> aa2881e94 (forced update)
TINKERPOP-1652 Disable PathRetractionStrategy strategy if VertexProgramStep has LABELLED_PATH requirement
If traversal has a VertexProgramStep with a LABELED_PATH, PathRetractionStrategy is not run.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/aa2881e9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/aa2881e9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/aa2881e9
Branch: refs/heads/TINKERPOP-1652
Commit: aa2881e94252aad5f157b1ae734101dbffa8fcfa
Parents: 3821792
Author: Ted Wilmes <tw...@gmail.com>
Authored: Thu Mar 16 09:23:29 2017 -0500
Committer: Ted Wilmes <tw...@gmail.com>
Committed: Thu Mar 16 15:39:51 2017 -0500
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../optimization/PathRetractionStrategy.java | 7 ++++++-
.../PathRetractionStrategyTest.java | 20 +++++++++++++++++++-
3 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aa2881e9/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index a77991e..a84c27b 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Updated PathRetractionStrategy to not run if the provided traversal contains a VertexProgramStep that has a LABELED_PATH requirement.
* Added various metrics to the `GremlinGroovyScriptEngine` around script compilation and exposed them in Gremlin Server.
* Moved the `caffeine` dependency down to `gremlin-groovy` and out of `gremlin-server`.
* Improved script compilation in `GremlinGroovyScriptEngine to use better caching, log long compile times and prevent failed compilations from recompiling on future requests.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aa2881e9/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 bd27a3e..b690c27 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
@@ -18,6 +18,7 @@
*/
package org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
import org.apache.tinkerpop.gremlin.process.traversal.Step;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
@@ -72,7 +73,11 @@ public final class PathRetractionStrategy extends AbstractTraversalStrategy<Trav
public void apply(final Traversal.Admin<?, ?> traversal) {
// 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)
- if (TraversalHelper.anyStepRecursively(step -> step instanceof LambdaHolder || step.getRequirements().contains(TraverserRequirement.PATH), TraversalHelper.getRootTraversal(traversal)))
+ // do not apply this strategy if a VertexProgramStep is present with LABELLED_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)))
return;
final boolean onGraphComputer = TraversalHelper.onGraphComputer(traversal);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aa2881e9/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategyTest.java
index 2a87f47..df8b949 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/PathRetractionStrategyTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization;
+import org.apache.tinkerpop.gremlin.process.computer.VertexProgram;
import org.apache.tinkerpop.gremlin.process.traversal.Order;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.Scope;
@@ -27,13 +28,17 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor;
import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.mockito.internal.util.collections.Sets;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -52,6 +57,8 @@ import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.values
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.where;
import static org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathRetractionStrategy.MAX_BARRIER_SIZE;
import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
/**
* @author Ted Wilmes (http://twilmes.org)
@@ -114,6 +121,14 @@ public class PathRetractionStrategyTest {
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> generateTestParameters() {
+ final VertexProgram labeledPathVertexProgram = mock(VertexProgram.class);
+ final VertexProgram pathVertexProgram = mock(VertexProgram.class);
+ final VertexProgram emptyRequirementsVertexProgram = mock(VertexProgram.class);
+
+ when(labeledPathVertexProgram.getTraverserRequirements()).thenReturn(Sets.newSet(TraverserRequirement.LABELED_PATH));
+ when(pathVertexProgram.getTraverserRequirements()).thenReturn(Sets.newSet(TraverserRequirement.PATH));
+ when(emptyRequirementsVertexProgram.getTraverserRequirements()).thenReturn(Collections.EMPTY_SET);
+
return Arrays.asList(new Object[][]{
{out(), "[]", null},
{__.V().as("a").out().as("b").where(neq("a")).out(), "[[]]", null},
@@ -191,6 +206,9 @@ public class PathRetractionStrategyTest {
{__.V().as("a").optional(bothE().dedup().as("b")).
choose(select("b"), select("a","b"), project("a").by(select("a"))),
"[[[a, b]], [[a, b]], [[a, b]], [[[a, b]]], [[a, b]]]", null},
+ {__.V().as("a").out().program(labeledPathVertexProgram).select("a"), "[]", null},
+ {__.V().as("a").out().program(pathVertexProgram).select("a"), "[]", null},
+ {__.V().as("a").out().program(emptyRequirementsVertexProgram).select("a"), "[[]]", null}
});
}
-}
+}
\ No newline at end of file