tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject [1/3] tinkerpop git commit: Implemented `reset()` in `ComputerAwareStep` to reset the `previousIterator` and reset the `finalStep` in `DefaultTraversal`. This fixes TINKERPOP-1867, a falsy behavior, mainly seen in reducing barrier steps.
Date Sun, 21 Jan 2018 01:11:27 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/tp32 1f56cb550 -> b889ca111


Implemented `reset()` in `ComputerAwareStep` to reset the `previousIterator` and reset the
`finalStep` in `DefaultTraversal`.
This fixes TINKERPOP-1867, a falsy behavior, mainly seen in reducing barrier steps.


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

Branch: refs/heads/tp32
Commit: fa8dae8b7aed18e73f01a6b13cdf01adbcbe4461
Parents: 231bbb6
Author: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Authored: Tue Jan 9 18:40:48 2018 -0700
Committer: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Committed: Sat Jan 20 18:08:31 2018 -0700

----------------------------------------------------------------------
 .../traversal/step/util/ComputerAwareStep.java  |  6 +++++
 .../traversal/util/DefaultTraversal.java        |  1 +
 .../step/branch/GroovyUnionTest.groovy          |  6 +++++
 .../traversal/step/branch/UnionTest.java        | 23 ++++++++++++++------
 4 files changed, 29 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fa8dae8b/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 7fda097..d025657 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
@@ -59,6 +59,12 @@ public abstract class ComputerAwareStep<S, E> extends AbstractStep<S,
E> impleme
         return clone;
     }
 
+    @Override
+    public void reset() {
+        super.reset();
+        this.previousIterator = EmptyIterator.instance();
+    }
+
     protected abstract Iterator<Traverser.Admin<E>> standardAlgorithm() throws
NoSuchElementException;
 
     protected abstract Iterator<Traverser.Admin<E>> computerAlgorithm() throws
NoSuchElementException;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fa8dae8b/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 b2c9a35..585a82b 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
@@ -208,6 +208,7 @@ public class DefaultTraversal<S, E> implements Traversal.Admin<S,
E> {
     @Override
     public void reset() {
         this.steps.forEach(Step::reset);
+        this.finalEndStep.reset();
         this.lastTraverser = EmptyTraverser.instance();
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fa8dae8b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyUnionTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyUnionTest.groovy
b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyUnionTest.groovy
index 5627cdc..50d590e 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyUnionTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyUnionTest.groovy
@@ -73,5 +73,11 @@ public abstract class GroovyUnionTest {
                 final Object v1Id, final Object v2Id) {
             new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id, v2Id).local(union(outE().count,
inE().count, outE().weight.sum))", "v1Id", v1Id, "v2Id", v2Id);
         }
+
+        @Override
+        public Traversal<Vertex, Number> get_g_VX1_2X_localXunionXcountXX(
+                final Object v1Id, final Object v2Id) {
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id, v2Id).local(union(count()))",
"v1Id", v1Id, "v2Id", v2Id);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fa8dae8b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/UnionTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/UnionTest.java
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/UnionTest.java
index df52f9b..03abc03 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/UnionTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/UnionTest.java
@@ -31,13 +31,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
-import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.in;
-import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.inE;
-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.__.repeat;
-import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.union;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 
@@ -61,6 +55,8 @@ public abstract class UnionTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Number> get_g_VX1_2X_localXunionXoutE_count__inE_count__outE_weight_sumXX(final
Object v1Id, final Object v2Id);
 
+    public abstract Traversal<Vertex, Number> get_g_VX1_2X_localXunionXcountXX(final
Object v1Id, final Object v2Id);
+
     @Test
     @LoadGraphWith(MODERN)
     public void g_V_unionXout__inX_name() {
@@ -144,6 +140,14 @@ public abstract class UnionTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(MODERN)
+    public void g_VX1_2X_localXunionXcountXX() {
+        final Traversal<Vertex, Number> traversal = get_g_VX1_2X_localXunionXcountXX(convertToVertexId("marko"),
convertToVertexId("vadas"));
+        printTraversalForm(traversal);
+        checkResults(Arrays.asList(1L, 1L), traversal);
+    }
+
+    @Test
+    @LoadGraphWith(MODERN)
     public void g_VX1_2X_unionXoutE_count__inE_count__outE_weight_sumX() {
         final Traversal<Vertex, Number> traversal = get_g_VX1_2X_unionXoutE_count__inE_count__outE_weight_sumX(convertToVertexId("marko"),
convertToVertexId("vadas"));
         printTraversalForm(traversal);
@@ -192,5 +196,10 @@ public abstract class UnionTest extends AbstractGremlinProcessTest {
         public Traversal<Vertex, Number> get_g_VX1_2X_localXunionXoutE_count__inE_count__outE_weight_sumXX(final
Object v1Id, final Object v2Id) {
             return g.V(v1Id, v2Id).local(union(outE().count(), inE().count(), (Traversal)
outE().values("weight").sum()));
         }
+
+        @Override
+        public Traversal<Vertex, Number> get_g_VX1_2X_localXunionXcountXX(final Object
v1Id, final Object v2Id) {
+            return g.V(v1Id, v2Id).local(union((Traversal) count()));
+        }
     }
 }


Mime
View raw message