You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/06/26 19:59:23 UTC

[1/6] incubator-tinkerpop git commit: minor bash script improvement

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/resultset-refactor 35122afa3 -> 382ccbfec


minor bash script improvement


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

Branch: refs/heads/resultset-refactor
Commit: 62172b0345121ac238bb4519f0a9e42a891ecb63
Parents: 8044315
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Fri Jun 26 15:49:21 2015 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri Jun 26 15:49:21 2015 +0200

----------------------------------------------------------------------
 bin/process-docs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/62172b03/bin/process-docs.sh
----------------------------------------------------------------------
diff --git a/bin/process-docs.sh b/bin/process-docs.sh
index faa3c4c..c3d3b4f 100755
--- a/bin/process-docs.sh
+++ b/bin/process-docs.sh
@@ -21,5 +21,5 @@
 pushd "$(dirname $0)/.." > /dev/null
 nc -z localhost 8080 || bin/gephi.mock > /dev/null 2>&1 &
 docs/preprocessor/preprocess.sh && mvn process-resources -Dasciidoc && docs/postprocessor/postprocess.sh
-pgrep gephi.mock | xargs -I {} pstree {} -p -a -l | cut -d , -f2 | awk '{print $1}' | xargs kill -PIPE > /dev/null
+pgrep gephi.mock | xargs -I {} pstree {} -p -a -l | cut -d , -f2 | awk '{print $1}' | xargs -r kill -PIPE > /dev/null
 popd > /dev/null


[4/6] incubator-tinkerpop git commit: added more MatchPredicateStratetegyTest tests. Fixed up an old MatchTest that was failing for a known reason, but now is right.

Posted by sp...@apache.org.
added more MatchPredicateStratetegyTest tests. Fixed up an old MatchTest that was failing for a known reason, but now is right.


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

Branch: refs/heads/resultset-refactor
Commit: d5b70bef8e016ec05c364ab5525b75379d412ba3
Parents: bc130ff
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Jun 26 11:24:50 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri Jun 26 11:24:50 2015 -0600

----------------------------------------------------------------------
 .../optimization/MatchPredicateStrategy.java    |  4 +-
 .../MatchPredicateStrategyTest.java             |  8 ++-
 .../traversal/step/map/GroovyMatchTest.groovy   |  8 +--
 .../process/traversal/step/map/MatchTest.java   | 17 +++---
 .../gremlin/hadoop/structure/HadoopGraph.java   |  4 +-
 .../tinkergraph/structure/TinkerGraphTest.java  | 56 +++-----------------
 6 files changed, 30 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d5b70bef/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
index dc26549..3a41092 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
@@ -103,7 +103,7 @@ public final class MatchPredicateStrategy extends AbstractTraversalStrategy<Trav
                                     .findAny()
                                     .isPresent()) {
                         matchStep.removeGlobalChild(matchTraversal);
-                        matchTraversal.removeStep(0);                                     // remove MatchStartStep
+                        matchTraversal.removeStep(0);                                       // remove MatchStartStep
                         matchTraversal.removeStep(matchTraversal.getSteps().size() - 1);    // remove MatchEndStep
                         matchStep.getPreviousStep().addLabel(startLabel);
                         TraversalHelper.insertTraversal(matchStep.getPreviousStep(), matchTraversal, traversal);
@@ -119,7 +119,7 @@ public final class MatchPredicateStrategy extends AbstractTraversalStrategy<Trav
         else {
             final String startLabel = MatchStep.Helper.computeStartLabel(matchStep.getGlobalChildren());
             Step<?, ?> previousStep = matchStep.getPreviousStep();
-            if(previousStep.getLabels().contains(startLabel))
+            if (previousStep.getLabels().contains(startLabel))
                 return startLabel;
             while (!(previousStep instanceof EmptyStep)) {
                 if (!previousStep.getLabels().isEmpty())

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d5b70bef/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategyTest.java
index 8524334..3111381 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategyTest.java
@@ -21,6 +21,7 @@
 
 package org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization;
 
+import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
@@ -122,7 +123,12 @@ public class MatchPredicateStrategyTest {
                     {__.out().as("a").out().match(as("a").has("name", "marko"), as("a").out().as("b")), __.out().as("a").out().match(as("a").has("name", "marko"), as("a").out().as("b"))}, // no has() pull out
                     {__.map(__.match(as("a").has("name", "marko"), as("a").out().as("b"))), __.map(__.match(as("a").has("name", "marko"), as("a").out().as("b")))}, // no has() pull out
                     {__.out().as("c").match(as("a").has("name", "marko"), as("a").out().as("b")), __.out().as("c").match(as("a").has("name", "marko"), as("a").out().as("b"))}, // no has() pull out
-                    //{__.match(as("a").out().as("b")).where(as("b").out("knows").as("c")), __.match(as("a").out().as("b"), as("b").where(__.out("knows").as("c")))},
+                    /////////
+                    {__.match(as("a").out().as("b"), __.where(as("b").out("knows").as("c"))), __.match(as("a").out().as("b"), as("b").where(__.out("knows").as("c")))}, // make as().where()
+                    {__.match(as("a").out().as("b"), __.where("a", P.gt("b"))), __.match(as("a").out().as("b"), __.as("a").where(P.gt("b")))},  // make as().where()
+                    /////////
+                    //{__.match(as("a").out().as("b")).where(as("b").out("knows").as("c")), __.match(as("a").out().as("b"), as("b").where(__.out("knows").as("c")))}, // make as().where()
+                    //{__.match(as("a").out().as("b")).where("a", P.gt("b")), __.match(as("a").out().as("b"), __.as("a").where(P.gt("b")))},  // make as().where()
             });
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d5b70bef/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
index 21d98c1..08b6300 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
@@ -223,11 +223,11 @@ public abstract class GroovyMatchTest {
         }
 
         @Override
-        public Traversal<Vertex, String> get_g_V_out_out_hasXname_rippleX_matchXa__b_created_a__c_knows_bX_selectXcX_outXknowsX_name() {
+        public Traversal<Vertex, String> get_g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX() {
             TraversalScriptHelper.compute("""
-                g.V.out.out.as('b').match(
-                    __.as('b').out('created').as('a'),
-                    __.as('c').out('knows').as('b')).select('c').out('knows').name
+                g.V().out().as("c").match(
+                    as("b").out("knows").as("a"),
+                    as("c").out("created").as("e")).select("c")
             """, g)
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d5b70bef/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
index 488b907..f0c012a 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
@@ -104,8 +104,7 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
     //TODO: with Traversal.reverse()
     public abstract Traversal<Vertex, Map<String, String>> get_g_V_matchXa_created_b__c_created_bX_select_byXnameX();
 
-    //TODO: with Traversal.reverse()
-    public abstract Traversal<Vertex, String> get_g_V_out_out_hasXname_rippleX_matchXa__b_created_a__c_knows_bX_selectXcX_outXknowsX_name();
+    public abstract Traversal<Vertex, String> get_g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX();
 
     // nested or/and with patterns in order that won't execute serially
     public abstract Traversal<Vertex, Map<String, Object>> get_g_V_matchXa_whereXa_neqXcXX__a_created_b__orXa_knows_vadas__a_0knows_and_a_hasXlabel_personXX__b_0created_c__b_0created_count_isXgtX1XXX_select_byXidX();
@@ -281,12 +280,10 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
         traversal.iterate();
     }
 
-    // TODO: this test requires Traversal.reverse()
     @Test(expected = IllegalStateException.class)
-    @Ignore
     @LoadGraphWith(MODERN)
-    public void g_V_out_out_hasXname_rippleX_matchXb_created_a__c_knows_bX_selectXcX_outXknowsX_name() throws Exception {
-        final Traversal<Vertex, String> traversal = get_g_V_out_out_hasXname_rippleX_matchXa__b_created_a__c_knows_bX_selectXcX_outXknowsX_name();
+    public void g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX() throws Exception {
+        final Traversal<Vertex, String> traversal = get_g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX();
         printTraversalForm(traversal);
         traversal.iterate();
     }
@@ -614,10 +611,10 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
         }
 
         @Override
-        public Traversal<Vertex, String> get_g_V_out_out_hasXname_rippleX_matchXa__b_created_a__c_knows_bX_selectXcX_outXknowsX_name() {
-            return g.V().out().out().as("b").match(
-                    as("b").out("created").as("a"),
-                    as("c").out("knows").as("b")).select("c").out("knows").values("name");
+        public Traversal<Vertex, String> get_g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX() {
+            return g.V().out().as("c").match(
+                    as("b").out("knows").as("a"),
+                    as("c").out("created").as("e")).select("c");
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d5b70bef/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
index 2971e1d..7589588 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
@@ -74,7 +74,7 @@ import java.util.stream.Stream;
         reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.")
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
-        method = "g_V_out_out_hasXname_rippleX_matchXb_created_a__c_knows_bX_selectXcX_outXknowsX_name",
+        method = "g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX",
         reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.")
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
@@ -90,7 +90,7 @@ import java.util.stream.Stream;
         reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.")
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals",
-        method = "g_V_out_out_hasXname_rippleX_matchXb_created_a__c_knows_bX_selectXcX_outXknowsX_name",
+        method = "g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX",
         reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.")
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals",

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d5b70bef/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index 0a9544e..ab1da96 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@ -167,57 +167,17 @@ public class TinkerGraphTest {
     @Test
     @Ignore
     public void testPlay7() throws Exception {
-        TinkerGraph graph = TinkerGraph.open();
+        /*TinkerGraph graph = TinkerGraph.open();
         graph.createIndex("name",Vertex.class);
-        graph.io(GraphMLIo.build()).readGraph("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");
-        GraphTraversalSource g = graph.traversal(GraphTraversalSource.standard());
+        graph.io(GraphMLIo.build()).readGraph("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");*/
         //System.out.println(g.V().properties().key().groupCount().next());
+        TinkerGraph graph = TinkerFactory.createModern();
+        GraphTraversalSource g = graph.traversal(GraphTraversalSource.standard());
         final List<Supplier<GraphTraversal<?,?>>> traversals = Arrays.asList(
-                /*() -> g.V().xmatch("a",
-                        as("a").in("sungBy").as("b"),
-                        not(as("a").in("writtenBy").as("b"))).select().by("name"),*/
-                () -> g.V().match(
-                        as("a").in("sungBy").as("b"),
-                        as("a").in("writtenBy").as("b")).select().by("name"),
-                () -> g.V().match(
-                        as("a").out("followedBy").as("b"),
-                        as("b").out("followedBy").as("a")).select().by("name"),
-                () -> g.V().match(
-                        as("a").out("followedBy").count().as("b"),
-                        as("a").in("followedBy").count().as("b"),
-                        as("b").is(P.gt(10))).select("a").by("name"),
-                () -> g.V().match(
-                        as("a").in("sungBy").count().as("b"),
-                        as("a").in("sungBy").as("c"),
-                        as("c").out("followedBy").as("d"),
-                        as("d").out("sungBy").as("e"),
-                        as("e").in("sungBy").count().as("b"),
-                        where("a",P.neq("e"))).select("a","e").by("name"),
-                () -> g.V().match(
-                        as("a").in("followedBy").as("b"),
-                        as("a").out("sungBy").as("c"),
-                        as("a").out("writtenBy").as("d")).select().by("name"),
-                () -> g.V().match(
-                        as("a").in("followedBy").as("b"),
-                        as("a").out("sungBy").as("c"),
-                        as("a").out("writtenBy").as("d"),
-                        where("c", P.neq("d"))).select().by("name"),
-                () -> g.V().match(
-                        as("a").in("sungBy").as("b"),
-                        as("a").in("writtenBy").as("b"),
-                        as("b").out("followedBy").as("c"),
-                        as("c").out("sungBy").as("a"),
-                        as("c").out("writtenBy").as("a")).select().by("name"),
-                () -> g.V().match(
-                        as("a").has("name", "Garcia"),
-                        as("a").in("writtenBy").as("b"),
-                        as("b").out("followedBy").as("c"),
-                        as("c").out("writtenBy").as("d"),
-                        as("d").where(P.neq("a"))).select().by("name"),
-                () -> g.V().as("a").out("followedBy").as("b").match(
-                        as("a").and(has(T.label,"song"),has("performances",P.gt(10))),
-                        as("a").out("writtenBy").as("c"),
-                        as("b").out("writtenBy").as("c")).select().by("name"));
+                () -> g.V().out().as("c").match(
+                        as("b").out("knows").as("a"),
+                        as("c").out("created").as("e")).select("c").out("knows").values("name")
+        );
 
         traversals.forEach(traversal -> {
             System.out.println("pre-strategy:  " + traversal.get());


[2/6] incubator-tinkerpop git commit: Removed MatchStep.getStartLabel(). The only class that needed it was MatchPredicateStrategy and that just uses the MatchStep.Helper.calculateStartLabel() static method. Added more MatchPredicateStrategyTest tests to

Posted by sp...@apache.org.
Removed MatchStep.getStartLabel(). The only class that needed it was MatchPredicateStrategy and that just uses the MatchStep.Helper.calculateStartLabel() static method. Added more MatchPredicateStrategyTest tests to make sure the compilation is correct. Tweaks to the-traversal.asciidoc formatting.


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

Branch: refs/heads/resultset-refactor
Commit: 6e93765989354ef469e65b1b9325422837a6b579
Parents: 62172b0
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Jun 26 09:21:07 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri Jun 26 09:21:07 2015 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  2 ++
 docs/src/the-traversal.asciidoc                 | 26 ++++++++++----------
 .../process/traversal/step/map/MatchStep.java   | 16 +++---------
 .../optimization/MatchPredicateStrategy.java    | 24 +++++++++++++++---
 .../process/traversal/util/TraversalHelper.java |  5 +---
 .../traversal/step/map/MatchStepTest.java       |  3 ---
 .../MatchPredicateStrategyTest.java             |  8 ++++--
 7 files changed, 47 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6e937659/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 9d86f1c..c96ac2a 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -25,6 +25,8 @@ image::http://www.tinkerpop.com/docs/current/images/gremlin-hindu.png[width=225]
 TinkerPop 3.0.0.GA (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* `MatchStep` and `match()` no longer have a "start label" parameter -- it is computed if the incoming traverser does not have requisite labels.
+* Added `TraversalParent.removeGlobalChild()` and `TraversalParent.removeLocalChild()`.
 * Add a `clear` option to the Gephi Plugin to empty the Gephi workspace.
 * `AbstractStep` now guarantees that bulk-less and null-valued traversers are never propagated.
 * Added `dedup(string...)` which allows for the deduplication of a stream based on unique scope values.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6e937659/docs/src/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/the-traversal.asciidoc b/docs/src/the-traversal.asciidoc
index f5efcd9..019199b 100644
--- a/docs/src/the-traversal.asciidoc
+++ b/docs/src/the-traversal.asciidoc
@@ -800,15 +800,15 @@ g.V().match(
         __.as('b').match(
                      __.as('b').out('created').as('c'),
                      __.as('c').has('name','ripple')).
-                  select('c').as('c')).
+                   select('c').as('c')).
       select('a','c').by('name')
 ----
 
-If an extended, step-labeled traversal proceeds the `match()`-step and the traverser entering the `match()` is destined to bind to a particular variable, then the previous step should be labeled accordingly.
+If a step-labeled traversal proceeds the `match()`-step and the traverser entering the `match()` is destined to bind to a particular variable, then the previous step should be labeled accordingly.
 
 [gremlin-groovy,modern]
 ----
-g.V().as('a').out('knows').as('b')
+g.V().as('a').out('knows').as('b').
   match(
     __.as('b').out('created').as('c'),
     __.not(__.as('c').in('created').as('a'))).
@@ -827,13 +827,12 @@ If a variable is at the start of a traversal pattern it *must* exist as a label
 ----
 g.V().as('a').out().as('b'). <1>
     match( <2>
-        __.as('a').out().count().as('c'), <3>
-        __.not(__.as('a').in().as('b')), <4>
-        or( <5>
-          __.as('a').out('knows').as('b'),
-          __.as('b').in().count().as('c').and().as('c').is(gt(2))  <6>
-        )
-    ).dedup('a','c'). <7>
+      __.as('a').out().count().as('c'), <3>
+      __.not(__.as('a').in().as('b')), <4>
+      or( <5>
+        __.as('a').out('knows').as('b'),
+        __.as('b').in().count().as('c').and().as('c').is(gt(2)))).  <6>
+    dedup('a','c'). <7>
     select('a','b','c').by('name').by('name').by() <8>
 ----
 
@@ -857,7 +856,8 @@ Match is typically used in conjunction with both `select()` (demonstrated previo
 g.V().match(
         __.as('a').out('created').as('b'),
         __.as('b').in('created').as('c')).
-          where('a', neq('c')).select('a','c').by('name')
+        where('a', neq('c')).
+      select('a','c').by('name')
 ----
 
 The `where()`-step can take either a `P`-predicate (example above) or a `Traversal` (example below). Using `MatchPredicateStrategy`, `where()`-clauses are automatically folded into `match()` and thus, subject to the query optimizer within `match()`-step.
@@ -868,8 +868,8 @@ traversal = g.V().match(
                     __.as('a').has(label,'person'), <1>
                     __.as('a').out('created').as('b'),
                     __.as('b').in('created').as('c')).
-                      where(__.as('a').out('knows').as('c')). <2>
-                      select('a','c').by('name'); null <3>
+                    where(__.as('a').out('knows').as('c')). <2>
+                  select('a','c').by('name'); null <3>
 traversal.toString() <4>
 traversal <5> <6>
 traversal.toString() <7>

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6e937659/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStep.java
index 22efece..bf6bb02 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStep.java
@@ -190,10 +190,6 @@ public final class MatchStep<S, E> extends ComputerAwareStep<S, Map<String, E>>
 
     }
 
-    public Optional<String> getStartLabel() {
-        return Optional.ofNullable(this.computedStartLabel);
-    }
-
     @Override
     public Set<String> getScopeKeys() {
         if (null == this.scopeKeys) {
@@ -331,10 +327,10 @@ public final class MatchStep<S, E> extends ComputerAwareStep<S, Map<String, E>>
                 traverser = this.starts.next();
                 final Path path = traverser.path();
                 if (!this.matchStartLabels.stream().filter(path::hasLabel).findAny().isPresent())
-                        path.addLabel(this.computedStartLabel);
+                        path.addLabel(this.computedStartLabel); // if the traverser doesn't have a legal start, then provide it the pre-computed one
                 path.addLabel(this.getId()); // so the traverser never returns to this branch ever again
             }
-
+            ///
             if (!this.isDuplicate(traverser)) {
                 if (hasMatched(this.conjunction, traverser))
                     return IteratorUtils.of(traverser.split(this.getBindings(traverser), this));
@@ -356,10 +352,10 @@ public final class MatchStep<S, E> extends ComputerAwareStep<S, Map<String, E>>
             final Traverser.Admin traverser = this.starts.next();
             final Path path = traverser.path();
             if (!this.matchStartLabels.stream().filter(path::hasLabel).findAny().isPresent())
-                path.addLabel(this.computedStartLabel);
+                path.addLabel(this.computedStartLabel); // if the traverser doesn't have a legal start, then provide it the pre-computed one
             if (!path.hasLabel(this.getId()))
                 path.addLabel(this.getId()); // so the traverser never returns to this branch ever again
-
+            ///
             if (!this.isDuplicate(traverser)) {
                 if (hasMatched(this.conjunction, traverser)) {
                     traverser.setStepId(this.getNextStep().getId());
@@ -674,10 +670,6 @@ public final class MatchStep<S, E> extends ComputerAwareStep<S, Map<String, E>>
             public final void incrementEndCount() {
                 this.multiplicity = (double) ++this.endsCount / (double) this.startsCount;
             }
-
-            /*public String toString() {
-                return this.multiplicity + "--" + this.traversal;
-            }*/
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6e937659/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
index 56d46f1..dc26549 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategy.java
@@ -89,11 +89,12 @@ public final class MatchPredicateStrategy extends AbstractTraversalStrategy<Trav
                     break;
             }
             // match(as('a').has(key,value),...) --> as('a').has(key,value).match(...)
-            if (matchStep.getStartLabel().isPresent() && (matchStep.getPreviousStep().getLabels().isEmpty() || matchStep.getPreviousStep().getLabels().contains(matchStep.getStartLabel()))) {
+            final String startLabel = this.determineStartLabelForHasPullOut(matchStep);
+            if (null != startLabel) {
                 ((MatchStep<?, ?>) matchStep).getGlobalChildren().stream().collect(Collectors.toList()).forEach(matchTraversal -> {
                     if (matchTraversal.getStartStep() instanceof MatchStep.MatchStartStep &&
                             ((MatchStep.MatchStartStep) matchTraversal.getStartStep()).getSelectKey().isPresent() &&
-                            ((MatchStep.MatchStartStep) matchTraversal.getStartStep()).getSelectKey().get().equals(matchStep.getStartLabel().get()) &&
+                            ((MatchStep.MatchStartStep) matchTraversal.getStartStep()).getSelectKey().get().equals(startLabel) &&
                             !(matchStep.getPreviousStep() instanceof EmptyStep) &&
                             !matchTraversal.getSteps().stream()
                                     .filter(step -> !(step instanceof MatchStep.MatchStartStep) &&
@@ -104,7 +105,7 @@ public final class MatchPredicateStrategy extends AbstractTraversalStrategy<Trav
                         matchStep.removeGlobalChild(matchTraversal);
                         matchTraversal.removeStep(0);                                     // remove MatchStartStep
                         matchTraversal.removeStep(matchTraversal.getSteps().size() - 1);    // remove MatchEndStep
-                        matchStep.getPreviousStep().addLabel((String)matchStep.getStartLabel().get());
+                        matchStep.getPreviousStep().addLabel(startLabel);
                         TraversalHelper.insertTraversal(matchStep.getPreviousStep(), matchTraversal, traversal);
                     }
                 });
@@ -112,6 +113,23 @@ public final class MatchPredicateStrategy extends AbstractTraversalStrategy<Trav
         });
     }
 
+    private String determineStartLabelForHasPullOut(final MatchStep<?, ?> matchStep) {
+        if (!(matchStep.getTraversal().getParent() instanceof EmptyStep))
+            return null;
+        else {
+            final String startLabel = MatchStep.Helper.computeStartLabel(matchStep.getGlobalChildren());
+            Step<?, ?> previousStep = matchStep.getPreviousStep();
+            if(previousStep.getLabels().contains(startLabel))
+                return startLabel;
+            while (!(previousStep instanceof EmptyStep)) {
+                if (!previousStep.getLabels().isEmpty())
+                    return null;
+                previousStep = previousStep.getPreviousStep();
+            }
+            return startLabel;
+        }
+    }
+
     public static MatchPredicateStrategy instance() {
         return INSTANCE;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6e937659/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
index 16f1f7f..eb2444c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
@@ -352,10 +352,7 @@ public final class TraversalHelper {
             if (((MatchStep.MatchStartStep) startStep).getSelectKey().isPresent())
                 variables.add(Scoping.Variable.START);
         } else if (startStep instanceof MatchStep) {
-            if (((MatchStep) startStep).getStartLabel().isPresent())
-                variables.add(Scoping.Variable.START);
-            else
-                ((MatchStep<?, ?>) startStep).getGlobalChildren().forEach(child -> TraversalHelper.getVariableLocations(variables, child));
+            ((MatchStep<?, ?>) startStep).getGlobalChildren().forEach(child -> TraversalHelper.getVariableLocations(variables, child));
         } else if (startStep instanceof ConjunctionStep || startStep instanceof NotStep || startStep instanceof WhereTraversalStep)
             ((TraversalParent) startStep).getLocalChildren().forEach(child -> TraversalHelper.getVariableLocations(variables, child));
         ///

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6e937659/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStepTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStepTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStepTest.java
index 67da0c9..6fd1410 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStepTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStepTest.java
@@ -62,7 +62,6 @@ public class MatchStepTest extends StepTest {
         final Traversal.Admin<?, ?> traversal = __.match(as("a").out().as("b"), as("c").path().as("d")).asAdmin();
         final MatchStep<?, ?> matchStep = (MatchStep<?, ?>) traversal.getStartStep();
         assertEquals(MatchStep.class, traversal.getStartStep().getClass());
-        assertEquals("a", matchStep.getStartLabel().get());
         assertEquals(2, matchStep.getGlobalChildren().size());
         Traversal.Admin<Object, Object> pattern = matchStep.getGlobalChildren().get(0);
         assertEquals("a", ((MatchStep.MatchStartStep) pattern.getStartStep()).getSelectKey().get());
@@ -83,7 +82,6 @@ public class MatchStepTest extends StepTest {
         assertEquals(1, new HashSet<>(traversals).size()); // the two patterns should pre-compile to the same traversal
         traversals.forEach(traversal -> {
             final MatchStep<?, ?> matchStep = (MatchStep<?, ?>) traversal.getStartStep();
-            assertEquals("a", matchStep.getStartLabel().get());
             assertEquals(2, matchStep.getGlobalChildren().size());
             Traversal.Admin<Object, Object> pattern = matchStep.getGlobalChildren().get(0);
             assertEquals("a", ((MatchStep.MatchStartStep) pattern.getStartStep()).getSelectKey().get());
@@ -110,7 +108,6 @@ public class MatchStepTest extends StepTest {
         assertEquals(1, new HashSet<>(traversals).size());   // the two patterns should pre-compile to the same traversal
         traversals.forEach(traversal -> {
             MatchStep<?, ?> matchStep = (MatchStep<?, ?>) traversal.getStartStep();
-            assertEquals("a", matchStep.getStartLabel().get());
             assertEquals(2, matchStep.getGlobalChildren().size());
             Traversal.Admin<Object, Object> pattern = matchStep.getGlobalChildren().get(0);
             assertEquals("a", ((MatchStep.MatchStartStep) pattern.getStartStep()).getSelectKey().get());

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6e937659/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategyTest.java
index 6ca4f0b..8524334 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchPredicateStrategyTest.java
@@ -117,8 +117,12 @@ public class MatchPredicateStrategyTest {
         static Iterable<Object[]> generateTestParameters() {
 
             return Arrays.asList(new Traversal[][]{
-                    {__.out().match(as("a").has("name", "marko"), as("a").out().as("b")), __.out().as("a").has("name", "marko").match(as("a").out().as("b"))},
-                    // {__.match("a", as("a").out().as("b")).where(as("b").out("knows").as("c")), __.match("a", as("a").out().as("b"), as("b").where(out("knows").as("c")))},
+                    {__.out().match(as("a").has("name", "marko"), as("a").out().as("b")), __.out().as("a").has("name", "marko").match(as("a").out().as("b"))}, // has() pull out
+                    {__.out().as("a").match(as("a").has("name", "marko"), as("a").out().as("b")), __.out().as("a").has("name", "marko").match(as("a").out().as("b"))}, // has() pull out
+                    {__.out().as("a").out().match(as("a").has("name", "marko"), as("a").out().as("b")), __.out().as("a").out().match(as("a").has("name", "marko"), as("a").out().as("b"))}, // no has() pull out
+                    {__.map(__.match(as("a").has("name", "marko"), as("a").out().as("b"))), __.map(__.match(as("a").has("name", "marko"), as("a").out().as("b")))}, // no has() pull out
+                    {__.out().as("c").match(as("a").has("name", "marko"), as("a").out().as("b")), __.out().as("c").match(as("a").has("name", "marko"), as("a").out().as("b"))}, // no has() pull out
+                    //{__.match(as("a").out().as("b")).where(as("b").out("knows").as("c")), __.match(as("a").out().as("b"), as("b").where(__.out("knows").as("c")))},
             });
         }
     }


[5/6] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/master' into resultset-refactor

Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/master' into resultset-refactor


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

Branch: refs/heads/resultset-refactor
Commit: ac53d5a6b8da8052a53a159931a642170f7d928c
Parents: 35122af d5b70be
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jun 26 13:34:43 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jun 26 13:34:43 2015 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  2 +
 bin/process-docs.sh                             |  2 +-
 docs/src/the-traversal.asciidoc                 | 26 ++++-----
 .../process/traversal/step/map/MatchStep.java   | 16 ++----
 .../optimization/MatchPredicateStrategy.java    | 26 +++++++--
 .../process/traversal/util/TraversalHelper.java |  5 +-
 .../traversal/step/map/MatchStepTest.java       |  3 --
 .../MatchPredicateStrategyTest.java             | 14 ++++-
 .../traversal/step/map/GroovyMatchTest.groovy   |  8 +--
 .../process/traversal/step/map/MatchTest.java   | 17 +++---
 .../gremlin/hadoop/structure/HadoopGraph.java   |  4 +-
 .../MultiMetaNeo4jGraphNativeNeo4jTest.java     | 36 +++++++++++++
 .../NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java | 36 +++++++++++++
 .../neo4j/process/NativeNeo4jCypherTest.java    |  3 +-
 .../MultiMetaNeo4jGraphNativeNeo4jTest.java     | 35 ------------
 .../NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java | 35 ------------
 .../tinkergraph/structure/TinkerGraphTest.java  | 56 +++-----------------
 17 files changed, 150 insertions(+), 174 deletions(-)
----------------------------------------------------------------------



[3/6] incubator-tinkerpop git commit: moved XXXNeo4jTest to neo4j directory as it tests both structure and process concepts.

Posted by sp...@apache.org.
moved XXXNeo4jTest to neo4j directory as it tests both structure and process concepts.


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

Branch: refs/heads/resultset-refactor
Commit: bc130ff5ab04633313f185e4edfef4f44e848c59
Parents: 6e93765
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Jun 26 09:31:30 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri Jun 26 09:31:30 2015 -0600

----------------------------------------------------------------------
 .../MultiMetaNeo4jGraphNativeNeo4jTest.java     | 36 ++++++++++++++++++++
 .../NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java | 36 ++++++++++++++++++++
 .../neo4j/process/NativeNeo4jCypherTest.java    |  3 +-
 .../MultiMetaNeo4jGraphNativeNeo4jTest.java     | 35 -------------------
 .../NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java | 35 -------------------
 5 files changed, 74 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bc130ff5/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/MultiMetaNeo4jGraphNativeNeo4jTest.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/MultiMetaNeo4jGraphNativeNeo4jTest.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/MultiMetaNeo4jGraphNativeNeo4jTest.java
new file mode 100644
index 0000000..2382d84
--- /dev/null
+++ b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/MultiMetaNeo4jGraphNativeNeo4jTest.java
@@ -0,0 +1,36 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one
+ *  * or more contributor license agreements.  See the NOTICE file
+ *  * distributed with this work for additional information
+ *  * regarding copyright ownership.  The ASF licenses this file
+ *  * to you under the Apache License, Version 2.0 (the
+ *  * "License"); you may not use this file except in compliance
+ *  * with the License.  You may obtain a copy of the License at
+ *  *
+ *  * http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing,
+ *  * software distributed under the License is distributed on an
+ *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  * KIND, either express or implied.  See the License for the
+ *  * specific language governing permissions and limitations
+ *  * under the License.
+ *
+ */
+
+package org.apache.tinkerpop.gremlin.neo4j;
+
+import org.apache.tinkerpop.gremlin.GraphProviderClass;
+import org.apache.tinkerpop.gremlin.neo4j.MultiMetaNeo4jGraphProvider;
+import org.apache.tinkerpop.gremlin.neo4j.NativeNeo4jSuite;
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@RunWith(NativeNeo4jSuite.class)
+@GraphProviderClass(provider = MultiMetaNeo4jGraphProvider.class, graph = Neo4jGraph.class)
+public class MultiMetaNeo4jGraphNativeNeo4jTest {
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bc130ff5/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java
new file mode 100644
index 0000000..5783721
--- /dev/null
+++ b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java
@@ -0,0 +1,36 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one
+ *  * or more contributor license agreements.  See the NOTICE file
+ *  * distributed with this work for additional information
+ *  * regarding copyright ownership.  The ASF licenses this file
+ *  * to you under the Apache License, Version 2.0 (the
+ *  * "License"); you may not use this file except in compliance
+ *  * with the License.  You may obtain a copy of the License at
+ *  *
+ *  * http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing,
+ *  * software distributed under the License is distributed on an
+ *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  * KIND, either express or implied.  See the License for the
+ *  * specific language governing permissions and limitations
+ *  * under the License.
+ *
+ */
+
+package org.apache.tinkerpop.gremlin.neo4j;
+
+import org.apache.tinkerpop.gremlin.GraphProviderClass;
+import org.apache.tinkerpop.gremlin.neo4j.NativeNeo4jSuite;
+import org.apache.tinkerpop.gremlin.neo4j.NoMultiNoMetaNeo4jGraphProvider;
+import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@RunWith(NativeNeo4jSuite.class)
+@GraphProviderClass(provider = NoMultiNoMetaNeo4jGraphProvider.class, graph = Neo4jGraph.class)
+public class NoMultiNoMetaNeo4jGraphNativeNeo4jTest {
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bc130ff5/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/NativeNeo4jCypherTest.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/NativeNeo4jCypherTest.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/NativeNeo4jCypherTest.java
index 5fdd818..7061b98 100644
--- a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/NativeNeo4jCypherTest.java
+++ b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/NativeNeo4jCypherTest.java
@@ -191,7 +191,8 @@ public class NativeNeo4jCypherTest extends AbstractNeo4jGremlinTest {
                         as("d").where(P.neq("a"))).select().by("name"),
                 () -> n.cypher("MATCH (a)<-[:writtenBy]-(b), (b)-[:followedBy]->(c), (c)-[:writtenBy]->(d) WHERE a <> d AND a.name = 'Garcia' AND 'artist' IN labels(a) RETURN a, b, c, d").select().by("name"),
                 ///
-                () -> g.V().as("a").out("followedBy").as("b").match(
+                () -> g.V().match(
+                        as("a").out("followedBy").as("b"),
                         as("a").has(T.label, "song").has("performances", P.gt(10)),
                         as("a").out("writtenBy").as("c"),
                         as("b").out("writtenBy").as("c")).select().by("name"),

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bc130ff5/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/MultiMetaNeo4jGraphNativeNeo4jTest.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/MultiMetaNeo4jGraphNativeNeo4jTest.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/MultiMetaNeo4jGraphNativeNeo4jTest.java
deleted file mode 100644
index 1015799..0000000
--- a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/MultiMetaNeo4jGraphNativeNeo4jTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  * http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *
- */
-
-package org.apache.tinkerpop.gremlin.neo4j.structure;
-
-import org.apache.tinkerpop.gremlin.GraphProviderClass;
-import org.apache.tinkerpop.gremlin.neo4j.MultiMetaNeo4jGraphProvider;
-import org.apache.tinkerpop.gremlin.neo4j.NativeNeo4jSuite;
-import org.junit.runner.RunWith;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@RunWith(NativeNeo4jSuite.class)
-@GraphProviderClass(provider = MultiMetaNeo4jGraphProvider.class, graph = Neo4jGraph.class)
-public class MultiMetaNeo4jGraphNativeNeo4jTest {
-}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bc130ff5/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java
deleted file mode 100644
index c83651d..0000000
--- a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- *  * Licensed to the Apache Software Foundation (ASF) under one
- *  * or more contributor license agreements.  See the NOTICE file
- *  * distributed with this work for additional information
- *  * regarding copyright ownership.  The ASF licenses this file
- *  * to you under the Apache License, Version 2.0 (the
- *  * "License"); you may not use this file except in compliance
- *  * with the License.  You may obtain a copy of the License at
- *  *
- *  * http://www.apache.org/licenses/LICENSE-2.0
- *  *
- *  * Unless required by applicable law or agreed to in writing,
- *  * software distributed under the License is distributed on an
- *  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  * KIND, either express or implied.  See the License for the
- *  * specific language governing permissions and limitations
- *  * under the License.
- *
- */
-
-package org.apache.tinkerpop.gremlin.neo4j.structure;
-
-import org.apache.tinkerpop.gremlin.GraphProviderClass;
-import org.apache.tinkerpop.gremlin.neo4j.NativeNeo4jSuite;
-import org.apache.tinkerpop.gremlin.neo4j.NoMultiNoMetaNeo4jGraphProvider;
-import org.junit.runner.RunWith;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@RunWith(NativeNeo4jSuite.class)
-@GraphProviderClass(provider = NoMultiNoMetaNeo4jGraphProvider.class, graph = Neo4jGraph.class)
-public class NoMultiNoMetaNeo4jGraphNativeNeo4jTest {
-}


[6/6] incubator-tinkerpop git commit: Refactored ResultSet pretty heavily.

Posted by sp...@apache.org.
Refactored ResultSet pretty heavily.

Added a some() method to get some specified number of Result objects back and refactored the implementation of one().


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

Branch: refs/heads/resultset-refactor
Commit: 382ccbfecbcbb4a6eff3121cd48b26f1fa9ea52d
Parents: ac53d5a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jun 26 13:57:58 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jun 26 13:57:58 2015 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/driver/ResultQueue.java   |  91 ++++++++++------
 .../tinkerpop/gremlin/driver/ResultSet.java     |  43 ++------
 .../server/GremlinDriverIntegrateTest.java      | 105 ++++++++++++++++++-
 3 files changed, 168 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/382ccbfe/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
index 6f33343..cc65e4d 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
@@ -19,34 +19,41 @@
 package org.apache.tinkerpop.gremlin.driver;
 
 import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
+import org.javatuples.Pair;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Queue;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * A queue of incoming {@link ResponseMessage} objects.  The queue is updated by the
- * {@link Handler.GremlinResponseHandler} until a response terminator is identified.  At that point the fetch
- * status is changed to {@link Status#COMPLETE} and all results have made it client side.
+ * {@link Handler.GremlinResponseHandler} until a response terminator is identified.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 final class ResultQueue {
-    public enum Status {
-        FETCHING,
-        COMPLETE
-    }
 
     private final LinkedBlockingQueue<Result> resultLinkedBlockingQueue;
 
-    private volatile Status status = Status.FETCHING;
-
     private final AtomicReference<Throwable> error = new AtomicReference<>();
 
     private final CompletableFuture<Void> readComplete;
 
+    private final Queue<Pair<CompletableFuture<List<Result>>,Integer>> waiting = new ConcurrentLinkedQueue<>();
+
+    /**
+     * Tracks the state of the "waiting" queue and whether or not results have been drained through it on
+     * read complete.  If they are then no additional "waiting" is required.
+     */
+    private final AtomicBoolean flushed = new AtomicBoolean(false);
+
     public ResultQueue(final LinkedBlockingQueue<Result> resultLinkedBlockingQueue, final CompletableFuture<Void> readComplete) {
         this.resultLinkedBlockingQueue = resultLinkedBlockingQueue;
         this.readComplete = readComplete;
@@ -54,6 +61,38 @@ final class ResultQueue {
 
     public void add(final Result result) {
         this.resultLinkedBlockingQueue.offer(result);
+
+        final Pair<CompletableFuture<List<Result>>, Integer> nextWaiting = waiting.peek();
+        if (nextWaiting != null && (resultLinkedBlockingQueue.size() > nextWaiting.getValue1() || readComplete.isDone())) {
+            final List<Result> results = new ArrayList<>(nextWaiting.getValue1());
+            resultLinkedBlockingQueue.drainTo(results, nextWaiting.getValue1());
+            nextWaiting.getValue0().complete(results);
+            waiting.remove(nextWaiting);
+        }
+    }
+
+    public CompletableFuture<List<Result>> await(final int items) {
+        final CompletableFuture<List<Result>> result = new CompletableFuture<>();
+        if (size() > items || readComplete.isDone()) {
+            // items are present so just drain to requested size if possible then complete it
+            final List<Result> results = new ArrayList<>(items);
+            resultLinkedBlockingQueue.drainTo(results, items);
+            result.complete(results);
+        } else {
+            // not enough items in the result queue so save this for callback later when the results actually arrive.
+            // only necessary to "wait" if we're not in the act of flushing already, in which case, no more waiting
+            // for additional results should be allowed.
+            if (flushed.get()) {
+                // just drain since we've flushed already
+                final List<Result> results = new ArrayList<>(items);
+                resultLinkedBlockingQueue.drainTo(results, items);
+                result.complete(results);
+            } else {
+                waiting.add(Pair.with(result, items));
+            }
+        }
+
+        return result;
     }
 
     public int size() {
@@ -66,38 +105,30 @@ final class ResultQueue {
         return this.size() == 0;
     }
 
-    public Result poll() {
-        Result result = null;
-        do {
-            if (error.get() != null) throw new RuntimeException(error.get());
-            try {
-                result = resultLinkedBlockingQueue.poll(10, TimeUnit.MILLISECONDS);
-            } catch (InterruptedException ie) {
-                error.set(new RuntimeException(ie));
-            }
-        } while (null == result && status == Status.FETCHING);
-
-        if (error.get() != null) throw new RuntimeException(error.get());
-
-        return result;
-    }
-
     public void drainTo(final Collection<Result> collection) {
         if (error.get() != null) throw new RuntimeException(error.get());
         resultLinkedBlockingQueue.drainTo(collection);
     }
 
-    public Status getStatus() {
-        return status;
-    }
-
     void markComplete() {
-        this.status = Status.COMPLETE;
         this.readComplete.complete(null);
+        this.flushWaiting();
     }
 
     void markError(final Throwable throwable) {
         error.set(throwable);
         this.readComplete.complete(null);
+        this.flushWaiting();
+    }
+
+    private void flushWaiting() {
+        while (waiting.peek() != null) {
+            final Pair<CompletableFuture<List<Result>>, Integer> nextWaiting = waiting.poll();
+            final List<Result> results = new ArrayList<>(nextWaiting.getValue1());
+            resultLinkedBlockingQueue.drainTo(results, nextWaiting.getValue1());
+            nextWaiting.getValue0().complete(results);
+        }
+
+        flushed.set(true);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/382ccbfe/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
index 74ce9b2..66a9ff0 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultSet.java
@@ -81,41 +81,23 @@ public final class ResultSet implements Iterable<Result> {
      * Determines if there are any remaining items being streamed to the client.
      */
     public boolean isExhausted() {
-        if (!resultQueue.isEmpty())
-            return false;
-
-        internalAwaitItems(1);
-
-        assert !resultQueue.isEmpty() || allItemsAvailable();
-        return resultQueue.isEmpty();
+        return !(!allItemsAvailable() || !resultQueue.isEmpty());
     }
 
     /**
      * Get the next {@link Result} from the stream, blocking until one is available.
      */
     public Result one() {
-        Result result = resultQueue.poll();
-        if (result != null)
-            return result;
-
-        internalAwaitItems(1);
-
-        result = resultQueue.poll();
-        if (result != null)
-            return result;
-        else
-            return null;
+        return some(1).join().get(0);
     }
 
     /**
-     * Wait for some number of items to be available on the client. The future will contain the number of items
-     * available which may or may not be the number the caller was waiting for.
+     * The returned {@link CompletableFuture} completes when the number of items specified are available.  The
+     * number returned will be equal to or less than that number.  They will only be less if the stream is
+     * completed and there are less than that number specified available.
      */
-    public CompletableFuture<Integer> awaitItems(final int items) {
-        if (allItemsAvailable())
-            CompletableFuture.completedFuture(getAvailableItemCount());
-
-        return CompletableFuture.supplyAsync(() -> internalAwaitItems(items), executor);
+    public CompletableFuture<List<Result>> some(final int items) {
+        return resultQueue.await(items);
     }
 
     /**
@@ -159,15 +141,4 @@ public final class ResultSet implements Iterable<Result> {
             }
         };
     }
-
-    private int internalAwaitItems(final int items) {
-        while (!allItemsAvailable() && getAvailableItemCount() < items) {
-            if (!channel.isOpen()) {
-                onChannelError.get();
-                throw new RuntimeException("Error while processing results from channel - check client and server logs for more information");
-            }
-        }
-
-        return getAvailableItemCount();
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/382ccbfe/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index 1417ce9..1b5f6c5 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@ -41,6 +41,7 @@ import org.junit.rules.TestName;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
@@ -53,6 +54,7 @@ import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.core.StringStartsWith.startsWith;
 import static org.junit.Assert.*;
 
@@ -170,6 +172,96 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
         final AtomicInteger counter = new AtomicInteger(0);
         results.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
+        assertEquals(9, counter.get());
+        assertThat(results.allItemsAvailable(), is(true));
+        assertThat(results.isExhausted(), is(true));
+
+        // cant stream it again
+        assertThat(results.stream().iterator().hasNext(), is(false));
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldIterate() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+        final Iterator<Result> itty = results.iterator();
+        final AtomicInteger counter = new AtomicInteger(0);
+        while (itty.hasNext()) {
+            counter.incrementAndGet();
+            assertEquals(counter.get(), itty.next().getInt());
+        }
+
+        assertEquals(9, counter.get());
+        assertThat(results.allItemsAvailable(), is(true));
+        assertThat(results.isExhausted(), is(true));
+
+        // can't stream it again
+        assertThat(results.iterator().hasNext(), is(false));
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldGetSomeThenSomeMore() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+        final CompletableFuture<List<Result>> batch1 = results.some(5);
+        final CompletableFuture<List<Result>> batch2 = results.some(5);
+        final CompletableFuture<List<Result>> batchNothingLeft = results.some(5);
+
+        assertEquals(5, batch1.get().size());
+        assertEquals(1, batch1.get().get(0).getInt());
+        assertEquals(2, batch1.get().get(1).getInt());
+        assertEquals(3, batch1.get().get(2).getInt());
+        assertEquals(4, batch1.get().get(3).getInt());
+        assertEquals(5, batch1.get().get(4).getInt());
+        assertThat(results.isExhausted(), is(false));
+
+        assertEquals(4, batch2.get().size());
+        assertEquals(6, batch2.get().get(0).getInt());
+        assertEquals(7, batch2.get().get(1).getInt());
+        assertEquals(8, batch2.get().get(2).getInt());
+        assertEquals(9, batch2.get().get(3).getInt());
+        assertThat(results.isExhausted(), is(true));
+
+        assertEquals(0, batchNothingLeft.get().size());
+
+        cluster.close();
+    }
+
+    @Test
+    public void shouldGetOneThenSomeThenSomeMore() throws Exception {
+        final Cluster cluster = Cluster.open();
+        final Client client = cluster.connect();
+
+        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
+        final Result one = results.one();
+        final CompletableFuture<List<Result>> batch1 = results.some(4);
+        final CompletableFuture<List<Result>> batch2 = results.some(5);
+        final CompletableFuture<List<Result>> batchNothingLeft = results.some(5);
+
+        assertEquals(1, one.getInt());
+
+        assertEquals(4, batch1.get().size());
+        assertEquals(2, batch1.get().get(0).getInt());
+        assertEquals(3, batch1.get().get(1).getInt());
+        assertEquals(4, batch1.get().get(2).getInt());
+        assertEquals(5, batch1.get().get(3).getInt());
+
+        assertEquals(4, batch2.get().size());
+        assertEquals(6, batch2.get().get(0).getInt());
+        assertEquals(7, batch2.get().get(1).getInt());
+        assertEquals(8, batch2.get().get(2).getInt());
+        assertEquals(9, batch2.get().get(3).getInt());
+        assertThat(results.isExhausted(), is(true));
+
+        assertEquals(0, batchNothingLeft.get().size());
 
         cluster.close();
     }
@@ -177,10 +269,13 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
     /**
      * This test arose from this issue: https://github.org/apache/tinkerpop/tinkerpop3/issues/515
      * <p/>
-     * ResultSet.all returns a CompleteableFuture that blocks on the worker pool until isExausted returns false.
-     * isExausted in turn needs a thread on the worker pool to even return. So its totally possible to consume all
+     * ResultSet.all returns a CompletableFuture that blocks on the worker pool until isExhausted returns false.
+     * isExhausted in turn needs a thread on the worker pool to even return. So its totally possible to consume all
      * threads on the worker pool waiting for .all to finish such that you can't even get one to wait for
-     * isExausted to run.
+     * isExhausted to run.
+     * <p/>
+     * Note that all() doesn't work as described above anymore.  It waits for callback on readComplete rather
+     * than blocking on isExhausted.
      */
     @Test
     public void shouldAvoidDeadlockOnCallToResultSetDotAll() throws Exception {
@@ -377,8 +472,8 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
         final Client client = cluster.connect(name.getMethodName());
 
         final ResultSet results1 = client.submit("x = [1,2,3,4,5,6,7,8,9]");
-        final AtomicInteger counter = new AtomicInteger(0);
-        results1.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
+        assertEquals(9, results1.all().get().size());
+        assertThat(results1.isExhausted(), is(true));
 
         final ResultSet results2 = client.submit("x[0]+1");
         assertEquals(2, results2.all().get().get(0).getInt());