tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject [2/5] tinkerpop git commit: Added a test case in `CountTest`, mainly to double-check that nested `.count().is(0)`'s get rewritten properly. Also fixed an loop in `DefaultTraversal` which had to potential to throw `ConcurrentModificationException`s.
Date Mon, 27 Feb 2017 18:43:09 GMT
Added a test case in `CountTest`, mainly to double-check that nested `.count().is(0)`'s get
rewritten properly.
Also fixed an loop in `DefaultTraversal` which had to potential to throw `ConcurrentModificationException`s.


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

Branch: refs/heads/tp32
Commit: c49c107338b0a4300c8577b8006a6c20c62b4bab
Parents: fe905dd
Author: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Authored: Thu Feb 23 18:12:34 2017 +0100
Committer: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Committed: Thu Feb 23 18:12:34 2017 +0100

----------------------------------------------------------------------
 .../process/traversal/util/DefaultTraversal.java  |  3 ++-
 .../traversal/step/map/GroovyCountTest.groovy     |  5 +++++
 .../process/traversal/step/map/CountTest.java     | 18 ++++++++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c49c1073/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 eb5f087..52c3027 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
@@ -113,7 +113,8 @@ public class DefaultTraversal<S, E> implements Traversal.Admin<S,
E> {
         TraversalHelper.reIdSteps(this.stepPosition, this);
         this.strategies.applyStrategies(this);
         boolean hasGraph = null != this.graph;
-        for (final Step<?, ?> step : this.getSteps()) {
+        for (int i = 0, j = this.steps.size(); i < j; i++) { // "foreach" can lead to
ConcurrentModificationExceptions
+            final Step step = this.steps.get(i);
             if (step instanceof TraversalParent) {
                 for (final Traversal.Admin<?, ?> globalChild : ((TraversalParent) step).getGlobalChildren())
{
                     globalChild.setStrategies(this.strategies);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c49c1073/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
index 898f16c..f6267f9 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy
@@ -67,5 +67,10 @@ public abstract class GroovyCountTest {
         public Traversal<Vertex, Long> get_g_V_fold_countXlocalX() {
             new ScriptTraversal<>(g, "gremlin-groovy", "g.V.fold.count(local)")
         }
+
+        @Override
+        public Traversal<Vertex, String> get_g_V_whereXinXknowsX_outXcreatedX_count_is_0XX_name()
{
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V.where(__.in('knows').out('created').count.is(0)).name")
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c49c1073/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/CountTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/CountTest.java
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/CountTest.java
index be53b5e..f6e7cac 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/CountTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/CountTest.java
@@ -27,8 +27,11 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.util.Arrays;
+
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.GRATEFUL;
 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.__.out;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -55,6 +58,8 @@ public abstract class CountTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Long> get_g_V_fold_countXlocalX();
 
+    public abstract Traversal<Vertex, String> get_g_V_whereXinXknowsX_outXcreatedX_count_is_0XX_name();
+
     @Test
     @LoadGraphWith(MODERN)
     public void g_V_count() {
@@ -136,6 +141,14 @@ public abstract class CountTest extends AbstractGremlinProcessTest {
         assertFalse(traversal.hasNext());
     }
 
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_V_whereXinXkknowsX_outXcreatedX_count_is_0XX_name() {
+        final Traversal<Vertex, String> traversal = get_g_V_whereXinXknowsX_outXcreatedX_count_is_0XX_name();
+        printTraversalForm(traversal);
+        checkResults(Arrays.asList("marko", "lop", "ripple", "peter"), traversal);
+    }
+
     public static class Traversals extends CountTest {
 
         @Override
@@ -177,5 +190,10 @@ public abstract class CountTest extends AbstractGremlinProcessTest {
         public Traversal<Vertex, Long> get_g_V_fold_countXlocalX() {
             return g.V().fold().count(Scope.local);
         }
+
+        @Override
+        public Traversal<Vertex, String> get_g_V_whereXinXknowsX_outXcreatedX_count_is_0XX_name()
{
+            return g.V().where(in("knows").out("created").count().is(0)).values("name");
+        }
     }
 }


Mime
View raw message