tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [02/28] tinkerpop git commit: fixed a bug in OLAP ComputerAwareStep.EndStep where labels were not being appended to the traverser correctly. Also, a small optimization tweak to PathRetractionStrategy to mirror the barrier-optimization retraction that was
Date Thu, 23 Feb 2017 16:23:35 GMT
fixed a bug in OLAP ComputerAwareStep.EndStep where labels were not being appended to the traverser
correctly. Also, a small optimization tweak to PathRetractionStrategy to mirror the barrier-optimization
retraction that was done earlier on tp32/ around LazyBarrierStrategy.


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

Branch: refs/heads/TINKERPOP-1612
Commit: 012edf17531f5b4ce979351bdfde504a32437800
Parents: 9b88e9a
Author: Marko A. Rodriguez <okrammarko@gmail.com>
Authored: Wed Feb 22 09:59:09 2017 -0700
Committer: Marko A. Rodriguez <okrammarko@gmail.com>
Committed: Wed Feb 22 09:59:09 2017 -0700

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  2 ++
 .../traversal/step/util/ComputerAwareStep.java  |  5 +++--
 .../optimization/PathRetractionStrategy.java    |  7 +++----
 .../PathRetractionStrategyTest.java             |  2 +-
 .../step/branch/GroovyChooseTest.groovy         |  5 +++++
 .../traversal/step/branch/ChooseTest.java       | 22 ++++++++++++++++++++
 6 files changed, 36 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/012edf17/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index de78d24..14addea 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,8 +26,10 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Fixed a bug in OLAP `ComputerAwareStep` where end-step labels were not being appended to
the traverser correctly.
 * Refactor `SparkContext` handler to support external kill and stop operations.
 * Fixed an optimization bug in `LazyBarrierStrategy` around appending barriers to the end
of a `Traversal`.
+* Fixed an optimization bug in `PathRetractionStrategy` around appending barriers to the
end of a `Traversal`.
 * `TraverserIterator` in GremlinServer is smart to try and bulk traversers prior to network
I/O.
 
 [[release-3-2-4]]

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/012edf17/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/ComputerAwareStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/ComputerAwareStep.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/ComputerAwareStep.java
index 5acff58..7fda097 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/ComputerAwareStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/ComputerAwareStep.java
@@ -75,8 +75,9 @@ public abstract class ComputerAwareStep<S, E> extends AbstractStep<S,
E> impleme
         protected Traverser.Admin<S> processNextStart() throws NoSuchElementException
{
             final Traverser.Admin<S> start = this.starts.next();
             if (this.traverserStepIdAndLabelsSetByChild) {
-                start.setStepId(((ComputerAwareStep<?, ?>) this.getTraversal().getParent()).getNextStep().getId());
-                start.path().extend(((ComputerAwareStep<?, ?>) this.getTraversal().getParent()).getLabels());
+                final ComputerAwareStep<?, ?> step = (ComputerAwareStep<?, ?>)
this.getTraversal().getParent();
+                start.setStepId(step.getNextStep().getId());
+                start.addLabels(step.getLabels());
             }
             return start;
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/012edf17/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 91f07f9..bd27a3e 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
@@ -98,8 +98,8 @@ public final class PathRetractionStrategy extends AbstractTraversalStrategy<Trav
                 final PathProcessor pathProcessor = (PathProcessor) currentStep;
                 if (currentStep instanceof MatchStep &&
                         (currentStep.getNextStep().equals(EmptyStep.instance()) ||
-                            currentStep.getNextStep() instanceof DedupGlobalStep ||
-                            currentStep.getNextStep() instanceof SelectOneStep &&
currentStep.getNextStep().getNextStep() instanceof FilterStep)) {
+                                currentStep.getNextStep() instanceof DedupGlobalStep ||
+                                currentStep.getNextStep() instanceof SelectOneStep &&
currentStep.getNextStep().getNextStep() instanceof FilterStep)) {
                     pathProcessor.setKeepLabels(((MatchStep) currentStep).getMatchStartLabels());
                     pathProcessor.getKeepLabels().addAll(((MatchStep) currentStep).getMatchEndLabels());
                 } else {
@@ -120,8 +120,7 @@ public final class PathRetractionStrategy extends AbstractTraversalStrategy<Trav
                         !(currentStep instanceof Barrier) &&
                         !(currentStep.getNextStep() instanceof Barrier) &&
                         !(currentStep.getTraversal().getParent() instanceof MatchStep) &&
-                        (!(currentStep.getNextStep() instanceof EmptyStep) || TraversalHelper.isGlobalChild(currentStep.getTraversal())))
-
+                        !(currentStep.getNextStep() instanceof EmptyStep))
                     TraversalHelper.insertAfterStep(new NoOpBarrierStep<>(traversal,
this.standardBarrierSize), currentStep, traversal);
             }
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/012edf17/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 2f99fd2..2a87f47 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
@@ -147,7 +147,7 @@ public class PathRetractionStrategyTest {
                 {__.V().as("a").out().as("b").select("a").barrier().count(), "[[]]", __.V().as("a").out().as("b").select("a").barrier().count()},
                 {__.V().as("a").out().as("b").dedup("a", "b").out(), "[[]]", __.V().as("a").out().as("b").dedup("a",
"b").out()},
                 {__.V().as("a").out().as("b").match(as("a").out().as("b")), "[[a, b]]", __.V().as("a").out().as("b").match(as("a").out().as("b"))},
-                {__.V().as("a").out().as("b").match(as("a").out().as("b")).select("a"), "[[a],
[]]", __.V().as("a").out().as("b").match(as("a").out().as("b")).select("a").barrier(MAX_BARRIER_SIZE)},
+                {__.V().as("a").out().as("b").match(as("a").out().as("b")).select("a"), "[[a],
[]]", __.V().as("a").out().as("b").match(as("a").out().as("b")).select("a")},
                 {__.V().as("a").out().as("b").match(as("a").out().as("b")).select("a").out().dedup("a"),
"[[a], [a], []]", __.V().as("a").out().as("b").match(as("a").out().as("b")).select("a").barrier(MAX_BARRIER_SIZE).out().dedup("a")},
                 {__.V().as("a").out().as("b").where(P.gt("a")).out().out(), "[[]]", __.V().as("a").out().as("b").where(P.gt("a")).barrier(MAX_BARRIER_SIZE).out().out()},
                 {__.V().as("a").out().as("b").where(P.gt("a")).count(), "[[]]", __.V().as("a").out().as("b").where(P.gt("a")).count()},

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/012edf17/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy
b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy
index 6c6a4ac..802c427 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy
@@ -58,5 +58,10 @@ public abstract class GroovyChooseTest {
         public Traversal<Vertex, String> get_g_V_chooseXoutXknowsX_count_isXgtX0XX__outXknowsXX_name()
{
             new ScriptTraversal<>(g, "gremlin-groovy", "g.V.choose(out('knows').count.is(gt(0)),
out('knows')).name")
         }
+
+        @Override
+        public Traversal<Vertex, Map<String, String>> get_g_V_hasLabelXpersonX_asXp1X_chooseXoutEXknowsX__outXknowsXX_asXp2X_selectXp1_p2X_byXnameX()
{
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').as('p1').choose(outE('knows'),
out('knows')).as('p2').select('p1', 'p2').by('name')");
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/012edf17/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/ChooseTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/ChooseTest.java
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/ChooseTest.java
index 8938bec..e59d659 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/ChooseTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/ChooseTest.java
@@ -39,6 +39,7 @@ import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.identi
 import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.in;
 import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.label;
 import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.outE;
 import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.valueMap;
 import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.values;
 import static org.junit.Assert.assertEquals;
@@ -61,6 +62,8 @@ public abstract class ChooseTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, String> get_g_V_chooseXoutXknowsX_count_isXgtX0XX__outXknowsXX_name();
 
+    public abstract Traversal<Vertex, Map<String, String>> get_g_V_hasLabelXpersonX_asXp1X_chooseXoutEXknowsX__outXknowsXX_asXp2X_selectXp1_p2X_byXnameX();
+
     @Test
     @LoadGraphWith(MODERN)
     public void g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX() {
@@ -111,6 +114,20 @@ public abstract class ChooseTest extends AbstractGremlinProcessTest {
         checkResults(Arrays.asList("vadas", "josh", "vadas", "josh", "peter", "lop", "ripple"),
traversal);
     }
 
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_V_hasLabelXpersonX_asXp1X_chooseXoutEXknowsX__outXknowsXX_asXp2X_selectXp1_p2X_byXnameX()
{
+        final Traversal<Vertex, Map<String, String>> traversal = get_g_V_hasLabelXpersonX_asXp1X_chooseXoutEXknowsX__outXknowsXX_asXp2X_selectXp1_p2X_byXnameX();
+        printTraversalForm(traversal);
+        checkResults(makeMapList(2,
+                "p1", "marko", "p2", "vadas",
+                "p1", "marko", "p2", "josh",
+                "p1", "vadas", "p2", "vadas",
+                "p1", "josh", "p2", "josh",
+                "p1", "peter", "p2", "peter"
+        ), traversal);
+    }
+
     public static class Traversals extends ChooseTest {
 
         @Override
@@ -142,5 +159,10 @@ public abstract class ChooseTest extends AbstractGremlinProcessTest {
         public Traversal<Vertex, String> get_g_V_chooseXoutXknowsX_count_isXgtX0XX__outXknowsXX_name()
{
             return g.V().choose(out("knows").count().is(P.gt(0)), out("knows")).values("name");
         }
+
+        @Override
+        public Traversal<Vertex, Map<String, String>> get_g_V_hasLabelXpersonX_asXp1X_chooseXoutEXknowsX__outXknowsXX_asXp2X_selectXp1_p2X_byXnameX()
{
+            return g.V().hasLabel("person").as("p1").choose(outE("knows"), out("knows")).as("p2").<String>select("p1",
"p2").by("name");
+        }
     }
 }
\ No newline at end of file


Mime
View raw message