You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by da...@apache.org on 2017/02/17 16:42:44 UTC

[01/21] tinkerpop git commit: Fixed an optimization bug in LazyBarrierStrategy. RemoteStrategy should be responsible for network I/O concerns (and using bulking as the optimization). [Forced Update!]

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1599 7ca1c4de9 -> 629b5c17a (forced update)


Fixed an optimization bug in LazyBarrierStrategy. RemoteStrategy should be responsible for network I/O concerns (and using bulking as the optimization).


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

Branch: refs/heads/TINKERPOP-1599
Commit: 080306b099b3ca5dbf5bf5041447fd1a0557b9cb
Parents: 9d74372
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Feb 15 15:07:53 2017 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Feb 15 15:07:53 2017 -0700

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  3 ++-
 .../upgrade/release-3.2.x-incubating.asciidoc   | 26 ++++++++++++++++++++
 .../strategy/decoration/RemoteStrategy.java     |  8 +++++-
 .../optimization/LazyBarrierStrategy.java       |  2 +-
 .../optimization/LazyBarrierStrategyTest.java   | 19 +++++++-------
 .../Neo4jGraphStepStrategyTest.java             |  2 +-
 .../TinkerGraphStepStrategyTest.java            |  2 +-
 7 files changed, 47 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/080306b0/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index b550fe4..cf7312e 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,7 +26,8 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-
+* Fixed an optimization bug in `LazyBarrierStrategy` around appending barriers to the end of a `Traversal`.
+* `RemoteStrategy` is smart to try and append a `NoOpBarrierStep` in order to bulk traversers prior to network I/O.
 
 [[release-3-2-4]]
 TinkerPop 3.2.4 (Release Date: February 8, 2017)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/080306b0/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index c199238..1247433 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -22,6 +22,32 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 
 *Nine Inch Gremlins*
 
+TinkerPop 3.2.5
+---------------
+
+*Release Date: NOT OFFICIALLY RELEASED YET*
+
+Please see the link:https://github.com/apache/tinkerpop/blob/3.2.5/CHANGELOG.asciidoc#release-3-2-5[changelog] for a complete list of all the modifications that are part of this release.
+
+Upgrading for Users
+~~~~~~~~~~~~~~~~~~~
+
+Upgrading for Providers
+~~~~~~~~~~~~~~~~~~~~~~~
+
+LazyBarrierStrategy No Longer End Appends Barriers
+++++++++++++++++++++++++++++++++++++++++++++++++++
+
+`LazyBarrierStrategy` was trying to do to much by considering `Traverser` effects on network I/O by appending an
+`NoOpBarrierStrategy` to the end of the root traversal. This should not be accomplished by `LazyBarrierStrategy`,
+but instead by `RemoteStrategy`. `RemoteStrategy` now tries to barrier-append. This may effect the reasoninig logic in
+some `ProviderStrategies`. Most likely not, but just be aware.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1627[TINKERPOP-1627]
+
+TinkerGraph Deserialization
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
 TinkerPop 3.2.4
 ---------------
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/080306b0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/decoration/RemoteStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/decoration/RemoteStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/decoration/RemoteStrategy.java
index 38ceb95..14d3b36 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/decoration/RemoteStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/decoration/RemoteStrategy.java
@@ -24,6 +24,8 @@ import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
 import org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
@@ -47,7 +49,7 @@ public final class RemoteStrategy extends AbstractTraversalStrategy<TraversalStr
         implements TraversalStrategy.DecorationStrategy {
 
     private static final RemoteStrategy INSTANCE = new RemoteStrategy();
-
+    protected static final int MAX_BARRIER_SIZE = 1000;
     private final Optional<RemoteConnection> remoteConnection;
 
     private static final Set<Class<? extends DecorationStrategy>> POSTS = Collections.singleton(VertexProgramStrategy.class);
@@ -90,6 +92,10 @@ public final class RemoteStrategy extends AbstractTraversalStrategy<TraversalStr
         if (!(traversal.getParent() instanceof EmptyStep))
             return;
 
+        // given that we send traversers over the wire, try our best to bulk to limit network traffic
+        if (!(traversal.getEndStep() instanceof Barrier))
+            traversal.addStep(new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE));
+
         // verifications to ensure unsupported steps do not exist in the traversal
         if (Boolean.valueOf(System.getProperty("is.testing", "false")) &&
                 (TraversalHelper.hasStepOfAssignableClassRecursively(ProfileSideEffectStep.class, traversal) ||

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/080306b0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
index 1f2d758..29c04a7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
@@ -86,7 +86,7 @@ public final class LazyBarrierStrategy extends AbstractTraversalStrategy<Travers
                                     (((GraphStep) step).getIds().length == 0 && !(step.getNextStep() instanceof HasStep))))) {
                 if (foundFlatMap && !labeledPath &&
                         !(step.getNextStep() instanceof Barrier) &&
-                        (!(step.getNextStep() instanceof EmptyStep) || step.getTraversal().getParent() instanceof EmptyStep)) {
+                        !(step.getNextStep() instanceof EmptyStep)) {
                     final Step noOpBarrierStep = new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE);
                     TraversalHelper.copyLabels(step, noOpBarrierStep, true);
                     TraversalHelper.insertAfterStep(noOpBarrierStep, step, traversal);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/080306b0/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
index e1b9a94..f67abd1 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization;
 
-import com.sun.org.apache.regexp.internal.RE;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
@@ -88,20 +87,20 @@ public class LazyBarrierStrategyTest {
                 {__.repeat(__.out()).times(4), __.repeat(__.out()).times(4), Collections.emptyList()},
                 {__.repeat(__.out()).times(4), __.out().barrier(REPEAT_SIZE).out().barrier(REPEAT_SIZE).out().barrier(REPEAT_SIZE).out().barrier(REPEAT_SIZE), Collections.singletonList(RepeatUnrollStrategy.instance())},
                 {__.out().out().as("a").select("a").out(), __.out().out().barrier(LAZY_SIZE).as("a").select("a").out(), Collections.emptyList()},
-                {__.out().out().as("a").select("a").out(), __.out().out().barrier(LAZY_SIZE).as("a").select("a").barrier(PATH_SIZE).out().barrier(LAZY_SIZE), Collections.singletonList(PathRetractionStrategy.instance())},
-                {__.out().out().as("a").out().select("a").out(), __.out().out().barrier(LAZY_SIZE).as("a").out().select("a").barrier(PATH_SIZE).out().barrier(LAZY_SIZE), Collections.singletonList(PathRetractionStrategy.instance())},
-                {__.out().out().out().limit(10).out(), __.out().out().barrier(LAZY_SIZE).out().limit(10).out().barrier(LAZY_SIZE), Collections.emptyList()},
+                {__.out().out().as("a").select("a").out(), __.out().out().barrier(LAZY_SIZE).as("a").select("a").barrier(PATH_SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+                {__.out().out().as("a").out().select("a").out(), __.out().out().barrier(LAZY_SIZE).as("a").out().select("a").barrier(PATH_SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+                {__.out().out().out().limit(10).out(), __.out().out().barrier(LAZY_SIZE).out().limit(10).out(), Collections.emptyList()},
                 {__.V().out().in().where(P.neq("a")), __.V().out().barrier(LAZY_SIZE).in().barrier(LAZY_SIZE).where(P.neq("a")), Collections.emptyList()},
                 {__.V().as("a").out().in().where(P.neq("a")), __.V().as("a").out().in().where(P.neq("a")), Collections.emptyList()},
                 {__.out().out().in().where(P.neq("a")), __.out().out().barrier(LAZY_SIZE).in().barrier(LAZY_SIZE).where(P.neq("a")), Collections.emptyList()},
                 {__.out().as("a").out().in().where(P.neq("a")), __.out().as("a").out().in().where(P.neq("a")), Collections.emptyList()},
-                {__.out().as("a").out().in().where(P.neq("a")).out().out(), __.out().as("a").out().in().where(P.neq("a")).barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE), Collections.singletonList(PathRetractionStrategy.instance())},
-                {__.out().as("a").out().as("b").in().where(P.neq("a")).out().out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(PATH_SIZE).out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE), Collections.singletonList(PathRetractionStrategy.instance())},
+                {__.out().as("a").out().in().where(P.neq("a")).out().out(), __.out().as("a").out().in().where(P.neq("a")).barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+                {__.out().as("a").out().as("b").in().where(P.neq("a")).out().out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(PATH_SIZE).out().barrier(LAZY_SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
                 {__.out().as("a").out().as("b").in().where(P.neq("a")).out().out(), __.out().as("a").out().as("b").in().where(P.neq("a")).out().out(), Collections.emptyList()},
-                {__.out().as("a").out().as("b").in().where(P.neq("a")).out().select("b").out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(PATH_SIZE).out().select("b").barrier(PATH_SIZE).out().barrier(LAZY_SIZE), Collections.singletonList(PathRetractionStrategy.instance())},
-                {__.out().as("a").out().as("b").in().where(P.neq("a")).out().select("b").out().out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(PATH_SIZE).out().select("b").barrier(PATH_SIZE).out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE), Collections.singletonList(PathRetractionStrategy.instance())},
-                {__.V().out().out().groupCount().by(__.out().out().out()).out(), __.V().out().barrier(LAZY_SIZE).out().groupCount().by(__.out().out().barrier(LAZY_SIZE).out()).out().barrier(LAZY_SIZE), Collections.emptyList()},
-                {__.V().out().out().groupCount().by(__.out().out().out()).out().as("a"), __.V().out().barrier(LAZY_SIZE).out().groupCount().by(__.out().out().barrier(LAZY_SIZE).out()).out().barrier(LAZY_SIZE).as("a"), Collections.emptyList()}
+                {__.out().as("a").out().as("b").in().where(P.neq("a")).out().select("b").out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(PATH_SIZE).out().select("b").barrier(PATH_SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+                {__.out().as("a").out().as("b").in().where(P.neq("a")).out().select("b").out().out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(PATH_SIZE).out().select("b").barrier(PATH_SIZE).out().barrier(LAZY_SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+                {__.V().out().out().groupCount().by(__.out().out().out()).out(), __.V().out().barrier(LAZY_SIZE).out().groupCount().by(__.out().out().barrier(LAZY_SIZE).out()).out(), Collections.emptyList()},
+                {__.V().out().out().groupCount().by(__.out().out().out()).out().as("a"), __.V().out().barrier(LAZY_SIZE).out().groupCount().by(__.out().out().barrier(LAZY_SIZE).out()).out().as("a"), Collections.emptyList()}
         });
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/080306b0/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/strategy/optimization/Neo4jGraphStepStrategyTest.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/strategy/optimization/Neo4jGraphStepStrategyTest.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/strategy/optimization/Neo4jGraphStepStrategyTest.java
index 77a2610..1150cf3 100644
--- a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/strategy/optimization/Neo4jGraphStepStrategyTest.java
+++ b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/strategy/optimization/Neo4jGraphStepStrategyTest.java
@@ -130,7 +130,7 @@ public class Neo4jGraphStepStrategyTest {
                 {__.V().has("name", P.eq("marko").and(P.eq("bob").or(P.eq("stephen")))).out("knows"),
                         g_V("name", eq("marko"), "name", P.eq("bob").or(eq("stephen"))).out("knows"), Collections.emptyList()},
                 ///////
-                {__.V().out().out().V().has("name", "marko").out(), g_V().out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).asAdmin().addStep(V("name", eq("marko"))).barrier(LAZY_SIZE).out().barrier(LAZY_SIZE), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
+                {__.V().out().out().V().has("name", "marko").out(), g_V().out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).asAdmin().addStep(V("name", eq("marko"))).barrier(LAZY_SIZE).out(), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
                 {__.V().out().out().V().has("name", "marko").as("a").out(), g_V().out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).asAdmin().addStep(V("name", eq("marko"))).barrier(LAZY_SIZE).as("a").out(), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
                 {__.V().out().V().has("age", gt(32)).barrier(10).has("name", "marko").as("a"), g_V().out().barrier(LAZY_SIZE).asAdmin().addStep(V("age", gt(32), "name", eq("marko"))).barrier(LAZY_SIZE).barrier(10).as("a"), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
                 {__.V().out().V().has("age", gt(32)).barrier(10).has("name", "marko").as("a"), g_V().out().barrier(LAZY_SIZE).asAdmin().addStep(V("age", gt(32), "name", eq("marko"))).barrier(LAZY_SIZE).barrier(10).as("a"), TraversalStrategies.GlobalCache.getStrategies(Neo4jGraph.class).toList()},

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/080306b0/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/strategy/optimization/TinkerGraphStepStrategyTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/strategy/optimization/TinkerGraphStepStrategyTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/strategy/optimization/TinkerGraphStepStrategyTest.java
index c62bd5a..b44d90f 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/strategy/optimization/TinkerGraphStepStrategyTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/strategy/optimization/TinkerGraphStepStrategyTest.java
@@ -131,7 +131,7 @@ public class TinkerGraphStepStrategyTest {
                 {__.V().has("name", P.eq("marko").and(P.eq("bob").or(P.eq("stephen")))).out("knows"),
                         g_V("name", eq("marko"), "name", P.eq("bob").or(eq("stephen"))).out("knows"), Collections.emptyList()},
                 ///////
-                {__.V().out().out().V().has("name", "marko").out(), g_V().out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).asAdmin().addStep(V("name", eq("marko"))).barrier(LAZY_SIZE).out().barrier(LAZY_SIZE), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
+                {__.V().out().out().V().has("name", "marko").out(), g_V().out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).asAdmin().addStep(V("name", eq("marko"))).barrier(LAZY_SIZE).out(), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
                 {__.V().out().out().V().has("name", "marko").as("a").out(), g_V().out().barrier(LAZY_SIZE).out().barrier(LAZY_SIZE).asAdmin().addStep(V("name", eq("marko"))).barrier(LAZY_SIZE).as("a").out(), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
                 {__.V().out().V().has("age", gt(32)).barrier(10).has("name", "marko").as("a"), g_V().out().barrier(LAZY_SIZE).asAdmin().addStep(V("age", gt(32), "name", eq("marko"))).barrier(LAZY_SIZE).barrier(10).as("a"), Arrays.asList(InlineFilterStrategy.instance(), FilterRankingStrategy.instance(), LazyBarrierStrategy.instance())},
                 {__.V().out().V().has("age", gt(32)).barrier(10).has("name", "marko").as("a"), g_V().out().barrier(LAZY_SIZE).asAdmin().addStep(V("age", gt(32), "name", eq("marko"))).barrier(LAZY_SIZE).barrier(10).as("a"), TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList()},


[21/21] tinkerpop git commit: updated changlog, added docs

Posted by da...@apache.org.
updated changlog, added docs


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

Branch: refs/heads/TINKERPOP-1599
Commit: af1c579a8b99db1512d3714e94beda501b69d23e
Parents: b711b5e
Author: davebshow <da...@gmail.com>
Authored: Wed Feb 15 18:26:08 2017 -0500
Committer: davebshow <da...@gmail.com>
Committed: Fri Feb 17 11:42:24 2017 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  5 ++
 .../src/reference/gremlin-applications.asciidoc | 71 ++++++++++++++++++++
 .../upgrade/release-3.2.x-incubating.asciidoc   | 30 ++++++++-
 3 files changed, 103 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/af1c579a/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index de78d24..744ffee 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -29,6 +29,11 @@ TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 * 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`.
 * `TraverserIterator` in GremlinServer is smart to try and bulk traversers prior to network I/O.
+* Improved Gremlin-Python Driver implementation by adding a threaded client with basic connection pooling and support for pluggable websocket clients.
+
+Improvements
+^^^^^^^^^^^^
+TINKERPOP-1599 implement real gremlin-python driver
 
 [[release-3-2-4]]
 TinkerPop 3.2.4 (Release Date: February 8, 2017)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/af1c579a/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index 7ca4efd..ece0a82 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -762,6 +762,77 @@ The above code demonstrates using the `TitanIoRegistry` which is an `IoRegistry`
 what classes (from Titan in this case) to auto-register during serialization.  Gremlin Server roughly uses this same
 approach when it configures it's serializers, so using this same model will ensure compatibility when making requests.
 
+[[connecting-via-python]]
+Connecting via Python
+~~~~~~~~~~~~~~~~~~~~~
+
+[source,python]
+----
+pip install gremlinpython
+----
+
+TinkerPop3 also includes a client for Python-based applications.  It is referred to as Gremlin-Python Driver.
+The `Client` class implementation/interface is based on the Java Driver, with some restrictions. Most notably,
+Gremlin-Python does not yet implement the `Cluster` class. Instead, `Client` is instantiated directly.
+Usage is as follows:
+
+[source,python]
+----
+from gremlin_python.driver import client <1>
+client = client.Client('ws://localhost:8182/gremlin', 'g') <2>
+----
+
+<1> Import the Gremlin-Python `client` module.
+<2> Opens a reference to `localhost` - note that there are various configuration options that can be passed
+to the `Client` object upon instantiation as keyword arguments.
+
+Once a `Client` instance is ready, it is possible to issue some Gremlin:
+
+[source,python]
+----
+result_set = client.submit("[1,2,3,4]")  <1>
+future_results = result_set.all()  <2>
+results = future_results.result() <3>
+assert results == [1, 2, 3, 4] <4>
+
+future_result_set = client.submitAsync("[1,2,3,4]") <5>
+result_set = future_result_set.result() <6>
+result = result_set.one() <7>
+assert results == [1, 2, 3, 4] <8>
+assert result_set.done.done() <9>
+----
+
+<1> Submit a script that simply returns a `List` of integers.  This method blocks until the request is written to
+the server and a `ResultSet` is constructed.
+<2> Even though the `ResultSet` is constructed, it does not mean that the server has sent back the results (or even
+evaluated the script potentially).  The `ResultSet` is just a holder that is awaiting the results from the server. The `all` method
+returns a `concurrent.futures.Future` that resolves to a list when it is complete.
+<3> Block until the the script is evaluated and results are sent back by the server.
+<4> Verify the result.
+<5> Submit the same script to the server but don't block.
+<6> Wait until request is written to the server and `ResultSet` is constructed.
+<7> Read a single result off the result stream.
+<8> Again, verify the result.
+<9> Verify that the all results have been read and stream is closed.
+
+Configuration
+^^^^^^^^^^^^^
+
+The following table describes the various configuration options for the Gremlin-Python Driver. They
+can be passed to the `Client` instance as keyword arguments:
+
+[width="100%",cols="3,10,^2",options="header"]
+|=========================================================
+|Key |Description |Default
+|protocol_factory |A callable that returns an instance of `AbstractBaseProtocol`. |`gremlin_python.driver.protocol.GremlinServerWSProtocol`
+|transport_factory |A callable that returns an instance of `AbstractBaseTransport`. |`gremlin_python.driver.tornado.transport.TornadoTransport`
+|pool_size |The number of connections used by the pool. |4
+|max_workers |Maximum number of worker threads. |Number of CPUs * 5
+|message_serializer |The message serializer implementation.|`gremlin_python.driver.serializer.GraphSONMessageSerializer`
+|password |The password to submit on requests that require authentication. |""
+|username |The username to submit on requests that require authentication. |""
+|=========================================================
+
 Connecting via REST
 ~~~~~~~~~~~~~~~~~~~
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/af1c579a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 1247433..6bfc028 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -32,6 +32,33 @@ Please see the link:https://github.com/apache/tinkerpop/blob/3.2.5/CHANGELOG.asc
 Upgrading for Users
 ~~~~~~~~~~~~~~~~~~~
 
+Gremlin-Python Driver
+^^^^^^^^^^^^^^^^^^^^^
+Gremlin-Python now offers a more complete driver implementation that uses connection pooling and
+the Python `concurrent.futures` module to provide asynchronous I/0 using threading. The default underlying
+websocket client implementation is still provided by Tornado, but it is trivial to plug in another client by
+defining the `Transport` interface.
+
+Using the `DriverRemoteConnection` class is the exact same as in previous versions; however,
+`DriverRemoteConnection` now uses the new `Client` class to submit messages to the server.
+
+The `Client` class implementation/interface is based on the Java Driver, with some restrictions.
+Most notably, Gremlin-Python does not yet implement the `Cluster` class. Instead, `Client` is
+instantiated directly. Usage is as follows:
+
+[source,python]
+----
+from gremlin_python.driver import client
+
+client = client.Client('ws://localhost:8182/gremlin', 'g')
+result_set = client.submit('1 + 1')
+future_results = result_set.all()  # returns a concurrent.futures.Future
+results = future_results.result()  # returns a list
+assert results == [2]
+----
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1599[TINKERPOP-1599]
+
 Upgrading for Providers
 ~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -45,9 +72,6 @@ some `ProviderStrategies`. Most likely not, but just be aware.
 
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1627[TINKERPOP-1627]
 
-TinkerGraph Deserialization
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
 TinkerPop 3.2.4
 ---------------
 


[15/21] tinkerpop git commit: allow client users to pass bindings as a second arg

Posted by da...@apache.org.
allow client users to pass bindings as a second arg


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

Branch: refs/heads/TINKERPOP-1599
Commit: b711b5e667c53328aed1c5fe9baad51fde5dc0b1
Parents: e3067e9
Author: davebshow <da...@gmail.com>
Authored: Wed Feb 15 17:57:32 2017 -0500
Committer: davebshow <da...@gmail.com>
Committed: Fri Feb 17 11:36:57 2017 -0500

----------------------------------------------------------------------
 .../src/main/jython/gremlin_python/driver/client.py          | 8 +++++---
 gremlin-python/src/main/jython/tests/driver/test_client.py   | 4 ++++
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b711b5e6/gremlin-python/src/main/jython/gremlin_python/driver/client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/client.py b/gremlin-python/src/main/jython/gremlin_python/driver/client.py
index 0314a44..c7c7037 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/client.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/client.py
@@ -103,10 +103,10 @@ class Client:
             self._url, self._traversal_source, protocol,
             self._transport_factory, self._executor, self._pool)
 
-    def submit(self, message):
-        return self.submitAsync(message).result()
+    def submit(self, message, bindings=None):
+        return self.submitAsync(message, bindings=bindings).result()
 
-    def submitAsync(self, message):
+    def submitAsync(self, message, bindings=None):
         if isinstance(message, traversal.Bytecode):
             message = request.RequestMessage(
                 processor='traversal', op='bytecode',
@@ -117,5 +117,7 @@ class Client:
                 processor='', op='eval',
                 args={'gremlin': message,
                       'aliases': {'g': self._traversal_source}})
+            if bindings:
+                message.args.update(bindings)
         conn = self._pool.get(True)
         return conn.write(message)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b711b5e6/gremlin-python/src/main/jython/tests/driver/test_client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_client.py b/gremlin-python/src/main/jython/tests/driver/test_client.py
index 02582a1..416caab 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_client.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_client.py
@@ -40,6 +40,10 @@ def test_client_simple_eval(client):
     assert client.submit('1 + 1').all().result()[0] == 2
 
 
+def test_client_simple_eval_bindings(client):
+    assert client.submit('x + x', {'x': 2}).all().result()[0] == 4
+
+
 def test_client_eval_traversal(client):
     assert len(client.submit('g.V()').all().result()) == 6
 


[20/21] tinkerpop git commit: close client in documentation examples

Posted by da...@apache.org.
close client in documentation examples


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

Branch: refs/heads/TINKERPOP-1599
Commit: 629b5c17a46f4eb828507eb5db8b8303af6aa49d
Parents: af1c579
Author: davebshow <da...@gmail.com>
Authored: Fri Feb 17 11:34:56 2017 -0500
Committer: davebshow <da...@gmail.com>
Committed: Fri Feb 17 11:42:24 2017 -0500

----------------------------------------------------------------------
 docs/src/reference/gremlin-applications.asciidoc   | 3 +++
 docs/src/upgrade/release-3.2.x-incubating.asciidoc | 1 +
 2 files changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/629b5c17/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index ece0a82..8e0edc2 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -800,6 +800,8 @@ result_set = future_result_set.result() <6>
 result = result_set.one() <7>
 assert results == [1, 2, 3, 4] <8>
 assert result_set.done.done() <9>
+
+client.close() <10>
 ----
 
 <1> Submit a script that simply returns a `List` of integers.  This method blocks until the request is written to
@@ -814,6 +816,7 @@ returns a `concurrent.futures.Future` that resolves to a list when it is complet
 <7> Read a single result off the result stream.
 <8> Again, verify the result.
 <9> Verify that the all results have been read and stream is closed.
+<10> Close client and underlying pool connections.
 
 Configuration
 ^^^^^^^^^^^^^

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/629b5c17/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 6bfc028..78c276b 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -55,6 +55,7 @@ result_set = client.submit('1 + 1')
 future_results = result_set.all()  # returns a concurrent.futures.Future
 results = future_results.result()  # returns a list
 assert results == [2]
+client.close()  # don't forget to close underlying connections
 ----
 
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1599[TINKERPOP-1599]


[10/21] tinkerpop git commit: More javadocs/reference docs for GraphTraversal steps

Posted by da...@apache.org.
More javadocs/reference docs for GraphTraversal steps

Covered properties/values/valueMap/propertyMap CTR


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

Branch: refs/heads/TINKERPOP-1599
Commit: f45d793f23cc5dd90f5d27c68523606559713306
Parents: 14c7df9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Feb 17 09:19:06 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Feb 17 09:19:06 2017 -0500

----------------------------------------------------------------------
 docs/src/reference/the-traversal.asciidoc       | 40 ++++++++++++++++++++
 .../traversal/dsl/graph/GraphTraversal.java     | 12 ++++++
 2 files changed, 52 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f45d793f/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index b41cf4a..71a35c2 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -1625,6 +1625,33 @@ g.V().hasLabel('person').
   valueMap('name', 'rank')
 ----
 
+[properties-step]]
+Properties Step
+~~~~~~~~~~~~~~~
+
+The `properties()`-step (*map*) extracts properties from an `Element` in the traversal stream.
+
+[gremlin-groovy,theCrew]
+----
+g.V(1).properties()
+g.V(1).properties('location').valueMap()
+g.V(1).properties('location').has('endTime').valueMap()
+----
+
+[[propertymap-step]]
+PropertyMap Step
+~~~~~~~~~~~~~
+
+The `propertiesMap()`-step yields a Map representation of the properties of an element.
+
+[gremlin-groovy,modern]
+----
+g.V().propertyMap()
+g.V().propertyMap('age')
+g.V().propertyMap('age','blah')
+g.E().propertyMap()
+----
+
 [[range-step]]
 Range Step
 ~~~~~~~~~~
@@ -2221,6 +2248,19 @@ g.V().hasLabel('person').valueMap(true,'name')
 g.V().hasLabel('person').properties('location').valueMap(true)
 ----
 
+[values-step]]
+Values Step
+~~~~~~~~~~~
+
+The `values()`-step (*map*) extracts the values of properties from an `Element` in the traversal stream.
+
+[gremlin-groovy,theCrew]
+----
+g.V(1).values()
+g.V(1).values('location')
+g.V(1).properties('location').values()
+----
+
 [[vertex-steps]]
 Vertex Steps
 ~~~~~~~~~~~~

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f45d793f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index c5a65e0..d37bff6 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -281,6 +281,13 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
         return this.asAdmin().addStep(new ConstantStep<E, E2>(this.asAdmin(), e));
     }
 
+    /**
+     * A {@code V} step is usually used to start a traversal but it may also be used mid-traversal.
+     *
+     * @param vertexIdsOrElements vertices to inject into the traversal
+     * @return the traversal with an appended {@link GraphStep}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#graph-step">Reference Documentation - Graph Step</a>
+     */
     public default GraphTraversal<S, Vertex> V(final Object... vertexIdsOrElements) {
         this.asAdmin().getBytecode().addStep(Symbols.V, vertexIdsOrElements);
         return this.asAdmin().addStep(new GraphStep<>(this.asAdmin(), Vertex.class, false, vertexIdsOrElements));
@@ -470,6 +477,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param propertyKeys the properties to retrieve
      * @param <E2>         the value type of the returned properties
      * @return the traversal with an appended {@link PropertiesStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#properties-step">Reference Documentation - Properties Step</a>
      */
     public default <E2> GraphTraversal<S, ? extends Property<E2>> properties(final String... propertyKeys) {
         this.asAdmin().getBytecode().addStep(Symbols.properties, propertyKeys);
@@ -483,6 +491,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param propertyKeys the properties to retrieve their value from
      * @param <E2>         the value type of the properties
      * @return the traversal with an appended {@link PropertiesStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#values-step">Reference Documentation - Values Step</a>
      */
     public default <E2> GraphTraversal<S, E2> values(final String... propertyKeys) {
         this.asAdmin().getBytecode().addStep(Symbols.values, propertyKeys);
@@ -496,6 +505,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param propertyKeys the properties to retrieve
      * @param <E2>         the value type of the returned properties
      * @return the traversal with an appended {@link PropertyMapStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#propertymap-step">Reference Documentation - PropertyMap Step</a>
      */
     public default <E2> GraphTraversal<S, Map<String, E2>> propertyMap(final String... propertyKeys) {
         this.asAdmin().getBytecode().addStep(Symbols.propertyMap, propertyKeys);
@@ -509,6 +519,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param propertyKeys the properties to retrieve
      * @param <E2>         the value type of the returned properties
      * @return the traversal with an appended {@link PropertyMapStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#valuemap-step">Reference Documentation - ValueMap Step</a>
      */
     public default <E2> GraphTraversal<S, Map<String, E2>> valueMap(final String... propertyKeys) {
         this.asAdmin().getBytecode().addStep(Symbols.valueMap, propertyKeys);
@@ -523,6 +534,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param propertyKeys  the properties to retrieve
      * @param <E2>          the value type of the returned properties
      * @return the traversal with an appended {@link PropertyMapStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#valuemap-step">Reference Documentation - ValueMap Step</a>
      */
     public default <E2> GraphTraversal<S, Map<String, E2>> valueMap(final boolean includeTokens, final String... propertyKeys) {
         this.asAdmin().getBytecode().addStep(Symbols.valueMap, includeTokens, propertyKeys);


[16/21] tinkerpop git commit: a couple small fixes in tests

Posted by da...@apache.org.
a couple small fixes in tests


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

Branch: refs/heads/TINKERPOP-1599
Commit: aa848c1add11e67cedebb6a63d2a9e40f1cb2072
Parents: 1d203b7
Author: davebshow <da...@gmail.com>
Authored: Mon Jan 30 20:02:25 2017 -0500
Committer: davebshow <da...@gmail.com>
Committed: Fri Feb 17 11:36:57 2017 -0500

----------------------------------------------------------------------
 .../src/main/jython/gremlin_python/driver/protocol.py       | 1 -
 gremlin-python/src/main/jython/tests/conftest.py            | 9 +++++----
 gremlin-python/src/main/jython/tests/driver/test_client.py  | 5 -----
 3 files changed, 5 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aa848c1a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
index 2ace35e..279a8f5 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
@@ -95,7 +95,6 @@ class GremlinServerWSProtocol(AbstractBaseProtocol):
                 data = self._transport.read()
                 self.data_received(data, results_dict)
             else:
-                # result_set.done.set_result(None)
                 del results_dict[request_id]
         else:
             del results_dict[request_id]

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aa848c1a/gremlin-python/src/main/jython/tests/conftest.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/conftest.py b/gremlin-python/src/main/jython/tests/conftest.py
index 3ab64a8..49779ac 100644
--- a/gremlin-python/src/main/jython/tests/conftest.py
+++ b/gremlin-python/src/main/jython/tests/conftest.py
@@ -31,14 +31,15 @@ from gremlin_python.driver.tornado.transport import TornadoTransport
 
 @pytest.fixture
 def connection(request):
+    protocol = GremlinServerWSProtocol(
+        username='stephen', password='password')
+    executor = concurrent.futures.ThreadPoolExecutor(5)
+    pool = queue.Queue()
     try:
-        protocol = GremlinServerWSProtocol(
-            username='stephen', password='password')
-        executor = concurrent.futures.ThreadPoolExecutor(5)
-        pool = queue.Queue()
         conn = Connection('ws://localhost:45940/gremlin', 'g', protocol,
                           lambda: TornadoTransport(), executor, pool)
     except:
+        executor.shutdown()
         pytest.skip('Gremlin Server is not running')
     else:
         def fin():

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aa848c1a/gremlin-python/src/main/jython/tests/driver/test_client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_client.py b/gremlin-python/src/main/jython/tests/driver/test_client.py
index 6395d7b..2e0e96c 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_client.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_client.py
@@ -41,7 +41,6 @@ def test_client(client):
     message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
     result_set = client.submit(message)
     assert len(result_set.all().result()) == 6
-    client.close()
 
 def test_iterate_result_set(client):
     g = Graph().traversal()
@@ -52,7 +51,6 @@ def test_iterate_result_set(client):
     for result in result_set:
         results += result
     assert len(results) == 6
-    client.close()
 
 def test_client_async(client):
     g = Graph().traversal()
@@ -62,7 +60,6 @@ def test_client_async(client):
     assert not future.done()
     result_set = future.result()
     assert len(result_set.all().result()) == 6
-    client.close()
 
 def test_connection_share(client):
     # Overwrite fixture with pool_size=1 client
@@ -80,7 +77,6 @@ def test_connection_share(client):
     assert future.done()
     result_set = future.result()
     assert len(result_set.all().result()) == 6
-    client.close()
 
 def test_multi_conn_pool(client):
     g = Graph().traversal()
@@ -95,4 +91,3 @@ def test_multi_conn_pool(client):
     # with connection pool `future` may or may not be done here
     result_set = future.result()
     assert len(result_set.all().result()) == 6
-    client.close()


[11/21] tinkerpop git commit: Added javadoc/reference docs for key/value and javadoc on select CTR

Posted by da...@apache.org.
Added javadoc/reference docs for key/value and javadoc on select CTR


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

Branch: refs/heads/TINKERPOP-1599
Commit: 123abf9d1b5e48eba64c47203114d2c79b3732bf
Parents: f45d793
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Feb 17 09:39:18 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Feb 17 09:39:18 2017 -0500

----------------------------------------------------------------------
 docs/src/reference/the-traversal.asciidoc       | 24 ++++++++++++++++++++
 .../traversal/dsl/graph/GraphTraversal.java     |  9 ++++++++
 2 files changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/123abf9d/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index 71a35c2..2002028 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -882,6 +882,18 @@ g.V(1).outE().label()
 g.V(1).properties().label()
 ----
 
+[[key-step]]
+Key Step
+~~~~~~~~
+
+The `key()`-step (*map*) takes a `Property` and extracts the key from it.
+
+[gremlin-groovy,theCrew]
+----
+g.V(1).properties().key()
+g.V(1).properties().properties().key()
+----
+
 [[limit-step]]
 Limit Step
 ~~~~~~~~~~
@@ -2212,6 +2224,18 @@ g.V(4).union(
          out().values('lang')).path()
 ----
 
+[[value-step]]
+Value Step
+~~~~~~~~~~
+
+The `value()`-step (*map*) takes a `Property` and extracts the value from it.
+
+[gremlin-groovy,theCrew]
+----
+g.V(1).properties().value()
+g.V(1).properties().properties().value()
+----
+
 [[valuemap-step]]
 ValueMap Step
 ~~~~~~~~~~~~~

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/123abf9d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index d37bff6..0c04e83 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -541,6 +541,13 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
         return this.asAdmin().addStep(new PropertyMapStep<>(this.asAdmin(), includeTokens, PropertyType.VALUE, propertyKeys));
     }
 
+    /**
+     * A version of {@code select} that allows for the extraction of a {@link Column} from objects in the traversal.
+     *
+     * @param column the column to extract
+     * @return the traversal with an appended {@link TraversalMapStep}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#select-step">Reference Documentation - Select Step</a>
+     */
     public default <E2> GraphTraversal<S, Collection<E2>> select(final Column column) {
         this.asAdmin().getBytecode().addStep(Symbols.select, column);
         return this.asAdmin().addStep(new TraversalMapStep<>(this.asAdmin(), new ColumnTraversal(column)));
@@ -566,6 +573,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * Map the {@link Property} to its {@link Property#key}.
      *
      * @return the traversal with an appended {@link PropertyKeyStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#key-step">Reference Documentation - Key Step</a>
      */
     public default GraphTraversal<S, String> key() {
         this.asAdmin().getBytecode().addStep(Symbols.key);
@@ -576,6 +584,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * Map the {@link Property} to its {@link Property#value}.
      *
      * @return the traversal with an appended {@link PropertyValueStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#value-step">Reference Documentation - Value Step</a>
      */
     public default <E2> GraphTraversal<S, E2> value() {
         this.asAdmin().getBytecode().addStep(Symbols.value);


[13/21] tinkerpop git commit: make sure to close manually created (not fixture) remote connection

Posted by da...@apache.org.
make sure to close manually created (not fixture) remote connection


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

Branch: refs/heads/TINKERPOP-1599
Commit: b5069ffab000fdb34f5fcb588c10452c6ea1a7bb
Parents: aa848c1
Author: davebshow <da...@gmail.com>
Authored: Mon Jan 30 20:07:03 2017 -0500
Committer: davebshow <da...@gmail.com>
Committed: Fri Feb 17 11:36:57 2017 -0500

----------------------------------------------------------------------
 .../tests/driver/test_driver_remote_connection_threaded.py     | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b5069ffa/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py
index d5efc0d..dffd442 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py
@@ -54,7 +54,10 @@ def test_conn_in_threads(remote_connection):
     child2.join()
 
 def _executor(q, conn):
+    close = False
     if not conn:
+        # This isn't a fixture so close manually
+        close = True
         conn = DriverRemoteConnection(
             'ws://localhost:45940/gremlin', 'g', pool_size=4)
     try:
@@ -66,3 +69,6 @@ def _executor(q, conn):
         q.put(sys.exc_info()[0])
     else:
         q.put('success!')
+        # Close conn
+        if close:
+            conn.close()


[08/21] tinkerpop git commit: Added javadoc/reference docs for label/id steps CTR

Posted by da...@apache.org.
Added javadoc/reference docs for label/id steps CTR


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

Branch: refs/heads/TINKERPOP-1599
Commit: 4215f3aa64234c786a2cdeab163c6c304940065d
Parents: 1780823
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Feb 16 16:58:13 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Feb 16 16:58:13 2017 -0500

----------------------------------------------------------------------
 docs/src/reference/the-traversal.asciidoc       | 27 ++++++++++++++++++++
 .../traversal/dsl/graph/GraphTraversal.java     |  2 ++
 2 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4215f3aa/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index ed76a7a..b41cf4a 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -807,6 +807,20 @@ the key,value pairs for those verticies.
 TinkerPop does not support a regular expression predicate, although specific graph databases that leverage TinkerPop
 may provide a partial match extension.
 
+[[id-step]]
+Id Step
+~~~~~~~
+
+The `id()`-step (*map*) takes an `Element` and extracts its identifier from it.
+
+[gremlin-groovy,modern]
+----
+g.V().id()
+g.V(1).out().id().is(2)
+g.V(1).outE().id()
+g.V(1).properties().id()
+----
+
 [[inject-step]]
 Inject Step
 ~~~~~~~~~~~
@@ -855,6 +869,19 @@ g.V().where(__.in('created').values('age').
 <2> Find projects having two or more contributors.
 <3> Find projects whose contributors average age is between 30 and 35.
 
+[[label-step]]
+Label Step
+~~~~~~~~~~
+
+The `label()`-step (*map*) takes an `Element` and extracts its label from it.
+
+[gremlin-groovy,modern]
+----
+g.V().label()
+g.V(1).outE().label()
+g.V(1).properties().label()
+----
+
 [[limit-step]]
 Limit Step
 ~~~~~~~~~~

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4215f3aa/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index 29f3b0a..1dcdd43 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -242,6 +242,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * Map the {@link Element} to its {@link Element#id}.
      *
      * @return the traversal with an appended {@link IdStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#id-step">Reference Documentation - Id Step</a>
      */
     public default GraphTraversal<S, Object> id() {
         this.asAdmin().getBytecode().addStep(Symbols.id);
@@ -252,6 +253,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * Map the {@link Element} to its {@link Element#label}.
      *
      * @return the traversal with an appended {@link LabelStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#label-step">Reference Documentation - Label Step</a>
      */
     public default GraphTraversal<S, String> label() {
         this.asAdmin().getBytecode().addStep(Symbols.label);


[06/21] tinkerpop git commit: Added javadoc to GraphTraversal for all mutating steps. CTR

Posted by da...@apache.org.
Added javadoc to GraphTraversal for all mutating steps. CTR


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

Branch: refs/heads/TINKERPOP-1599
Commit: ff96e3c8754c6130e545636e1350d75252368bd3
Parents: a30dabc
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Feb 16 16:31:02 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Feb 16 16:31:02 2017 -0500

----------------------------------------------------------------------
 .../traversal/dsl/graph/GraphTraversal.java     | 62 ++++++++++++++++++++
 1 file changed, 62 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff96e3c8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index b00293d..d6e6cfd 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -745,11 +745,24 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
         return this.asAdmin().addStep(new TreeStep<>(this.asAdmin()));
     }
 
+    /**
+     * Adds a {@link Vertex}.
+     *
+     * @param vertexLabel the label of the {@link Vertex} to add
+     * @return the traversal with the {@link AddVertexStep} added
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addvertex-step">Reference Documentation - AddVertex Step</a>
+     */
     public default GraphTraversal<S, Vertex> addV(final String vertexLabel) {
         this.asAdmin().getBytecode().addStep(Symbols.addV, vertexLabel);
         return this.asAdmin().addStep(new AddVertexStep<>(this.asAdmin(), vertexLabel));
     }
 
+    /**
+     * Adds a {@link Vertex} with a default vertex label.
+     *
+     * @return the traversal with the {@link AddVertexStep} added
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addvertex-step">Reference Documentation - AddVertex Step</a>
+     */
     public default GraphTraversal<S, Vertex> addV() {
         this.asAdmin().getBytecode().addStep(Symbols.addV);
         return this.asAdmin().addStep(new AddVertexStep<>(this.asAdmin(), null));
@@ -768,29 +781,68 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
         return (GraphTraversal<S, Vertex>) this;
     }
 
+    /**
+     * Adds an {@link Edge} with the specified edge label.
+     *
+     * @param edgeLabel the label of the newly added edge
+     * @return the traversal with the {@link AddEdgeStep} added
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step">Reference Documentation - AddEdge Step</a>
+     */
     public default GraphTraversal<S, Edge> addE(final String edgeLabel) {
         this.asAdmin().getBytecode().addStep(Symbols.addE, edgeLabel);
         return this.asAdmin().addStep(new AddEdgeStep<>(this.asAdmin(), edgeLabel));
     }
 
+    /**
+     * When used as a modifier to {@link #addE(String)} this method specifies the step label to use for selecting the
+     * incoming vertex of the newly added {@link Edge}.
+     *
+     * @param toStepLabel the step label of the incoming vertex
+     * @return the traversal with the modified {@link AddEdgeStep}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step">Reference Documentation - AddEdge Step</a>
+     */
     public default GraphTraversal<S, E> to(final String toStepLabel) {
         this.asAdmin().getBytecode().addStep(Symbols.to, toStepLabel);
         ((AddEdgeStep) this.asAdmin().getEndStep()).addTo(__.select(toStepLabel));
         return this;
     }
 
+    /**
+     * When used as a modifier to {@link #addE(String)} this method specifies the step label to use for selecting the
+     * outgoing vertex of the newly added {@link Edge}.
+     *
+     * @param fromStepLabel the step label of the outgoing vertex
+     * @return the traversal with the modified {@link AddEdgeStep}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step">Reference Documentation - AddEdge Step</a>
+     */
     public default GraphTraversal<S, E> from(final String fromStepLabel) {
         this.asAdmin().getBytecode().addStep(Symbols.from, fromStepLabel);
         ((AddEdgeStep) this.asAdmin().getEndStep()).addFrom(__.select(fromStepLabel));
         return this;
     }
 
+    /**
+     * When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
+     * incoming vertex of the newly added {@link Edge}.
+     *
+     * @param toVertex the traversal for selecting the incoming vertex
+     * @return the traversal with the modified {@link AddEdgeStep}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step">Reference Documentation - AddEdge Step</a>
+     */
     public default GraphTraversal<S, E> to(final Traversal<E, Vertex> toVertex) {
         this.asAdmin().getBytecode().addStep(Symbols.to, toVertex);
         ((AddEdgeStep) this.asAdmin().getEndStep()).addTo(toVertex);
         return this;
     }
 
+    /**
+     * When used as a modifier to {@link #addE(String)} this method specifies the traversal to use for selecting the
+     * outgoing vertex of the newly added {@link Edge}.
+     *
+     * @param fromVertex the traversal for selecting the outgoing vertex
+     * @return the traversal with the modified {@link AddEdgeStep}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addedge-step">Reference Documentation - AddEdge Step</a>
+     */
     public default GraphTraversal<S, E> from(final Traversal<E, Vertex> fromVertex) {
         this.asAdmin().getBytecode().addStep(Symbols.from, fromVertex);
         ((AddEdgeStep) this.asAdmin().getEndStep()).addFrom(fromVertex);
@@ -1205,6 +1257,14 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
                 : new SampleLocalStep<>(this.asAdmin(), amountToSample));
     }
 
+    /**
+     * Removes elements and properties from the graph. This step is not a terminating, in the sense that it does not
+     * automatically iterate the traversal. It is therefore necessary to do some form of iteration for the removal
+     * to actually take place. In most cases, iteration is best accomplished with {@code g.V().drop().iterate()}.
+     *
+     * @return the traversal with the {@link DropStep} added
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#drop-step">Reference Documentation - Drop Step</a>
+     */
     public default GraphTraversal<S, E> drop() {
         this.asAdmin().getBytecode().addStep(Symbols.drop);
         return this.asAdmin().addStep(new DropStep<>(this.asAdmin()));
@@ -1318,6 +1378,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param key         the key for the property
      * @param value       the value for the property
      * @param keyValues   any meta properties to be assigned to this property
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addproperty-step">AddProperty Step</a>
      */
     public default GraphTraversal<S, E> property(final VertexProperty.Cardinality cardinality, final Object key, final Object value, final Object... keyValues) {
         if (null == cardinality)
@@ -1349,6 +1410,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param key       the key for the property
      * @param value     the value for the property
      * @param keyValues any meta properties to be assigned to this property
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addproperty-step">AddProperty Step</a>
      */
     public default GraphTraversal<S, E> property(final Object key, final Object value, final Object... keyValues) {
         return key instanceof VertexProperty.Cardinality ?


[12/21] tinkerpop git commit: Added tests around use of Pop in select()

Posted by da...@apache.org.
Added tests around use of Pop in select()

Added more javadoc and reference docs CTR


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

Branch: refs/heads/TINKERPOP-1599
Commit: 0a08bf929fdad19cbef4b21e993ce041254d8589
Parents: 123abf9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Feb 17 11:27:09 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Feb 17 11:27:09 2017 -0500

----------------------------------------------------------------------
 docs/src/reference/the-traversal.asciidoc       |  9 +++++++
 .../traversal/dsl/graph/GraphTraversal.java     | 22 +++++++++++++++
 .../traversal/step/map/GroovySelectTest.groovy  | 10 +++++++
 .../process/traversal/step/map/SelectTest.java  | 28 ++++++++++++++++++++
 4 files changed, 69 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0a08bf92/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index 2002028..8ba51df 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -1960,6 +1960,15 @@ g.V().hasLabel('song').out('sungBy').groupCount().by('name').select(values).unfo
 
 WARNING: Note that `by()`-modulation is not supported with `select(keys)` and `select(values)`.
 
+There is also an option to supply a `Pop` operation to `select()` to manipulate `List` objects in the `Traverser`:
+
+[gremlin-groovy,modern]
+----
+g.V(1).as("a").repeat(out().as("a")).times(2).select(first, "a")
+g.V(1).as("a").repeat(out().as("a")).times(2).select(last, "a")
+g.V(1).as("a").repeat(out().as("a")).times(2).select(all, "a")
+----
+
 [[using-where-with-select]]
 Using Where with Select
 ^^^^^^^^^^^^^^^^^^^^^^^

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0a08bf92/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index 0c04e83..095391d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -595,6 +595,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * Map the {@link Traverser} to its {@link Path} history via {@link Traverser#path}.
      *
      * @return the traversal with an appended {@link PathStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#path-step">Reference Documentation - Path Step</a>
      */
     public default GraphTraversal<S, Path> path() {
         this.asAdmin().getBytecode().addStep(Symbols.path);
@@ -607,6 +608,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param matchTraversals the traversal that maintain variables which must hold for the life of the traverser
      * @param <E2>            the type of the obejcts bound in the variables
      * @return the traversal with an appended {@link MatchStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#match-step">Reference Documentation - Match Step</a>
      */
     public default <E2> GraphTraversal<S, Map<String, E2>> match(final Traversal<?, ?>... matchTraversals) {
         this.asAdmin().getBytecode().addStep(Symbols.match, matchTraversals);
@@ -618,6 +620,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      *
      * @param <E2> the sack value type
      * @return the traversal with an appended {@link SackStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#sack-step">Reference Documentation - Sack Step</a>
      */
     public default <E2> GraphTraversal<S, E2> sack() {
         this.asAdmin().getBytecode().addStep(Symbols.sack);
@@ -646,6 +649,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param otherSelectKeys the third+ keys to project
      * @param <E2>            the type of the objects projected
      * @return the traversal with an appended {@link SelectStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#select-step">Reference Documentation - Select Step</a>
      */
     public default <E2> GraphTraversal<S, Map<String, E2>> select(final Pop pop, final String selectKey1, final String selectKey2, String... otherSelectKeys) {
         final String[] selectKeys = new String[otherSelectKeys.length + 2];
@@ -664,6 +668,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param otherSelectKeys the third+ keys to project
      * @param <E2>            the type of the objects projected
      * @return the traversal with an appended {@link SelectStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#select-step">Reference Documentation - Select Step</a>
      */
     public default <E2> GraphTraversal<S, Map<String, E2>> select(final String selectKey1, final String selectKey2, String... otherSelectKeys) {
         final String[] selectKeys = new String[otherSelectKeys.length + 2];
@@ -674,11 +679,28 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
         return this.asAdmin().addStep(new SelectStep<>(this.asAdmin(), null, selectKeys));
     }
 
+    /**
+     * Map the {@link Traverser} to the object specified by the {@code selectKey} and apply the {@link Pop} operation
+     * to it.
+     *
+     * @param selectKey the key to project
+     * @return the traversal with an appended {@link SelectStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#select-step">Reference Documentation - Select Step</a>
+     */
     public default <E2> GraphTraversal<S, E2> select(final Pop pop, final String selectKey) {
         this.asAdmin().getBytecode().addStep(Symbols.select, pop, selectKey);
         return this.asAdmin().addStep(new SelectOneStep<>(this.asAdmin(), pop, selectKey));
     }
 
+    /**
+     * Map the {@link Traverser} to the object specified by the {@code selectKey}. Note that unlike other uses of
+     * {@code select} where there are multiple keys, this use of {@code select} with a single key does not produce a
+     * {@code Map}.
+     *
+     * @param selectKey the key to project
+     * @return the traversal with an appended {@link SelectStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#select-step">Reference Documentation - Select Step</a>
+     */
     public default <E2> GraphTraversal<S, E2> select(final String selectKey) {
         this.asAdmin().getBytecode().addStep(Symbols.select, selectKey);
         return this.asAdmin().addStep(new SelectOneStep<>(this.asAdmin(), null, selectKey));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0a08bf92/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySelectTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySelectTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySelectTest.groovy
index 789c36f..89fc691 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySelectTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySelectTest.groovy
@@ -33,6 +33,16 @@ public abstract class GroovySelectTest {
     public static class Traversals extends SelectTest {
 
         @Override
+        public Traversal<Vertex, Vertex> get_g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXfirst_aX(final Object v1Id) {
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').repeat(__.out().as('a')).times(2).select(Pop.first, 'a')", "v1Id", v1Id)
+        }
+
+        @Override
+        public Traversal<Vertex, Vertex> get_g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXlast_aX(final Object v1Id) {
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').repeat(__.out().as('a')).times(2).select(Pop.last, 'a')", "v1Id", v1Id)
+        }
+
+        @Override
         public Traversal<Vertex, Map<String, Vertex>> get_g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX(final Object v1Id) {
             new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('knows').as('b').select('a','b')", "v1Id", v1Id)
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0a08bf92/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
index 6e418b2..6d07edf 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
@@ -117,6 +117,10 @@ public abstract class SelectTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Map<String, Object>> get_g_V_valueMap_selectXpop_a_bX(final Pop pop);
 
+    public abstract Traversal<Vertex, Vertex> get_g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXfirst_aX(final Object v1Id);
+
+    public abstract Traversal<Vertex, Vertex> get_g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXlast_aX(final Object v1Id);
+
     // when labels don't exist
 
     public abstract Traversal<Vertex, String> get_g_V_untilXout_outX_repeatXin_asXaXX_selectXaX_byXtailXlocalX_nameX();
@@ -646,6 +650,20 @@ public abstract class SelectTest extends AbstractGremlinProcessTest {
         assertFalse(traversal.hasNext());
     }
 
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXfirst_aX() {
+        final Traversal<Vertex, Vertex> traversal = get_g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXfirst_aX(convertToVertexId("marko"));
+        checkResults(Arrays.asList(convertToVertex(graph, "marko"), convertToVertex(graph, "marko")), traversal);
+    }
+
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXlast_aX() {
+        final Traversal<Vertex, Vertex> traversal = get_g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXlast_aX(convertToVertexId("marko"));
+        checkResults(Arrays.asList(convertToVertex(graph, "ripple"), convertToVertex(graph, "lop")), traversal);
+    }
+
     public static class Traversals extends SelectTest {
         @Override
         public Traversal<Vertex, Map<String, Vertex>> get_g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX(final Object v1Id) {
@@ -846,5 +864,15 @@ public abstract class SelectTest extends AbstractGremlinProcessTest {
         public Traversal<Vertex, Map<String, String>> get_g_V_asXaX_outXknowsX_asXbX_localXselectXa_bX_byXnameXX() {
             return g.V().as("a").out("knows").as("b").local(__.<Vertex, String>select("a", "b").by("name"));
         }
+
+        @Override
+        public Traversal<Vertex, Vertex> get_g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXfirst_aX(final Object v1Id) {
+            return g.V(v1Id).as("a").repeat(__.out().as("a")).times(2).select(Pop.first, "a");
+        }
+
+        @Override
+        public Traversal<Vertex, Vertex> get_g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXlast_aX(final Object v1Id) {
+            return g.V(v1Id).as("a").repeat(__.out().as("a")).times(2).select(Pop.last, "a");
+        }
     }
 }


[09/21] tinkerpop git commit: More javadocs in GraphTraversal for mean/min/max/order CTR

Posted by da...@apache.org.
More javadocs in GraphTraversal for mean/min/max/order CTR


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

Branch: refs/heads/TINKERPOP-1599
Commit: 14c7df95a4254625986837fbcf2842beaf415da3
Parents: 4215f3a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Feb 16 17:13:12 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Feb 16 17:13:12 2017 -0500

----------------------------------------------------------------------
 .../traversal/dsl/graph/GraphTraversal.java     | 60 +++++++++++++++++++-
 1 file changed, 58 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14c7df95/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index 1dcdd43..c5a65e0 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -444,6 +444,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * Order all the objects in the traversal up to this point and then emit them one-by-one in their ordered sequence.
      *
      * @return the traversal with an appended {@link OrderGlobalStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#order-step">Reference Documentation - Order Step</a>
      */
     public default GraphTraversal<S, E> order() {
         this.asAdmin().getBytecode().addStep(Symbols.order);
@@ -455,6 +456,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      *
      * @param scope whether the ordering is the current local object or the entire global stream.
      * @return the traversal with an appended {@link OrderGlobalStep} or {@link OrderLocalStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#order-step">Reference Documentation - Order Step</a>
      */
     public default GraphTraversal<S, E> order(final Scope scope) {
         this.asAdmin().getBytecode().addStep(Symbols.order, scope);
@@ -677,60 +679,114 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
     }
 
     /**
-     * Map the traversal stream to its reduction as a sum of the {@link Traverser#bulk} values (i.e. count the number of traversers up to this point).
+     * Map the traversal stream to its reduction as a sum of the {@link Traverser#bulk} values (i.e. count the number
+     * of traversers up to this point).
      *
      * @return the traversal with an appended {@link CountGlobalStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#count-step">Reference Documentation - Count Step</a>
      */
     public default GraphTraversal<S, Long> count() {
         this.asAdmin().getBytecode().addStep(Symbols.count);
         return this.asAdmin().addStep(new CountGlobalStep<>(this.asAdmin()));
     }
 
+    /**
+     * Map the traversal stream to its reduction as a sum of the {@link Traverser#bulk} values given the specified
+     * {@link Scope} (i.e. count the number of traversers up to this point).
+     *
+     * @return the traversal with an appended {@link CountGlobalStep} or {@link CountLocalStep} depending on the {@link Scope}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#count-step">Reference Documentation - Count Step</a>
+     */
     public default GraphTraversal<S, Long> count(final Scope scope) {
         this.asAdmin().getBytecode().addStep(Symbols.count, scope);
         return this.asAdmin().addStep(scope.equals(Scope.global) ? new CountGlobalStep<>(this.asAdmin()) : new CountLocalStep<>(this.asAdmin()));
     }
 
     /**
-     * Map the traversal stream to its reduction as a sum of the {@link Traverser#get} values multiplied by their {@link Traverser#bulk} (i.e. sum the traverser values up to this point).
+     * Map the traversal stream to its reduction as a sum of the {@link Traverser#get} values multiplied by their
+     * {@link Traverser#bulk} (i.e. sum the traverser values up to this point).
      *
      * @return the traversal with an appended {@link SumGlobalStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#sum-step">Reference Documentation - Sum Step</a>
      */
     public default <E2 extends Number> GraphTraversal<S, E2> sum() {
         this.asAdmin().getBytecode().addStep(Symbols.sum);
         return this.asAdmin().addStep(new SumGlobalStep<>(this.asAdmin()));
     }
 
+    /**
+     * Map the traversal stream to its reduction as a sum of the {@link Traverser#get} values multiplied by their
+     * {@link Traverser#bulk} given the specified {@link Scope} (i.e. sum the traverser values up to this point).
+     *
+     * @return the traversal with an appended {@link SumGlobalStep} or {@link SumLocalStep} depending on the {@link Scope}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#sum-step">Reference Documentation - Sum Step</a>
+     */
     public default <E2 extends Number> GraphTraversal<S, E2> sum(final Scope scope) {
         this.asAdmin().getBytecode().addStep(Symbols.sum, scope);
         return this.asAdmin().addStep(scope.equals(Scope.global) ? new SumGlobalStep<>(this.asAdmin()) : new SumLocalStep(this.asAdmin()));
     }
 
+    /**
+     * Determines the largest value in the stream.
+     *
+     * @return the traversal with an appended {@link MaxGlobalStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#max-step">Reference Documentation - Max Step</a>
+     */
     public default <E2 extends Number> GraphTraversal<S, E2> max() {
         this.asAdmin().getBytecode().addStep(Symbols.max);
         return this.asAdmin().addStep(new MaxGlobalStep<>(this.asAdmin()));
     }
 
+    /**
+     * Determines the largest value in the stream given the {@link Scope}.
+     *
+     * @return the traversal with an appended {@link MaxGlobalStep} or {@link MaxLocalStep} depending on the {@link Scope}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#max-step">Reference Documentation - Max Step</a>
+     */
     public default <E2 extends Number> GraphTraversal<S, E2> max(final Scope scope) {
         this.asAdmin().getBytecode().addStep(Symbols.max, scope);
         return this.asAdmin().addStep(scope.equals(Scope.global) ? new MaxGlobalStep<>(this.asAdmin()) : new MaxLocalStep(this.asAdmin()));
     }
 
+    /**
+     * Determines the smallest value in the stream.
+     *
+     * @return the traversal with an appended {@link MinGlobalStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#min-step">Reference Documentation - Min Step</a>
+     */
     public default <E2 extends Number> GraphTraversal<S, E2> min() {
         this.asAdmin().getBytecode().addStep(Symbols.min);
         return this.asAdmin().addStep(new MinGlobalStep<>(this.asAdmin()));
     }
 
+    /**
+     * Determines the smallest value in the stream given the {@link Scope}.
+     *
+     * @return the traversal with an appended {@link MinGlobalStep} or {@link MinLocalStep} depending on the {@link Scope}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#min-step">Reference Documentation - Min Step</a>
+     */
     public default <E2 extends Number> GraphTraversal<S, E2> min(final Scope scope) {
         this.asAdmin().getBytecode().addStep(Symbols.min, scope);
         return this.asAdmin().addStep(scope.equals(Scope.global) ? new MinGlobalStep<E2>(this.asAdmin()) : new MinLocalStep<>(this.asAdmin()));
     }
 
+    /**
+     * Determines the mean value in the stream.
+     *
+     * @return the traversal with an appended {@link MeanGlobalStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#mean-step">Reference Documentation - Mean Step</a>
+     */
     public default <E2 extends Number> GraphTraversal<S, E2> mean() {
         this.asAdmin().getBytecode().addStep(Symbols.mean);
         return this.asAdmin().addStep(new MeanGlobalStep<>(this.asAdmin()));
     }
 
+    /**
+     * Determines the mean value in the stream given the {@link Scope}.
+     *
+     * @return the traversal with an appended {@link MeanGlobalStep} or {@link MeanLocalStep} depending on the {@link Scope}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#mean-step">Reference Documentation - Mean Step</a>
+     */
     public default <E2 extends Number> GraphTraversal<S, E2> mean(final Scope scope) {
         this.asAdmin().getBytecode().addStep(Symbols.mean, scope);
         return this.asAdmin().addStep(scope.equals(Scope.global) ? new MeanGlobalStep<>(this.asAdmin()) : new MeanLocalStep(this.asAdmin()));


[19/21] tinkerpop git commit: added code for new driver, updated driver tests

Posted by da...@apache.org.
added code for new driver, updated driver tests


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

Branch: refs/heads/TINKERPOP-1599
Commit: 1d203b7494432a5296e04581c9903f138753e964
Parents: 0a08bf9
Author: davebshow <da...@gmail.com>
Authored: Mon Jan 30 17:22:36 2017 -0500
Committer: davebshow <da...@gmail.com>
Committed: Fri Feb 17 11:36:57 2017 -0500

----------------------------------------------------------------------
 gremlin-python/pom.xml                          |   1 +
 .../python/TraversalSourceGenerator.groovy      |  11 +-
 .../main/jython/gremlin_python/driver/client.py | 114 ++++++++
 .../jython/gremlin_python/driver/connection.py  |  78 ++++++
 .../driver/driver_remote_connection.py          | 260 +++----------------
 .../jython/gremlin_python/driver/protocol.py    | 103 ++++++++
 .../gremlin_python/driver/remote_connection.py  |  98 ++++---
 .../jython/gremlin_python/driver/request.py     |  25 ++
 .../jython/gremlin_python/driver/resultset.py   |  91 +++++++
 .../jython/gremlin_python/driver/serializer.py  | 117 +++++++++
 .../gremlin_python/driver/tornado/__init__.py   |  18 ++
 .../gremlin_python/driver/tornado/transport.py  |  48 ++++
 .../jython/gremlin_python/driver/transport.py   |  46 ++++
 .../jython/gremlin_python/process/traversal.py  |  11 +-
 gremlin-python/src/main/jython/setup.py         |  18 +-
 .../src/main/jython/tests/conftest.py           |  72 +++++
 .../src/main/jython/tests/driver/test_client.py |  98 +++++++
 .../driver/test_driver_remote_connection.py     | 150 ++++-------
 .../test_driver_remote_connection_threaded.py   |  77 +++---
 .../jython/tests/structure/io/test_graphson.py  |  21 +-
 20 files changed, 1039 insertions(+), 418 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-python/pom.xml b/gremlin-python/pom.xml
index c9d6c65..2b4a80e 100644
--- a/gremlin-python/pom.xml
+++ b/gremlin-python/pom.xml
@@ -314,6 +314,7 @@
                                         <param>aenum==1.4.5</param>
                                         <param>tornado==4.4.1</param>
                                         <param>six==1.10.0</param>
+                                        <param>futures==3.0.5</param>
                                     </libraries>
                                 </configuration>
                             </execution>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
index fc76b71..995fe80 100644
--- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
+++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
@@ -116,15 +116,16 @@ class Traversal(object):
             return tempList
     def promise(self, cb=None):
         self.traversal_strategies.apply_async_strategies(self)
-        future_traversers = self.traversers
-        future = type(future_traversers)()
+        future_traversal = self.remote_results
+        future = type(future_traversal)()
         def process(f):
             try:
-                traversers = f.result()
+                traversal = f.result()
             except Exception as e:
                 future.set_exception(e)
             else:
-                self.traversers = iter(traversers)
+                self.traversers = iter(traversal.traversers)
+                self.side_effects = traversal.side_effects
                 if cb:
                     try:
                         result = cb(self)
@@ -134,7 +135,7 @@ class Traversal(object):
                         future.set_result(result)
                 else:
                     future.set_result(self)
-        future_traversers.add_done_callback(process)
+        future_traversal.add_done_callback(process)
         return future
 
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/driver/client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/client.py b/gremlin-python/src/main/jython/gremlin_python/driver/client.py
new file mode 100644
index 0000000..dec39bf
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/client.py
@@ -0,0 +1,114 @@
+"""
+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.
+"""
+import collections
+import functools
+
+from concurrent.futures import ThreadPoolExecutor
+
+from six.moves import queue
+
+from gremlin_python.driver import connection, protocol, request
+from gremlin_python.process import traversal
+
+# This is until concurrent.futures backport 3.1.0 release
+try:
+    from multiprocessing import cpu_count
+except ImportError:
+    # some platforms don't have multiprocessing
+    def cpu_count():
+        return None
+
+__author__ = 'David M. Brown (davebshow@gmail.com)'
+
+
+class Client:
+
+    def __init__(self, url, traversal_source, protocol_factory=None,
+                 transport_factory=None, pool_size=None, max_workers=None,
+                 message_serializer=None, username="", password=""):
+        self._url = url
+        self._traversal_source = traversal_source
+        self._message_serializer = message_serializer
+        self._username = username
+        self._password = password
+        if transport_factory is None:
+            try:
+                from gremlin_python.driver.tornado.transport import (
+                    TornadoTransport)
+            except ImportError:
+                raise Exception("Please install Tornado or pass"
+                                "custom transport factory")
+            else:
+                transport_factory = lambda: TornadoTransport()
+        self._transport_factory = transport_factory
+        if protocol_factory is None:
+            protocol_factory = lambda: protocol.GremlinServerWSProtocol(
+                message_serializer=self._message_serializer,
+                username=self._username,
+                password=self._password)
+        self._protocol_factory = protocol_factory
+        if pool_size is None:
+            pool_size = 4
+        self._pool_size = pool_size
+        # This is until concurrent.futures backport 3.1.0 release
+        if max_workers is None:
+            # Use this number because ThreadPoolExecutor is often
+            # used to overlap I/O instead of CPU work.
+            max_workers = (cpu_count() or 1) * 5
+        self._executor = ThreadPoolExecutor(max_workers=max_workers)
+        # Threadsafe queue
+        self._pool = queue.Queue()
+        self._fill_pool()
+
+    @property
+    def executor(self):
+        return self._executor
+
+    @property
+    def traversal_source(self):
+        return self._traversal_source
+
+    def _fill_pool(self):
+        for i in range(self._pool_size):
+            conn = self._get_connection()
+            self._pool.put_nowait(conn)
+
+    def close(self):
+        while not self._pool.empty():
+            conn = self._pool.get(True)
+            conn.close()
+        self._executor.shutdown()
+
+    def _get_connection(self):
+        protocol = self._protocol_factory()
+        return connection.Connection(
+            self._url, self._traversal_source, protocol,
+            self._transport_factory, self._executor, self._pool)
+
+    def submit(self, message):
+        return self.submitAsync(message).result()
+
+    def submitAsync(self, message):
+        if isinstance(message, traversal.Bytecode):
+            message = request.RequestMessage(
+                processor='traversal', op='bytecode',
+                args={'gremlin': message,
+                      'aliases': {'g': self._traversal_source}})
+        conn = self._pool.get(True)
+        return conn.write(message)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/driver/connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/connection.py
new file mode 100644
index 0000000..abc4545
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/connection.py
@@ -0,0 +1,78 @@
+"""
+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.
+"""
+import uuid
+from concurrent.futures import Future
+from six.moves import queue
+
+from gremlin_python.driver import resultset
+
+__author__ = 'David M. Brown (davebshow@gmail.com)'
+
+
+class Connection:
+
+    def __init__(self, url, traversal_source, protocol, transport_factory,
+                 executor, pool):
+        self._url = url
+        self._traversal_source = traversal_source
+        self._protocol = protocol
+        self._transport_factory = transport_factory
+        self._executor = executor
+        self._transport = None
+        self._pool = pool
+        self._results = {}
+        self.connect()
+
+    def connect(self):
+        if self._transport:
+            self._transport.close()
+        self._transport = self._transport_factory()
+        self._transport.connect(self._url)
+        self._protocol.connection_made(self._transport)
+
+    def close(self):
+        self._transport.close()
+
+    def write(self, request_message):
+        request_id = str(uuid.uuid4())
+        result_set = resultset.ResultSet(queue.Queue(), request_id)
+        self._results[request_id] = result_set
+        # Create write task
+        future = Future()
+        future_write = self._executor.submit(
+            self._protocol.write, request_id, request_message)
+
+        def cb(f):
+            try:
+                f.result()
+            except Exception as e:
+                future.set_exception(e)
+            else:
+                # Start receive task
+                done = self._executor.submit(self._receive)
+                result_set.done = done
+                future.set_result(result_set)
+
+        future_write.add_done_callback(cb)
+        return future
+
+    def _receive(self):
+        data = self._transport.read()
+        self._protocol.data_received(data, self._results)
+        self._pool.put_nowait(self)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
index 2cbe0e7..fb0e4ba 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
@@ -16,236 +16,50 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 """
-import base64
-import functools
-import json
-import uuid
-from tornado import gen
-from tornado import concurrent
-from tornado import ioloop
-from tornado import websocket
+from concurrent.futures import Future
 
-from gremlin_python.structure.io.graphson import GraphSONReader, GraphSONWriter
-from .remote_connection import RemoteConnection
-from .remote_connection import RemoteTraversal
-from .remote_connection import RemoteTraversalSideEffects
+from gremlin_python.driver import client
+from gremlin_python.driver.remote_connection import (
+    RemoteConnection, RemoteTraversal, RemoteTraversalSideEffects)
 
-
-class GremlinServerError(Exception):
-    pass
+__author__ = 'David M. Brown (davebshow@gmail.com)'
 
 
 class DriverRemoteConnection(RemoteConnection):
-    def __init__(self, url, traversal_source, username="", password="", loop=None, graphson_reader=None, graphson_writer=None):
-        super(DriverRemoteConnection, self).__init__(url, traversal_source)
-        self._url = url
-        self._username = username
-        self._password = password
-        if loop is None:
-            loop = ioloop.IOLoop.current()
-        self._loop = loop
-        self._websocket = self._loop.run_sync(lambda: websocket.websocket_connect(self.url))
-        self._graphson_reader = graphson_reader or GraphSONReader()
-        self._graphson_writer = graphson_writer or GraphSONWriter()
-
-    def submit(self, bytecode):
-        '''
-        :param bytecode: the bytecode of a traversal to submit to the RemoteConnection
-        :return: a RemoteTraversal with RemoteTraversalSideEffects
-        '''
-        request_id = str(uuid.uuid4())
-        traversers = self._loop.run_sync(lambda: self.submit_traversal_bytecode(request_id, bytecode))
-        keys, value, close = self._get_side_effect_lambdas(request_id)
-        return RemoteTraversal(iter(traversers), RemoteTraversalSideEffects(keys, value, close, self._loop))
-
-    def submit_async(self, bytecode):
-        request_id = str(uuid.uuid4())
-        future_traversers = self.submit_traversal_bytecode(request_id, bytecode)
-        keys, value, close = self._get_side_effect_lambdas(request_id)
-        side_effects = RemoteTraversalSideEffects(keys, value, close, self._loop)
-        return RemoteTraversal(future_traversers, side_effects)
-
-    @gen.coroutine
-    def submit_traversal_bytecode(self, request_id, bytecode):
-        message = {
-            "requestId": {
-                "@type": "g:UUID",
-                "@value": request_id
-            },
-            "op": "bytecode",
-            "processor": "traversal",
-            "args": {
-                "gremlin": self._graphson_writer.toDict(bytecode),
-                "aliases": {"g": self.traversal_source}
-            }
-        }
-        traversers = yield self._execute_message(message)
-        raise gen.Return(traversers)
-
-    @gen.coroutine
-    def submit_sideEffect_keys(self, request_id):
-        message = {
-            "requestId": {
-                "@type": "g:UUID",
-                "@value": str(uuid.uuid4())
-            },
-            "op": "keys",
-            "processor": "traversal",
-            "args": {
-                "sideEffect": {
-                    "@type": "g:UUID",
-                    "@value": request_id
-                }
-            }
-        }
-        keys = yield self._execute_message(message)
-        raise gen.Return(set(keys))
-
-    @gen.coroutine
-    def submit_sideEffect_value(self, request_id, key):
-        message = {
-            "requestId": {
-                "@type": "g:UUID",
-                "@value": str(uuid.uuid4())
-            },
-            "op": "gather",
-            "processor": "traversal",
-            "args": {
-                "sideEffect": {
-                    "@type": "g:UUID",
-                    "@value": request_id
-                },
-                "sideEffectKey": key,
-                "aliases": {"g": self.traversal_source}
-            }
-        }
-        try:
-            value = yield self._execute_message(message)
-        except:
-            raise KeyError(key)
-        raise gen.Return(value)
-
-    @gen.coroutine
-    def submit_sideEffect_close(self, request_id):
-        message = {
-            "requestId": {
-                "@type": "g:UUID",
-                "@value": str(uuid.uuid4())
-            },
-            "op": "close",
-            "processor": "traversal",
-            "args": {
-                "sideEffect": {
-                    "@type": "g:UUID",
-                    "@value": request_id
-                }
-            }
-        }
-        result = yield self._execute_message(message)
-        raise gen.Return(result)
 
-    def _get_side_effect_lambdas(self, request_id):
-        side_effect_keys = lambda: self._loop.run_sync(lambda: self.submit_sideEffect_keys(request_id))
-        side_effect_value = lambda key: self._loop.run_sync(lambda: self.submit_sideEffect_value(request_id, key))
-        side_effect_close = lambda: self._loop.run_sync(lambda: self.submit_sideEffect_close(request_id))
-        return side_effect_keys, side_effect_value, side_effect_close
-
-    @gen.coroutine
-    def _execute_message(self, send_message):
-        send_message = b"".join([b"\x21",
-                                 b"application/vnd.gremlin-v2.0+json",
-                                 json.dumps(send_message, separators=(',', ':')).encode("utf-8")])
-        if self._websocket.protocol is None:
-            self._websocket = yield websocket.websocket_connect(self.url)
-        self._websocket.write_message(send_message, binary=True)
-        response = Response(self._websocket, self._username, self._password, self._graphson_reader)
-        results = None
-        while True:
-            recv_message = yield response.receive()
-            if recv_message is None:
-                break
-            aggregateTo = recv_message[0]
-            # on first message, get the right result data structure
-            if None == results:
-                if "list" == aggregateTo:
-                    results = []
-                elif "set" == aggregateTo:
-                    results = set()
-                elif aggregateTo in ["map", "bulkset"]:
-                    results = {}
-                elif "none" == aggregateTo:
-                    results = None
-                else:
-                    results = []
-
-            # if there is no update to a structure, then the item is the result
-            if results is None:
-                results = recv_message[1][0]
-            # updating a map is different than a list or a set
-            elif isinstance(results, dict):
-                if "map" == aggregateTo:
-                    for item in recv_message[1]:
-                        results.update(item)
-                else:
-                    for item in recv_message[1]:
-                        results[item.object] = item.bulk
-            # flat add list to result list
-            else:
-                results += recv_message[1]
-        raise gen.Return([] if None == results else results)
+    def __init__(self, url, traversal_source, protocol_factory=None,
+                 transport_factory=None, pool_size=None, max_workers=None,
+                 username="", password=""):
+        self._client = client.Client(url, traversal_source, protocol_factory,
+                                     transport_factory, pool_size, max_workers,
+                                     None, username, password)
+        self._url = self._client._url
+        self._traversal_source = self._client._traversal_source
 
     def close(self):
-        self._websocket.close()
-
+        self._client.close()
 
-class Response:
-    def __init__(self, websocket, username, password, graphson_reader):
-        self._websocket = websocket
-        self._username = username
-        self._password = password
-        self._closed = False
-        self._graphson_reader = graphson_reader
-
-    @gen.coroutine
-    def receive(self):
-        if self._closed:
-            return
-        recv_message = yield self._websocket.read_message()
-        recv_message = json.loads(recv_message.decode('utf-8'))
-        status_code = recv_message["status"]["code"]
-        aggregateTo = recv_message["result"]["meta"].get("aggregateTo", "list")
+    def submit(self, bytecode):
+        result_set = self._client.submit(bytecode)
+        results = result_set.all().result()
+        side_effects = RemoteTraversalSideEffects(result_set.request_id,
+                                                  self._client)
+        return RemoteTraversal(iter(results), side_effects)
+
+    def submitAsync(self, bytecode):
+        future = Future()
+        future_result_set = self._client.submitAsync(bytecode)
+
+        def cb(f):
+            try:
+                result_set = f.result()
+            except Exception as e:
+                future.set_exception(e)
+            else:
+                results = result_set.all().result()
+                side_effects = RemoteTraversalSideEffects(result_set.request_id,
+                                                          self._client)
+                future.set_result(RemoteTraversal(iter(results), side_effects))
 
-        # authentification required then
-        if status_code == 407:
-            self._websocket.write_message(
-                b"".join([b"\x21",
-                          b"application/vnd.gremlin-v2.0+json",
-                          json.dumps({
-                              "requestId": {
-                                  "@type": "g:UUID",
-                                  "@value": str(uuid.uuid4())
-                              },
-                              "op": "authentication",
-                              "processor": "traversal",
-                              "args": {
-                                  "sasl": base64.b64encode(
-                                      b"".join([b"\x00", self._username.encode("utf-8"),
-                                                b"\x00", self._password.encode("utf-8")])).decode()
-                              }
-                          }, separators=(',', ':')).encode("utf-8")]), binary=True)
-            results = yield self.receive()
-            raise gen.Return(results)
-        elif status_code == 204:
-            self._closed = True
-            return
-        elif status_code in [200, 206]:
-            results = []
-            for item in recv_message["result"]["data"]:
-                results.append(self._graphson_reader.toObject(item))
-            if status_code == 200:
-                self._closed = True
-            raise gen.Return((aggregateTo, results))
-        else:
-            self._closed = True
-            raise GremlinServerError(
-                "{0}: {1}".format(status_code, recv_message["status"]["message"]))
+        future_result_set.add_done_callback(cb)
+        return future

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
new file mode 100644
index 0000000..2ace35e
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
@@ -0,0 +1,103 @@
+"""
+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.
+"""
+import abc
+import base64
+import collections
+import json
+import uuid
+
+import six
+
+from gremlin_python.driver import serializer, request
+
+__author__ = 'David M. Brown (davebshow@gmail.com)'
+
+
+class GremlinServerError(Exception):
+    pass
+
+
+@six.add_metaclass(abc.ABCMeta)
+class AbstractBaseProtocol:
+
+    @abc.abstractmethod
+    def connection_made(self, transport):
+        self._transport = transport
+
+    @abc.abstractmethod
+    def data_received(self, message):
+        pass
+
+    @abc.abstractmethod
+    def write(self, request_id, request_message):
+        pass
+
+
+class GremlinServerWSProtocol(AbstractBaseProtocol):
+
+    def __init__(self, message_serializer=None, username='', password=''):
+        if message_serializer is None:
+            message_serializer = serializer.GraphSONMessageSerializer()
+        self._message_serializer = message_serializer
+        self._username = username
+        self._password = password
+
+    def connection_made(self, transport):
+        super(GremlinServerWSProtocol, self).connection_made(transport)
+
+    def write(self, request_id, request_message):
+        message = self._message_serializer.serialize_message(
+            request_id, request_message)
+        self._transport.write(message)
+
+    def data_received(self, data, results_dict):
+        data = json.loads(data.decode('utf-8'))
+        request_id = data['requestId']
+        result_set = results_dict[request_id]
+        status_code = data['status']['code']
+        aggregate_to = data['result']['meta'].get('aggregateTo', 'list')
+        result_set.aggregate_to = aggregate_to
+        if status_code == 407:
+            auth = b''.join([b'\x00', self._username.encode('utf-8'),
+                             b'\x00', self._password.encode('utf-8')])
+            request_message = request.RequestMessage(
+                'traversal', 'authentication',
+                {'sasl': base64.b64encode(auth).decode()})
+            self.write(request_id, request_message)
+            data = self._transport.read()
+            self.data_received(data, results_dict)
+        elif status_code == 204:
+            result_set.stream.put_nowait([])
+            del results_dict[request_id]
+        elif status_code in [200, 206]:
+            results = []
+            for msg in data["result"]["data"]:
+                results.append(
+                    self._message_serializer.deserialize_message(msg))
+            result_set.stream.put_nowait(results)
+            if status_code == 206:
+                data = self._transport.read()
+                self.data_received(data, results_dict)
+            else:
+                # result_set.done.set_result(None)
+                del results_dict[request_id]
+        else:
+            del results_dict[request_id]
+            raise GremlinServerError(
+                "{0}: {1}".format(status_code, data["status"]["message"]))

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
index f7ed48e..c48cfe3 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
@@ -17,11 +17,11 @@ specific language governing permissions and limitations
 under the License.
 '''
 import abc
+import collections
 import six
 
-from ..process.traversal import Traversal
-from ..process.traversal import TraversalStrategy
-from ..process.traversal import TraversalSideEffects
+from gremlin_python.driver import request
+from gremlin_python.process import traversal
 
 __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
 
@@ -42,45 +42,53 @@ class RemoteConnection(object):
 
     @abc.abstractmethod
     def submit(self, bytecode):
-        print("sending " + bytecode + " to GremlinServer...")
-        return RemoteTraversal(iter([]), TraversalSideEffects())
+        pass
 
     def __repr__(self):
         return "remoteconnection[" + self._url + "," + self._traversal_source + "]"
 
 
-class RemoteTraversal(Traversal):
+class RemoteTraversal(traversal.Traversal):
     def __init__(self, traversers, side_effects):
-        Traversal.__init__(self, None, None, None)
+        super(RemoteTraversal, self).__init__(None, None, None)
         self.traversers = traversers
-        self.side_effects = side_effects
+        self._side_effects = side_effects
+
+    @property
+    def side_effects(self):
+        return self._side_effects
+
+    @side_effects.setter
+    def side_effects(self, val):
+        self._side_effects = val
 
 
-class RemoteTraversalSideEffects(TraversalSideEffects):
-    def __init__(self, keys_lambda, value_lambda, close_lambda, loop):
-        self._keys_lambda = keys_lambda
-        self._value_lambda = value_lambda
-        self._close_lambda = close_lambda
-        self._loop = loop
+class RemoteTraversalSideEffects(traversal.TraversalSideEffects):
+    def __init__(self, side_effect, client):
+        self._side_effect = side_effect
+        self._client = client
         self._keys = set()
         self._side_effects = {}
         self._closed = False
 
     def keys(self):
-        if self._loop._running:
-            raise RuntimeError("Cannot call side effect methods"
-                               "while event loop is running")
         if not self._closed:
-            self._keys = self._keys_lambda()
+            message = request.RequestMessage(
+                'traversal', 'keys',
+                {'sideEffect': self._side_effect,
+                'aliases': {'g': self._client.traversal_source}})
+            self._keys = set(self._client.submit(message).all().result())
         return self._keys
 
     def get(self, key):
-        if self._loop._running:
-            raise RuntimeError("Cannot call side effect methods"
-                               "while event loop is running")
+
         if not self._side_effects.get(key):
             if not self._closed:
-                results = self._value_lambda(key)
+                message = request.RequestMessage(
+                    'traversal', 'gather',
+                    {'sideEffect': self._side_effect, 'sideEffectKey': key,
+                     'aliases': {'g': self._client.traversal_source}})
+                results = self._aggregate_results(self._client.submit(message))
                 self._side_effects[key] = results
                 self._keys.add(key)
             else:
@@ -88,27 +96,57 @@ class RemoteTraversalSideEffects(TraversalSideEffects):
         return self._side_effects[key]
 
     def close(self):
-        if self._loop._running:
-            raise RuntimeError("Cannot call side effect methods"
-                               "while event loop is running")
-        results = self._close_lambda()
+        if not self._closed:
+            message = request.RequestMessage(
+                'traversal', 'close',
+                {'sideEffect': self._side_effect,
+                 'aliases': {'g': self._client._traversal_source}})
+            results = self._client.submit(message).all().result()
         self._closed = True
         return results
 
+    def _aggregate_results(self, result_set):
+        aggregates = {'list': [], 'set': set(), 'map': {}, 'bulkset': {},
+                      'none': None}
+        results = None
+        for msg in result_set:
+            if results is None:
+                aggregate_to = result_set.aggregate_to
+                results = aggregates.get(aggregate_to, [])
+            # on first message, get the right result data structure
+            # if there is no update to a structure, then the item is the result
+            if results is None:
+                results = msg[0]
+            # updating a map is different than a list or a set
+            elif isinstance(results, dict):
+                if aggregate_to == "map":
+                    for item in msg:
+                        results.update(item)
+                else:
+                    for item in msg:
+                        results[item.object] = item.bulk
+            elif isinstance(results, set):
+                results.update(msg)
+            # flat add list to result list
+            else:
+                results += msg
+        if results is None:
+            results = []
+        return results
+
 
-class RemoteStrategy(TraversalStrategy):
+class RemoteStrategy(traversal.TraversalStrategy):
     def __init__(self, remote_connection):
         self.remote_connection = remote_connection
 
     def apply(self, traversal):
         if traversal.traversers is None:
             remote_traversal = self.remote_connection.submit(traversal.bytecode)
+            traversal.remote_results = remote_traversal
             traversal.side_effects = remote_traversal.side_effects
             traversal.traversers = remote_traversal.traversers
 
     def apply_async(self, traversal):
         if traversal.traversers is None:
-            remote_traversal = self.remote_connection.submit_async(
+            traversal.remote_results = self.remote_connection.submitAsync(
                 traversal.bytecode)
-            traversal.side_effects = remote_traversal.side_effects
-            traversal.traversers = remote_traversal.traversers

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/driver/request.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/request.py b/gremlin-python/src/main/jython/gremlin_python/driver/request.py
new file mode 100644
index 0000000..ac7b845
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/request.py
@@ -0,0 +1,25 @@
+"""
+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.
+"""
+import collections
+
+__author__ = 'David M. Brown (davebshow@gmail.com)'
+
+
+RequestMessage = collections.namedtuple(
+    'RequestMessage', ['processor', 'op', 'args'])

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py b/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
new file mode 100644
index 0000000..cfdca5b
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/resultset.py
@@ -0,0 +1,91 @@
+"""
+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.
+"""
+from concurrent.futures import Future
+
+__author__ = 'David M. Brown (davebshow@gmail.com)'
+
+
+class ResultSet:
+
+    def __init__(self, stream, request_id):
+        self._stream = stream
+        self._request_id = request_id
+        self._done = None
+        self._aggregate_to = None
+
+    @property
+    def aggregate_to(self):
+        return self._aggregate_to
+
+    @aggregate_to.setter
+    def aggregate_to(self, val):
+        self._aggregate_to = val
+
+    @property
+    def request_id(self):
+        return self._request_id
+
+    @property
+    def stream(self):
+        return self._stream
+
+    def __iter__(self):
+        return self
+
+    def __next__(self):
+        result = self.one()
+        if not result:
+            raise StopIteration
+        return result
+
+    def next(self):
+        return self.__next__()
+
+    @property
+    def done(self):
+        return self._done
+
+    @done.setter
+    def done(self, future):
+        self._done = future
+
+    def one(self):
+        while not self.done.done():
+            if not self.stream.empty():
+                return self.stream.get_nowait()
+        if not self.stream.empty():
+            return self.stream.get_nowait()
+        return self.done.result()
+
+    def all(self):
+        future = Future()
+
+        def cb(f):
+            try:
+                f.result()
+            except Exception as e:
+                future.set_exception(e)
+            else:
+                results = []
+                while not self.stream.empty():
+                    results += self.stream.get_nowait()
+                future.set_result(results)
+
+        self.done.add_done_callback(cb)
+        return future

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py b/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
new file mode 100644
index 0000000..10dcfd3
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
@@ -0,0 +1,117 @@
+"""
+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.
+"""
+try:
+    import ujson as json
+except ImportError:
+    import json
+
+from gremlin_python.structure.io import graphson
+
+__author__ = 'David M. Brown (davebshow@gmail.com)'
+
+
+class Processor:
+    """Base class for OpProcessor serialization system."""
+
+    _graphson_writer = graphson.GraphSONWriter()
+
+    def __init__(self, default_args):
+        self._default_args = default_args
+
+    def get_op_args(self, op, args):
+        op_method = getattr(self, op, None)
+        if not op_method:
+            raise Exception("Processor does not support op: {}".format(op))
+        args_ = self._default_args.get(op, dict()).copy()
+        args_.update(args)
+        return op_method(args_)
+
+
+class GraphSONMessageSerializer:
+    """Message serializer for GraphSON"""
+
+    _graphson_reader = graphson.GraphSONReader()
+
+    class traversal(Processor):
+
+        def authentication(self, args):
+            return args
+
+        def bytecode(self, args):
+            gremlin = args['gremlin']
+            args['gremlin'] = self._graphson_writer.toDict(gremlin)
+            aliases = args.get('aliases', '')
+            if not aliases:
+                aliases = {'g': 'g'}
+            args['aliases'] = aliases
+            return args
+
+        def close(self, args):
+            return self.keys(args)
+
+        def gather(self, args):
+            side_effect = args['sideEffect']
+            args['sideEffect'] = {'@type': 'g:UUID', '@value': side_effect}
+            aliases = args.get('aliases', '')
+            if not aliases:
+                aliases = {'g': 'g'}
+            args['aliases'] = aliases
+            return args
+
+        def keys(self, args):
+            side_effect = args['sideEffect']
+            args['sideEffect'] = {'@type': 'g:UUID', '@value': side_effect}
+            return args
+
+
+    def get_processor(self, processor):
+        processor = getattr(self, processor, None)
+        if not processor:
+            raise Exception("Unknown processor")
+        return processor({})
+
+    def serialize_message(self, request_id, request_message):
+        processor = request_message.processor
+        op = request_message.op
+        args = request_message.args
+        if not processor:
+            processor_obj = self.get_processor('standard')
+        else:
+            processor_obj = self.get_processor(processor)
+        args = processor_obj.get_op_args(op, args)
+        message = self.build_message(request_id, processor, op, args)
+        return message
+
+    def build_message(self, request_id, processor, op, args):
+        message = {
+            'requestId': {'@type': 'g:UUID', '@value': request_id},
+            'processor': processor,
+            'op': op,
+            'args': args
+        }
+        return self.finalize_message(message, b"\x21",
+                                     b"application/vnd.gremlin-v2.0+json")
+
+    def finalize_message(self, message, mime_len, mime_type):
+        message = json.dumps(message)
+        message = b''.join([mime_len, mime_type, message.encode('utf-8')])
+        return message
+
+    def deserialize_message(self, message):
+        return self._graphson_reader.toObject(message)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/driver/tornado/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/tornado/__init__.py b/gremlin-python/src/main/jython/gremlin_python/driver/tornado/__init__.py
new file mode 100644
index 0000000..17b49a5
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/tornado/__init__.py
@@ -0,0 +1,18 @@
+"""
+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.
+"""

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/driver/tornado/transport.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/tornado/transport.py b/gremlin-python/src/main/jython/gremlin_python/driver/tornado/transport.py
new file mode 100644
index 0000000..cc218e9
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/tornado/transport.py
@@ -0,0 +1,48 @@
+"""
+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.
+"""
+from tornado import ioloop, gen
+from tornado import websocket
+
+from gremlin_python.driver.transport import AbstractBaseTransport
+
+__author__ = 'David M. Brown (davebshow@gmail.com)'
+
+
+class TornadoTransport(AbstractBaseTransport):
+
+    def __init__(self):
+        self._loop = ioloop.IOLoop(make_current=False)
+
+    def connect(self, url):
+        self._ws = self._loop.run_sync(
+            lambda: websocket.websocket_connect(url))
+
+    def write(self, message):
+        self._loop.run_sync(
+            lambda: self._ws.write_message(message, binary=True))
+
+    def read(self):
+        return self._loop.run_sync(lambda: self._ws.read_message())
+
+    def close(self):
+        self._ws.close()
+        self._loop.close()
+
+    def closed(self):
+        return not self._ws.protocol

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/driver/transport.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/transport.py b/gremlin-python/src/main/jython/gremlin_python/driver/transport.py
new file mode 100644
index 0000000..9181956
--- /dev/null
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/transport.py
@@ -0,0 +1,46 @@
+"""
+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.
+"""
+import abc
+import six
+
+__author__ = 'David M. Brown (davebshow@gmail.com)'
+
+
+@six.add_metaclass(abc.ABCMeta)
+class AbstractBaseTransport:
+
+    @abc.abstractmethod
+    def connect(self, url):
+        pass
+
+    @abc.abstractmethod
+    def write(self, message):
+        pass
+
+    @abc.abstractmethod
+    def read(self):
+        pass
+
+    @abc.abstractmethod
+    def close(self):
+        pass
+
+    @abc.abstractproperty
+    def closed(self):
+        pass

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
index 07afeac..f09ab76 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
@@ -79,15 +79,16 @@ class Traversal(object):
             return tempList
     def promise(self, cb=None):
         self.traversal_strategies.apply_async_strategies(self)
-        future_traversers = self.traversers
-        future = type(future_traversers)()
+        future_traversal = self.remote_results
+        future = type(future_traversal)()
         def process(f):
             try:
-                traversers = f.result()
+                traversal = f.result()
             except Exception as e:
                 future.set_exception(e)
             else:
-                self.traversers = iter(traversers)
+                self.traversers = iter(traversal.traversers)
+                self.side_effects = traversal.side_effects
                 if cb:
                     try:
                         result = cb(self)
@@ -97,7 +98,7 @@ class Traversal(object):
                         future.set_result(result)
                 else:
                     future.set_result(self)
-        future_traversers.add_done_callback(process)
+        future_traversal.add_done_callback(process)
         return future
 
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/setup.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/setup.py b/gremlin-python/src/main/jython/setup.py
index 6878c34..8b30b9f 100644
--- a/gremlin-python/src/main/jython/setup.py
+++ b/gremlin-python/src/main/jython/setup.py
@@ -18,8 +18,9 @@ under the License.
 '''
 import codecs
 import os
+import sys
 import time
-from setuptools import setup, Command
+from setuptools import setup
 
 # Folder containing the setup.py
 root = os.path.dirname(os.path.abspath(__file__))
@@ -43,6 +44,15 @@ from gremlin_python import __version__
 
 version = __version__.version
 
+install_requires = [
+    'aenum==1.4.5',
+    'tornado==4.4.1',
+    'six==1.10.0'
+]
+
+if sys.version_info < (3,2):
+    install_requires += ['futures==3.0.5']
+
 setup(
     name='gremlinpython',
     version=version,
@@ -60,11 +70,7 @@ setup(
         'pytest',
         'mock'
     ],
-    install_requires=[
-        'aenum==1.4.5',
-        'tornado==4.4.1',
-        'six==1.10.0'
-    ],
+    install_requires=install_requires,
     classifiers=[
         "Intended Audience :: Developers",
         "License :: OSI Approved :: Apache Software License",

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/tests/conftest.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/conftest.py b/gremlin-python/src/main/jython/tests/conftest.py
new file mode 100644
index 0000000..3ab64a8
--- /dev/null
+++ b/gremlin-python/src/main/jython/tests/conftest.py
@@ -0,0 +1,72 @@
+'''
+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.
+'''
+import concurrent.futures
+import pytest
+
+from six.moves import queue
+
+from gremlin_python.driver.client import Client
+from gremlin_python.driver.connection import Connection
+from gremlin_python.driver.driver_remote_connection import (
+    DriverRemoteConnection)
+from gremlin_python.driver.protocol import GremlinServerWSProtocol
+from gremlin_python.driver.tornado.transport import TornadoTransport
+
+
+@pytest.fixture
+def connection(request):
+    try:
+        protocol = GremlinServerWSProtocol(
+            username='stephen', password='password')
+        executor = concurrent.futures.ThreadPoolExecutor(5)
+        pool = queue.Queue()
+        conn = Connection('ws://localhost:45940/gremlin', 'g', protocol,
+                          lambda: TornadoTransport(), executor, pool)
+    except:
+        pytest.skip('Gremlin Server is not running')
+    else:
+        def fin():
+            executor.shutdown()
+            conn.close()
+        request.addfinalizer(fin)
+        return conn
+
+@pytest.fixture
+def client(request):
+    try:
+        client = Client('ws://localhost:45940/gremlin', 'g')
+    except:
+        pytest.skip('Gremlin Server is not running')
+    else:
+        def fin():
+            client.close()
+        request.addfinalizer(fin)
+        return client
+
+@pytest.fixture
+def remote_connection(request):
+    try:
+        remote_conn = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
+    except:
+        pytest.skip('Gremlin Server is not running')
+    else:
+        def fin():
+            remote_conn.close()
+        request.addfinalizer(fin)
+        return remote_conn

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/tests/driver/test_client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_client.py b/gremlin-python/src/main/jython/tests/driver/test_client.py
new file mode 100644
index 0000000..6395d7b
--- /dev/null
+++ b/gremlin-python/src/main/jython/tests/driver/test_client.py
@@ -0,0 +1,98 @@
+'''
+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.
+'''
+import pytest
+
+from gremlin_python.driver.client import Client
+from gremlin_python.driver.request import RequestMessage
+from gremlin_python.structure.graph import Graph
+
+__author__ = 'David M. Brown (davebshow@gmail.com)'
+
+
+def test_connection(connection):
+    g = Graph().traversal()
+    t = g.V()
+    message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
+    results_set = connection.write(message).result()
+    future = results_set.all()
+    results = future.result()
+    assert len(results) == 6
+    assert isinstance(results, list)
+
+def test_client(client):
+    g = Graph().traversal()
+    t = g.V()
+    message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
+    result_set = client.submit(message)
+    assert len(result_set.all().result()) == 6
+    client.close()
+
+def test_iterate_result_set(client):
+    g = Graph().traversal()
+    t = g.V()
+    message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
+    result_set = client.submit(message)
+    results = []
+    for result in result_set:
+        results += result
+    assert len(results) == 6
+    client.close()
+
+def test_client_async(client):
+    g = Graph().traversal()
+    t = g.V()
+    message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
+    future = client.submitAsync(message)
+    assert not future.done()
+    result_set = future.result()
+    assert len(result_set.all().result()) == 6
+    client.close()
+
+def test_connection_share(client):
+    # Overwrite fixture with pool_size=1 client
+    client = Client('ws://localhost:45940/gremlin', 'g', pool_size=1)
+    g = Graph().traversal()
+    t = g.V()
+    message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
+    future = client.submitAsync(message)
+    future2 = client.submitAsync(message)
+
+    result_set2 = future2.result()
+    assert len(result_set2.all().result()) == 6
+
+    # This future has to finish for the second to yield result - pool_size=1
+    assert future.done()
+    result_set = future.result()
+    assert len(result_set.all().result()) == 6
+    client.close()
+
+def test_multi_conn_pool(client):
+    g = Graph().traversal()
+    t = g.V()
+    message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
+    future = client.submitAsync(message)
+    future2 = client.submitAsync(message)
+
+    result_set2 = future2.result()
+    assert len(result_set2.all().result()) == 6
+
+    # with connection pool `future` may or may not be done here
+    result_set = future.result()
+    assert len(result_set.all().result()) == 6
+    client.close()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
index 783cf7e..cd64e2b 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
@@ -16,19 +16,14 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 '''
-
-__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
-
-import unittest
-from unittest import TestCase
-
 import pytest
 
 from tornado import ioloop, gen
 
 from gremlin_python import statics
 from gremlin_python.statics import long
-from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
+from gremlin_python.driver.driver_remote_connection import (
+    DriverRemoteConnection)
 from gremlin_python.process.traversal import Traverser
 from gremlin_python.process.traversal import TraversalStrategy
 from gremlin_python.process.graph_traversal import __
@@ -36,16 +31,17 @@ from gremlin_python.structure.graph import Graph
 from gremlin_python.structure.graph import Vertex
 from gremlin_python.process.strategies import SubgraphStrategy
 
+__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
+
 
-class TestDriverRemoteConnection(TestCase):
-    def test_traversals(self):
+class TestDriverRemoteConnection(object):
+    def test_traversals(self, remote_connection):
         statics.load_statics(globals())
-        connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
-        assert "remoteconnection[ws://localhost:45940/gremlin,g]" == str(connection)
-        g = Graph().traversal().withRemote(connection)
+        assert "remoteconnection[ws://localhost:45940/gremlin,g]" == str(remote_connection)
+        g = Graph().traversal().withRemote(remote_connection)
 
         assert long(6) == g.V().count().toList()[0]
-        #
+        # #
         assert Vertex(1) == g.V(1).next()
         assert 1 == g.V(1).id().next()
         assert Traverser(Vertex(1)) == g.V(1).nextTraverser()
@@ -56,26 +52,24 @@ class TestDriverRemoteConnection(TestCase):
         assert 2 == len(results)
         assert "lop" in results
         assert "ripple" in results
-        #
+        # #
         assert 10 == g.V().repeat(both()).times(5)[0:10].count().next()
-        assert 1 == g.V().repeat(both()).times(5)[0].count().next()
+        assert 1 == g.V().repeat(both()).times(5)[0:1].count().next()
         assert 0 == g.V().repeat(both()).times(5)[0:0].count().next()
         assert 4 == g.V()[2:].count().next()
         assert 2 == g.V()[:2].count().next()
-        #
+        # #
         results = g.withSideEffect('a',['josh','peter']).V(1).out('created').in_('created').values('name').where(within('a')).toList()
         assert 2 == len(results)
         assert 'josh' in results
         assert 'peter' in results
-        # todo: need a traversal metrics deserializer
+        # # todo: need a traversal metrics deserializer
         g.V().out().profile().next()
-        connection.close()
 
-    def test_strategies(self):
+    def test_strategies(self, remote_connection):
         statics.load_statics(globals())
-        connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
         #
-        g = Graph().traversal().withRemote(connection). \
+        g = Graph().traversal().withRemote(remote_connection). \
             withStrategies(TraversalStrategy("SubgraphStrategy",
                                              {"vertices": __.hasLabel("person"),
                                               "edges": __.hasLabel("created")}))
@@ -84,7 +78,7 @@ class TestDriverRemoteConnection(TestCase):
         assert 1 == g.V().label().dedup().count().next()
         assert "person" == g.V().label().dedup().next()
         #
-        g = Graph().traversal().withRemote(connection). \
+        g = Graph().traversal().withRemote(remote_connection). \
             withStrategies(SubgraphStrategy(vertices=__.hasLabel("person"), edges=__.hasLabel("created")))
         assert 4 == g.V().count().next()
         assert 0 == g.E().count().next()
@@ -98,24 +92,19 @@ class TestDriverRemoteConnection(TestCase):
         assert "person" == g.V().label().next()
         assert "marko" == g.V().name.next()
         #
-        g = Graph().traversal().withRemote(connection).withComputer()
+        g = Graph().traversal().withRemote(remote_connection).withComputer()
         assert 6 == g.V().count().next()
         assert 6 == g.E().count().next()
-        connection.close()
 
-    def test_side_effects(self):
+    def test_side_effects(self, remote_connection):
         statics.load_statics(globals())
-        connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
         #
-        g = Graph().traversal().withRemote(connection)
+        g = Graph().traversal().withRemote(remote_connection)
         ###
         t = g.V().hasLabel("project").name.iterate()
         assert 0 == len(t.side_effects.keys())
-        try:
+        with pytest.raises(Exception):
             m = t.side_effects["m"]
-            raise Exception("Accessing a non-existent key should throw an error")
-        except KeyError:
-            pass
         ###
         t = g.V().out("created").groupCount("m").by("name")
         results = t.toSet()
@@ -131,7 +120,7 @@ class TestDriverRemoteConnection(TestCase):
         assert 1 == m["ripple"]
         assert isinstance(m["lop"], long)
         assert isinstance(m["ripple"], long)
-        ###
+        ##
         t = g.V().out("created").groupCount("m").by("name").name.aggregate("n")
         results = t.toSet()
         assert 2 == len(results)
@@ -154,16 +143,11 @@ class TestDriverRemoteConnection(TestCase):
         assert 32 == list(results)[0]
         assert 32 == t.side_effects['m']
         assert 1 == len(t.side_effects.keys())
-        try:
+        with pytest.raises(Exception):
             x = t.side_effects["x"]
-            raise Exception("Accessing a non-existent key should throw an error")
-        except KeyError:
-            pass
-        connection.close()
 
-    def test_side_effect_close(self):
-        connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
-        g = Graph().traversal().withRemote(connection)
+    def test_side_effect_close(self, remote_connection):
+        g = Graph().traversal().withRemote(remote_connection)
         t = g.V().aggregate('a').aggregate('b')
         t.toList()
 
@@ -193,76 +177,30 @@ class TestDriverRemoteConnection(TestCase):
         # Try to get 'b' directly from server, should throw error
         with pytest.raises(Exception):
             t.side_effects.value_lambda('b')
-        connection.close()
 
-    def test_promise(self):
-        loop = ioloop.IOLoop.current()
-        connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
-        g = Graph().traversal().withRemote(connection)
-
-        @gen.coroutine
-        def go():
-            future_traversal = g.V().promise(lambda x: x.toList())
-            assert not future_traversal.done()
-            resp = yield future_traversal
-            assert future_traversal.done()
-            assert len(resp) == 6
-            count = yield g.V().count().promise(lambda x: x.next())
-            assert count == 6
-
-        loop.run_sync(go)
-        connection.close()
-
-    def test_promise_side_effects(self):
-        loop = ioloop.IOLoop.current()
-        connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
-        g = Graph().traversal().withRemote(connection)
-
-        # Side effects are problematic in coroutines.
-        # Because they are designed to be synchronous (calling `run_sync`)
-        # they result in an error if called from a coroutine because
-        # the event loop is already running
-        @gen.coroutine
-        def go():
-            traversal = yield g.V().aggregate('a').promise()
-            # Calling synchronous side effect methods from coroutine raises.
-            with pytest.raises(RuntimeError):
-                keys = traversal.side_effects.keys()
-
-            with pytest.raises(RuntimeError):
-                keys = traversal.side_effects.get('a')
-
-            with pytest.raises(RuntimeError):
-                keys = traversal.side_effects.close()
-
-        loop.run_sync(go)
-
-        # If we return the traversal though, we can use side effects per usual.
-        @gen.coroutine
-        def go():
-            traversal = yield g.V().aggregate('a').promise()
-            raise gen.Return(traversal)  # Weird legacy Python compatible idiom
-
-        # See, normal side effects.
-        traversal = loop.run_sync(go)
-        a, = traversal.side_effects.keys()
+    def test_promise(self, remote_connection):
+        g = Graph().traversal().withRemote(remote_connection)
+        future = g.V().aggregate('a').promise()
+        t = future.result()
+        assert len(t.toList()) == 6
+        a, = t.side_effects.keys()
         assert  a == 'a'
-        results = traversal.side_effects.get('a')
+        results = t.side_effects.get('a')
         assert results
-        results = traversal.side_effects.close()
+        results = t.side_effects.close()
         assert not results
 
-        connection.close()
-
 
-if __name__ == '__main__':
-    test = False
-    try:
-        connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
-        test = True
-        connection.close()
-    except:
-        print("GremlinServer is not running and this test case will not execute: " + __file__)
+def test_in_tornado_app(remote_connection):
+    # Make sure nothing weird with loops
+    @gen.coroutine
+    def go():
+        conn = DriverRemoteConnection(
+            'ws://localhost:45940/gremlin', 'g', pool_size=4)
+        g = Graph().traversal().withRemote(conn)
+        yield gen.sleep(0)
+        assert len(g.V().toList()) == 6
+        conn.close()
 
-    if test:
-        unittest.main()
+    io_loop = ioloop.IOLoop.current()
+    io_loop.run_sync(go)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py
index 0c18651..d5efc0d 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection_threaded.py
@@ -16,58 +16,53 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 '''
-
-
-__author__ = 'David M. Brown (davebshow@gmail.com)'
-
-
 import sys
 from threading import Thread
 
 import pytest
-
 from six.moves import queue
-from tornado import ioloop
 
 from gremlin_python.driver.driver_remote_connection import (
     DriverRemoteConnection)
 from gremlin_python.structure.graph import Graph
 
-
-skip = False
-try:
-    connection = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
-    connection.close()
-except:
-    skip = True
+__author__ = 'David M. Brown (davebshow@gmail.com)'
 
 
-@pytest.mark.skipif(skip, reason='Gremlin Server is not running')
-class TestDriverRemoteConnectionThreaded:
+def test_conns_in_threads(remote_connection):
+    q = queue.Queue()
+    child = Thread(target=_executor, args=(q, None))
+    child2 = Thread(target=_executor, args=(q, None))
+    child.start()
+    child2.start()
+    for x in range(2):
+        success = q.get()
+        assert success == 'success!'
+    child.join()
+    child2.join()
 
-    def test_threaded_client(self):
-        q = queue.Queue()
-        # Here if we give each thread its own loop there is no problem.
-        loop1 = ioloop.IOLoop()
-        loop2 = ioloop.IOLoop()
-        child = Thread(target=self._executor, args=(q, loop1))
-        child2 = Thread(target=self._executor, args=(q, loop2))
-        child.start()
-        child2.start()
-        for x in range(2):
-            success = q.get()
-            assert success == 'success!'
-        child.join()
-        child2.join()
+def test_conn_in_threads(remote_connection):
+    q = queue.Queue()
+    child = Thread(target=_executor, args=(q, remote_connection))
+    child2 = Thread(target=_executor, args=(q, remote_connection))
+    child.start()
+    child2.start()
+    for x in range(2):
+        success = q.get()
+        assert success == 'success!'
+    child.join()
+    child2.join()
 
-    def _executor(self, q, loop):
-        try:
-            connection = DriverRemoteConnection(
-                'ws://localhost:45940/gremlin', 'g', loop=loop)
-            g = Graph().traversal().withRemote(connection)
-            assert len(g.V().toList()) == 6
-        except:
-            q.put(sys.exc_info()[0])
-        else:
-            q.put('success!')
-            connection.close()
+def _executor(q, conn):
+    if not conn:
+        conn = DriverRemoteConnection(
+            'ws://localhost:45940/gremlin', 'g', pool_size=4)
+    try:
+        g = Graph().traversal().withRemote(conn)
+        future = g.V().promise()
+        t = future.result()
+        assert len(t.toList()) == 6
+    except:
+        q.put(sys.exc_info()[0])
+    else:
+        q.put('success!')

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1d203b74/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py b/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
index 2437cfd..7bca769 100644
--- a/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
@@ -141,8 +141,25 @@ class TestGraphSONWriter(TestCase):
         assert """true""" == self.graphson_writer.writeObject(True)
 
     def test_P(self):
-        assert """{"@type":"g:P","@value":{"predicate":"and","value":[{"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},{"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},{"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}}""" == self.graphson_writer.writeObject(
-            P.lt("b").or_(P.gt("c")).and_(P.neq("d")))
+        result = {'@type': 'g:P',
+                  '@value': {
+                     'predicate': 'and',
+                     'value': [{
+                        '@type': 'g:P',
+                        '@value': {
+                            'predicate': 'or',
+                            'value': [{
+                                '@type': 'g:P',
+                                '@value': {'predicate': 'lt', 'value': 'b'}
+                            },
+                            {'@type': 'g:P', '@value': {'predicate': 'gt', 'value': 'c'}}
+                            ]
+                        }
+                    },
+                    {'@type': 'g:P', '@value': {'predicate': 'neq', 'value': 'd'}}]}}
+
+        assert  result == json.loads(
+            self.graphson_writer.writeObject(P.lt("b").or_(P.gt("c")).and_(P.neq("d"))))
 
     def test_strategies(self):
         # we have a proxy model for now given that we don't want to have to have g:XXX all registered on the Gremlin traversal machine (yet)


[03/21] tinkerpop git commit: Merge branch 'TINKERPOP-1627' into tp32

Posted by da...@apache.org.
Merge branch 'TINKERPOP-1627' into tp32


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

Branch: refs/heads/TINKERPOP-1599
Commit: b717615dfe6176413f223316f925c975d81ba1c1
Parents: 4a328b9 b635c80
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Feb 16 11:09:32 2017 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Feb 16 11:09:32 2017 -0700

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  3 ++-
 .../upgrade/release-3.2.x-incubating.asciidoc   | 26 ++++++++++++++++++++
 .../strategy/decoration/RemoteStrategy.java     |  1 -
 .../optimization/LazyBarrierStrategy.java       |  2 +-
 .../optimization/LazyBarrierStrategyTest.java   | 19 +++++++-------
 .../gremlin/server/util/TraverserIterator.java  | 21 +++++++++++++---
 .../Neo4jGraphStepStrategyTest.java             |  2 +-
 .../TinkerGraphStepStrategyTest.java            |  2 +-
 8 files changed, 58 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b717615d/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index e3c78f9,30fb41e..de78d24
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -26,8 -26,8 +26,9 @@@ image::https://raw.githubusercontent.co
  TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
 +* 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`.
+ * `TraverserIterator` in GremlinServer is smart to try and bulk traversers prior to network I/O.
  
  [[release-3-2-4]]
  TinkerPop 3.2.4 (Release Date: February 8, 2017)


[18/21] tinkerpop git commit: added standard message processor

Posted by da...@apache.org.
added standard message processor


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

Branch: refs/heads/TINKERPOP-1599
Commit: 07d2064677db405493c7963a937dcbcd4f502b20
Parents: 949ed56
Author: davebshow <da...@gmail.com>
Authored: Wed Feb 15 14:25:28 2017 -0500
Committer: davebshow <da...@gmail.com>
Committed: Fri Feb 17 11:36:57 2017 -0500

----------------------------------------------------------------------
 .../src/main/jython/gremlin_python/driver/client.py  |  5 +++++
 .../main/jython/gremlin_python/driver/serializer.py  | 10 ++++++++++
 .../src/main/jython/tests/driver/test_client.py      | 15 ++++++++++++++-
 3 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/07d20646/gremlin-python/src/main/jython/gremlin_python/driver/client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/client.py b/gremlin-python/src/main/jython/gremlin_python/driver/client.py
index dec39bf..fcbdf07 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/client.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/client.py
@@ -110,5 +110,10 @@ class Client:
                 processor='traversal', op='bytecode',
                 args={'gremlin': message,
                       'aliases': {'g': self._traversal_source}})
+        elif isinstance(message, str):
+            message = request.RequestMessage(
+                processor='', op='eval',
+                args={'gremlin': message,
+                      'aliases': {'g': self._traversal_source}})
         conn = self._pool.get(True)
         return conn.write(message)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/07d20646/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py b/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
index 10dcfd3..2db7374 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
@@ -48,6 +48,16 @@ class GraphSONMessageSerializer:
 
     _graphson_reader = graphson.GraphSONReader()
 
+
+    class standard(Processor):
+
+        def authentication(self, args):
+            return args
+
+        def eval(self, args):
+            return args
+
+
     class traversal(Processor):
 
         def authentication(self, args):

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/07d20646/gremlin-python/src/main/jython/tests/driver/test_client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_client.py b/gremlin-python/src/main/jython/tests/driver/test_client.py
index 2e0e96c..02582a1 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_client.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_client.py
@@ -35,13 +35,23 @@ def test_connection(connection):
     assert len(results) == 6
     assert isinstance(results, list)
 
-def test_client(client):
+
+def test_client_simple_eval(client):
+    assert client.submit('1 + 1').all().result()[0] == 2
+
+
+def test_client_eval_traversal(client):
+    assert len(client.submit('g.V()').all().result()) == 6
+
+
+def test_client_bytecode(client):
     g = Graph().traversal()
     t = g.V()
     message = RequestMessage('traversal', 'bytecode', {'gremlin': t.bytecode})
     result_set = client.submit(message)
     assert len(result_set.all().result()) == 6
 
+
 def test_iterate_result_set(client):
     g = Graph().traversal()
     t = g.V()
@@ -52,6 +62,7 @@ def test_iterate_result_set(client):
         results += result
     assert len(results) == 6
 
+
 def test_client_async(client):
     g = Graph().traversal()
     t = g.V()
@@ -61,6 +72,7 @@ def test_client_async(client):
     result_set = future.result()
     assert len(result_set.all().result()) == 6
 
+
 def test_connection_share(client):
     # Overwrite fixture with pool_size=1 client
     client = Client('ws://localhost:45940/gremlin', 'g', pool_size=1)
@@ -78,6 +90,7 @@ def test_connection_share(client):
     result_set = future.result()
     assert len(result_set.all().result()) == 6
 
+
 def test_multi_conn_pool(client):
     g = Graph().traversal()
     t = g.V()


[07/21] tinkerpop git commit: Added links to reference docs in GraphTraversal javadoc for Vertex ops CTR

Posted by da...@apache.org.
Added links to reference docs in GraphTraversal javadoc for Vertex ops CTR


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

Branch: refs/heads/TINKERPOP-1599
Commit: 1780823a48e0ac99d5d66e64ba34d9d42e3fedad
Parents: ff96e3c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Feb 16 16:37:50 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Feb 16 16:37:50 2017 -0500

----------------------------------------------------------------------
 .../process/traversal/dsl/graph/GraphTraversal.java    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1780823a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index d6e6cfd..29f3b0a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -290,6 +290,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param direction  the direction to traverse from the current vertex
      * @param edgeLabels the edge labels to traverse
      * @return the traversal with an appended {@link VertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Vertex> to(final Direction direction, final String... edgeLabels) {
         this.asAdmin().getBytecode().addStep(Symbols.to, direction, edgeLabels);
@@ -301,6 +302,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      *
      * @param edgeLabels the edge labels to traverse
      * @return the traversal with an appended {@link VertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Vertex> out(final String... edgeLabels) {
         this.asAdmin().getBytecode().addStep(Symbols.out, edgeLabels);
@@ -312,6 +314,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      *
      * @param edgeLabels the edge labels to traverse
      * @return the traversal with an appended {@link VertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Vertex> in(final String... edgeLabels) {
         this.asAdmin().getBytecode().addStep(Symbols.in, edgeLabels);
@@ -323,6 +326,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      *
      * @param edgeLabels the edge labels to traverse
      * @return the traversal with an appended {@link VertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Vertex> both(final String... edgeLabels) {
         this.asAdmin().getBytecode().addStep(Symbols.both, edgeLabels);
@@ -335,6 +339,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param direction  the direction to traverse from the current vertex
      * @param edgeLabels the edge labels to traverse
      * @return the traversal with an appended {@link VertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Edge> toE(final Direction direction, final String... edgeLabels) {
         this.asAdmin().getBytecode().addStep(Symbols.toE, direction, edgeLabels);
@@ -346,6 +351,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      *
      * @param edgeLabels the edge labels to traverse
      * @return the traversal with an appended {@link VertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Edge> outE(final String... edgeLabels) {
         this.asAdmin().getBytecode().addStep(Symbols.outE, edgeLabels);
@@ -357,6 +363,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      *
      * @param edgeLabels the edge labels to traverse
      * @return the traversal with an appended {@link VertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Edge> inE(final String... edgeLabels) {
         this.asAdmin().getBytecode().addStep(Symbols.inE, edgeLabels);
@@ -368,6 +375,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      *
      * @param edgeLabels the edge labels to traverse
      * @return the traversal with an appended {@link VertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Edge> bothE(final String... edgeLabels) {
         this.asAdmin().getBytecode().addStep(Symbols.bothE, edgeLabels);
@@ -379,6 +387,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      *
      * @param direction the direction to traverser from the current edge
      * @return the traversal with an appended {@link EdgeVertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Vertex> toV(final Direction direction) {
         this.asAdmin().getBytecode().addStep(Symbols.toV, direction);
@@ -389,6 +398,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * Map the {@link Edge} to its incoming/head incident {@link Vertex}.
      *
      * @return the traversal with an appended {@link EdgeVertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Vertex> inV() {
         this.asAdmin().getBytecode().addStep(Symbols.inV);
@@ -399,6 +409,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * Map the {@link Edge} to its outgoing/tail incident {@link Vertex}.
      *
      * @return the traversal with an appended {@link EdgeVertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Vertex> outV() {
         this.asAdmin().getBytecode().addStep(Symbols.outV);
@@ -409,6 +420,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * Map the {@link Edge} to its incident vertices.
      *
      * @return the traversal with an appended {@link EdgeVertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Vertex> bothV() {
         this.asAdmin().getBytecode().addStep(Symbols.bothV);
@@ -419,6 +431,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * Map the {@link Edge} to the incident vertex that was not just traversed from in the path history.
      *
      * @return the traversal with an appended {@link EdgeOtherVertexStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps">Reference Documentation - Vertex Step</a>
      */
     public default GraphTraversal<S, Vertex> otherV() {
         this.asAdmin().getBytecode().addStep(Symbols.otherV);


[05/21] tinkerpop git commit: Add javadoc for general steps on GraphTraversal CTR

Posted by da...@apache.org.
Add javadoc for general steps on GraphTraversal CTR


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

Branch: refs/heads/TINKERPOP-1599
Commit: a30dabc7c5eb93e644c3f706a2f33786a156a465
Parents: 7d173c8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Feb 16 16:10:43 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Feb 16 16:10:43 2017 -0500

----------------------------------------------------------------------
 .../traversal/dsl/graph/GraphTraversal.java     | 56 +++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a30dabc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index 2e5858a..b00293d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -187,16 +187,24 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
     ///////////////////// MAP STEPS /////////////////////
 
     /**
-     * Map a traverser referencing an object of type <code>E</code> to an object of type <code>E2</code>.
+     * Map a {@link Traverser} referencing an object of type <code>E</code> to an object of type <code>E2</code>.
      *
      * @param function the lambda expression that does the functional mapping
      * @return the traversal with an appended {@link LambdaMapStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#general-steps">Reference Documentation - General Steps</a>
      */
     public default <E2> GraphTraversal<S, E2> map(final Function<Traverser<E>, E2> function) {
         this.asAdmin().getBytecode().addStep(Symbols.map, function);
         return this.asAdmin().addStep(new LambdaMapStep<>(this.asAdmin(), function));
     }
 
+    /**
+     * Map a {@link Traverser} referencing an object of type <code>E</code> to an object of type <code>E2</code>.
+     *
+     * @param mapTraversal the traversal expression that does the functional mapping
+     * @return the traversal with an appended {@link LambdaMapStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#general-steps">Reference Documentation - General Steps</a>
+     */
     public default <E2> GraphTraversal<S, E2> map(final Traversal<?, E2> mapTraversal) {
         this.asAdmin().getBytecode().addStep(Symbols.map, mapTraversal);
         return this.asAdmin().addStep(new TraversalMapStep<>(this.asAdmin(), mapTraversal));
@@ -209,6 +217,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param function the lambda expression that does the functional mapping
      * @param <E2>     the type of the returned iterator objects
      * @return the traversal with an appended {@link LambdaFlatMapStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#general-steps">Reference Documentation - General Steps</a>
      */
     public default <E2> GraphTraversal<S, E2> flatMap(final Function<Traverser<E>, Iterator<E2>> function) {
         this.asAdmin().getBytecode().addStep(Symbols.flatMap, function);
@@ -222,6 +231,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * @param flatMapTraversal the traversal generating objects of type <code>E2</code>
      * @param <E2>             the end type of the internal traversal
      * @return the traversal with an appended {@link TraversalFlatMapStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#general-steps">Reference Documentation - General Steps</a>
      */
     public default <E2> GraphTraversal<S, E2> flatMap(final Traversal<?, E2> flatMapTraversal) {
         this.asAdmin().getBytecode().addStep(Symbols.flatMap, flatMapTraversal);
@@ -839,11 +849,27 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
 
     ///////////////////// FILTER STEPS /////////////////////
 
+    /**
+     * Map the {@link Traverser} to either {@code true} or {@code false}, where {@code false} will not pass the
+     * traverser to the next step.
+     *
+     * @param predicate the filter function to apply
+     * @return the traversal with the {@link LambdaFilterStep} added
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#general-steps">Reference Documentation - General Steps</a>
+     */
     public default GraphTraversal<S, E> filter(final Predicate<Traverser<E>> predicate) {
         this.asAdmin().getBytecode().addStep(Symbols.filter, predicate);
         return this.asAdmin().addStep(new LambdaFilterStep<>(this.asAdmin(), predicate));
     }
 
+    /**
+     * Map the {@link Traverser} to either {@code true} or {@code false}, where {@code false} will not pass the
+     * traverser to the next step.
+     *
+     * @param filterTraversal the filter traversal to apply
+     * @return the traversal with the {@link TraversalFilterStep} added
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#general-steps">Reference Documentation - General Steps</a>
+     */
     public default GraphTraversal<S, E> filter(final Traversal<?, ?> filterTraversal) {
         this.asAdmin().getBytecode().addStep(Symbols.filter, filterTraversal);
         return this.asAdmin().addStep(new TraversalFilterStep<>(this.asAdmin(), (Traversal) filterTraversal));
@@ -1186,11 +1212,25 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
 
     ///////////////////// SIDE-EFFECT STEPS /////////////////////
 
+    /**
+     * Perform some operation on the {@link Traverser} and pass it to the next step unmodified.
+     *
+     * @param consumer the operation to perform at this step in relation to the {@link Traverser}
+     * @return the traversal with an appended {@link LambdaSideEffectStep}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#general-steps">Reference Documentation - General Steps</a>
+     */
     public default GraphTraversal<S, E> sideEffect(final Consumer<Traverser<E>> consumer) {
         this.asAdmin().getBytecode().addStep(Symbols.sideEffect, consumer);
         return this.asAdmin().addStep(new LambdaSideEffectStep<>(this.asAdmin(), consumer));
     }
 
+    /**
+     * Perform some operation on the {@link Traverser} and pass it to the next step unmodified.
+     *
+     * @param sideEffectTraversal the operation to perform at this step in relation to the {@link Traverser}
+     * @return the traversal with an appended {@link TraversalSideEffectStep}
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#general-steps">Reference Documentation - General Steps</a>
+     */
     public default GraphTraversal<S, E> sideEffect(final Traversal<?, ?> sideEffectTraversal) {
         this.asAdmin().getBytecode().addStep(Symbols.sideEffect, sideEffectTraversal);
         return this.asAdmin().addStep(new TraversalSideEffectStep<>(this.asAdmin(), (Traversal) sideEffectTraversal));
@@ -1321,6 +1361,13 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
 
     ///////////////////// BRANCH STEPS /////////////////////
 
+    /**
+     * Split the {@link Traverser} to all the specified traversals.
+     *
+     * @param branchTraversal the traversal to branch the {@link Traverser} to
+     * @return the {@link Traversal} with the {@link BranchStep} added
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#general-steps">Reference Documentation - General Steps</a>
+     */
     public default <M, E2> GraphTraversal<S, E2> branch(final Traversal<?, M> branchTraversal) {
         this.asAdmin().getBytecode().addStep(Symbols.branch, branchTraversal);
         final BranchStep<E, E2, M> branchStep = new BranchStep<>(this.asAdmin());
@@ -1328,6 +1375,13 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
         return this.asAdmin().addStep(branchStep);
     }
 
+    /**
+     * Split the {@link Traverser} to all the specified functions.
+     *
+     * @param function the traversal to branch the {@link Traverser} to
+     * @return the {@link Traversal} with the {@link BranchStep} added
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#general-steps">Reference Documentation - General Steps</a>
+     */
     public default <M, E2> GraphTraversal<S, E2> branch(final Function<Traverser<E>, M> function) {
         this.asAdmin().getBytecode().addStep(Symbols.branch, function);
         final BranchStep<E, E2, M> branchStep = new BranchStep<>(this.asAdmin());


[04/21] tinkerpop git commit: Added ability to inject maven variables to javadoc

Posted by da...@apache.org.
Added ability to inject maven variables to javadoc

This will make it possible to easily cross-reference javadoc to reference docs CTR


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

Branch: refs/heads/TINKERPOP-1599
Commit: 7d173c86be7f6ad00eeb0a18d7b615d9f527ec48
Parents: b717615
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Feb 16 13:55:18 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Feb 16 13:55:18 2017 -0500

----------------------------------------------------------------------
 .../traversal/dsl/graph/GraphTraversal.java     |  1 +
 pom.xml                                         | 36 ++++++++++++++++++++
 2 files changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7d173c86/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index abcb870..2e5858a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -262,6 +262,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
      * Map any object to a fixed <code>E</code> value.
      *
      * @return the traversal with an appended {@link ConstantStep}.
+     * @see <a target="_blank" href="http://tinkerpop.apache.org/docs/${project.version}/reference/#constant-step">Reference Documentation - Constant Step</a>
      */
     public default <E2> GraphTraversal<S, E2> constant(final E2 e) {
         this.asAdmin().getBytecode().addStep(Symbols.constant, e);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7d173c86/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 00eaaab..802593e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1215,6 +1215,42 @@ limitations under the License.
                             </execution>
                         </executions>
                     </plugin>
+                    <plugin>
+                        <artifactId>maven-resources-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>apply-filters-to-javadoc</id>
+                                <phase>process-resources</phase>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals>
+                                <configuration>
+                                    <outputDirectory>${basedir}/target/javadoc-temp</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>${basedir}/target/site/apidocs</directory>
+                                            <filtering>true</filtering>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>copy-java-doc-back</id>
+                                <phase>process-resources</phase>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals>
+                                <configuration>
+                                    <outputDirectory>${basedir}/target/site/apidocs</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>${basedir}/target/javadoc-temp</directory>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
                 </plugins>
             </build>
         </profile>


[17/21] tinkerpop git commit: allow user to pass graphson reader/writer

Posted by da...@apache.org.
allow user to pass graphson reader/writer


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

Branch: refs/heads/TINKERPOP-1599
Commit: e3067e9399e6e4c63a15f796631386448be9424f
Parents: 07d2064
Author: davebshow <da...@gmail.com>
Authored: Wed Feb 15 16:27:46 2017 -0500
Committer: davebshow <da...@gmail.com>
Committed: Fri Feb 17 11:36:57 2017 -0500

----------------------------------------------------------------------
 .../main/jython/gremlin_python/driver/client.py |  6 +-
 .../driver/driver_remote_connection.py          | 20 +++--
 .../jython/gremlin_python/driver/protocol.py    |  9 +-
 .../jython/gremlin_python/driver/serializer.py  | 86 ++++++++++----------
 .../src/main/jython/tests/conftest.py           |  2 +
 5 files changed, 70 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e3067e93/gremlin-python/src/main/jython/gremlin_python/driver/client.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/client.py b/gremlin-python/src/main/jython/gremlin_python/driver/client.py
index fcbdf07..0314a44 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/client.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/client.py
@@ -23,7 +23,7 @@ from concurrent.futures import ThreadPoolExecutor
 
 from six.moves import queue
 
-from gremlin_python.driver import connection, protocol, request
+from gremlin_python.driver import connection, protocol, request, serializer
 from gremlin_python.process import traversal
 
 # This is until concurrent.futures backport 3.1.0 release
@@ -44,6 +44,8 @@ class Client:
                  message_serializer=None, username="", password=""):
         self._url = url
         self._traversal_source = traversal_source
+        if message_serializer is None:
+            message_serializer = serializer.GraphSONMessageSerializer()
         self._message_serializer = message_serializer
         self._username = username
         self._password = password
@@ -59,7 +61,7 @@ class Client:
         self._transport_factory = transport_factory
         if protocol_factory is None:
             protocol_factory = lambda: protocol.GremlinServerWSProtocol(
-                message_serializer=self._message_serializer,
+                self._message_serializer,
                 username=self._username,
                 password=self._password)
         self._protocol_factory = protocol_factory

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e3067e93/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
index fb0e4ba..1f08e2b 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
@@ -18,7 +18,7 @@ under the License.
 """
 from concurrent.futures import Future
 
-from gremlin_python.driver import client
+from gremlin_python.driver import client, serializer
 from gremlin_python.driver.remote_connection import (
     RemoteConnection, RemoteTraversal, RemoteTraversalSideEffects)
 
@@ -29,10 +29,20 @@ class DriverRemoteConnection(RemoteConnection):
 
     def __init__(self, url, traversal_source, protocol_factory=None,
                  transport_factory=None, pool_size=None, max_workers=None,
-                 username="", password=""):
-        self._client = client.Client(url, traversal_source, protocol_factory,
-                                     transport_factory, pool_size, max_workers,
-                                     None, username, password)
+                 username="", password="", message_serializer=None,
+                 graphson_reader=None, graphson_writer=None):
+        if message_serializer is None:
+            message_serializer = serializer.GraphSONMessageSerializer(
+                reader=graphson_reader,
+                writer=graphson_writer)
+        self._client = client.Client(url, traversal_source,
+                                     protocol_factory=protocol_factory,
+                                     transport_factory=transport_factory,
+                                     pool_size=pool_size,
+                                     max_workers=max_workers,
+                                     message_serializer=message_serializer,
+                                     username=username,
+                                     password=password)
         self._url = self._client._url
         self._traversal_source = self._client._traversal_source
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e3067e93/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
index 279a8f5..33b4419 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/protocol.py
@@ -19,10 +19,13 @@ under the License.
 import abc
 import base64
 import collections
-import json
 import uuid
 
 import six
+try:
+    import ujson as json
+except ImportError:
+    import json
 
 from gremlin_python.driver import serializer, request
 
@@ -51,9 +54,7 @@ class AbstractBaseProtocol:
 
 class GremlinServerWSProtocol(AbstractBaseProtocol):
 
-    def __init__(self, message_serializer=None, username='', password=''):
-        if message_serializer is None:
-            message_serializer = serializer.GraphSONMessageSerializer()
+    def __init__(self, message_serializer, username='', password=''):
         self._message_serializer = message_serializer
         self._username = username
         self._password = password

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e3067e93/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py b/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
index 2db7374..a29d4dc 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/serializer.py
@@ -29,72 +29,74 @@ __author__ = 'David M. Brown (davebshow@gmail.com)'
 class Processor:
     """Base class for OpProcessor serialization system."""
 
-    _graphson_writer = graphson.GraphSONWriter()
-
-    def __init__(self, default_args):
-        self._default_args = default_args
+    def __init__(self, writer):
+        self._graphson_writer = writer
 
     def get_op_args(self, op, args):
         op_method = getattr(self, op, None)
         if not op_method:
             raise Exception("Processor does not support op: {}".format(op))
-        args_ = self._default_args.get(op, dict()).copy()
-        args_.update(args)
-        return op_method(args_)
-
+        return op_method(args)
 
-class GraphSONMessageSerializer:
-    """Message serializer for GraphSON"""
 
-    _graphson_reader = graphson.GraphSONReader()
+class Standard(Processor):
 
+    def authentication(self, args):
+        return args
 
-    class standard(Processor):
+    def eval(self, args):
+        return args
 
-        def authentication(self, args):
-            return args
 
-        def eval(self, args):
-            return args
+class Traversal(Processor):
 
+    def authentication(self, args):
+        return args
 
-    class traversal(Processor):
+    def bytecode(self, args):
+        gremlin = args['gremlin']
+        args['gremlin'] = self._graphson_writer.toDict(gremlin)
+        aliases = args.get('aliases', '')
+        if not aliases:
+            aliases = {'g': 'g'}
+        args['aliases'] = aliases
+        return args
 
-        def authentication(self, args):
-            return args
+    def close(self, args):
+        return self.keys(args)
 
-        def bytecode(self, args):
-            gremlin = args['gremlin']
-            args['gremlin'] = self._graphson_writer.toDict(gremlin)
-            aliases = args.get('aliases', '')
-            if not aliases:
-                aliases = {'g': 'g'}
-            args['aliases'] = aliases
-            return args
+    def gather(self, args):
+        side_effect = args['sideEffect']
+        args['sideEffect'] = {'@type': 'g:UUID', '@value': side_effect}
+        aliases = args.get('aliases', '')
+        if not aliases:
+            aliases = {'g': 'g'}
+        args['aliases'] = aliases
+        return args
 
-        def close(self, args):
-            return self.keys(args)
+    def keys(self, args):
+        side_effect = args['sideEffect']
+        args['sideEffect'] = {'@type': 'g:UUID', '@value': side_effect}
+        return args
 
-        def gather(self, args):
-            side_effect = args['sideEffect']
-            args['sideEffect'] = {'@type': 'g:UUID', '@value': side_effect}
-            aliases = args.get('aliases', '')
-            if not aliases:
-                aliases = {'g': 'g'}
-            args['aliases'] = aliases
-            return args
 
-        def keys(self, args):
-            side_effect = args['sideEffect']
-            args['sideEffect'] = {'@type': 'g:UUID', '@value': side_effect}
-            return args
+class GraphSONMessageSerializer:
+    """Message serializer for GraphSON"""
 
+    def __init__(self, reader=None, writer=None):
+        if not reader:
+            reader = graphson.GraphSONReader()
+        self._graphson_reader = reader
+        if not writer:
+            writer = graphson.GraphSONWriter()
+        self.standard = Standard(writer)
+        self.traversal = Traversal(writer)
 
     def get_processor(self, processor):
         processor = getattr(self, processor, None)
         if not processor:
             raise Exception("Unknown processor")
-        return processor({})
+        return processor
 
     def serialize_message(self, request_id, request_message):
         processor = request_message.processor

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e3067e93/gremlin-python/src/main/jython/tests/conftest.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/conftest.py b/gremlin-python/src/main/jython/tests/conftest.py
index 3425266..2cd4282 100644
--- a/gremlin-python/src/main/jython/tests/conftest.py
+++ b/gremlin-python/src/main/jython/tests/conftest.py
@@ -26,12 +26,14 @@ from gremlin_python.driver.connection import Connection
 from gremlin_python.driver.driver_remote_connection import (
     DriverRemoteConnection)
 from gremlin_python.driver.protocol import GremlinServerWSProtocol
+from gremlin_python.driver.serializer import GraphSONMessageSerializer
 from gremlin_python.driver.tornado.transport import TornadoTransport
 
 
 @pytest.fixture
 def connection(request):
     protocol = GremlinServerWSProtocol(
+        GraphSONMessageSerializer(),
         username='stephen', password='password')
     executor = concurrent.futures.ThreadPoolExecutor(5)
     pool = queue.Queue()


[14/21] tinkerpop git commit: fixtures should test for subclasses of OSError (ConnectionError, ConnectionRefusedError etc.)

Posted by da...@apache.org.
fixtures should test for subclasses of OSError (ConnectionError, ConnectionRefusedError etc.)


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

Branch: refs/heads/TINKERPOP-1599
Commit: 949ed56ee91e1fd6af38ea45f9702f6fb8883ad2
Parents: b5069ff
Author: davebshow <da...@gmail.com>
Authored: Tue Jan 31 10:43:59 2017 -0500
Committer: davebshow <da...@gmail.com>
Committed: Fri Feb 17 11:36:57 2017 -0500

----------------------------------------------------------------------
 gremlin-python/src/main/jython/tests/conftest.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/949ed56e/gremlin-python/src/main/jython/tests/conftest.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/conftest.py b/gremlin-python/src/main/jython/tests/conftest.py
index 49779ac..3425266 100644
--- a/gremlin-python/src/main/jython/tests/conftest.py
+++ b/gremlin-python/src/main/jython/tests/conftest.py
@@ -38,7 +38,7 @@ def connection(request):
     try:
         conn = Connection('ws://localhost:45940/gremlin', 'g', protocol,
                           lambda: TornadoTransport(), executor, pool)
-    except:
+    except OSError:
         executor.shutdown()
         pytest.skip('Gremlin Server is not running')
     else:
@@ -52,7 +52,7 @@ def connection(request):
 def client(request):
     try:
         client = Client('ws://localhost:45940/gremlin', 'g')
-    except:
+    except OSError:
         pytest.skip('Gremlin Server is not running')
     else:
         def fin():
@@ -64,7 +64,7 @@ def client(request):
 def remote_connection(request):
     try:
         remote_conn = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
-    except:
+    except OSError:
         pytest.skip('Gremlin Server is not running')
     else:
         def fin():


[02/21] tinkerpop git commit: moved the bulking logic for GremlinServer into TraverserIterator. Basically, at the point of returning traversers over the network, try and bulk as many as you can to reduce traffic.

Posted by da...@apache.org.
moved the bulking logic for GremlinServer into TraverserIterator. Basically, at the point of returning traversers over the network, try and bulk as many as you can to reduce traffic.


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

Branch: refs/heads/TINKERPOP-1599
Commit: b635c801d07aca4d9b62e962f5bf9b2326b732cf
Parents: 080306b
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Feb 16 08:35:51 2017 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Feb 16 08:35:51 2017 -0700

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  2 +-
 .../strategy/decoration/RemoteStrategy.java     |  7 -------
 .../gremlin/server/util/TraverserIterator.java  | 21 +++++++++++++++++---
 3 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b635c801/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index cf7312e..30fb41e 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -27,7 +27,7 @@ TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 * Fixed an optimization bug in `LazyBarrierStrategy` around appending barriers to the end of a `Traversal`.
-* `RemoteStrategy` is smart to try and append a `NoOpBarrierStep` in order to bulk traversers prior to network I/O.
+* `TraverserIterator` in GremlinServer is smart to try and bulk traversers prior to network I/O.
 
 [[release-3-2-4]]
 TinkerPop 3.2.4 (Release Date: February 8, 2017)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b635c801/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/decoration/RemoteStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/decoration/RemoteStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/decoration/RemoteStrategy.java
index 14d3b36..d1b14d5 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/decoration/RemoteStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/decoration/RemoteStrategy.java
@@ -24,8 +24,6 @@ import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
 import org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
@@ -49,7 +47,6 @@ public final class RemoteStrategy extends AbstractTraversalStrategy<TraversalStr
         implements TraversalStrategy.DecorationStrategy {
 
     private static final RemoteStrategy INSTANCE = new RemoteStrategy();
-    protected static final int MAX_BARRIER_SIZE = 1000;
     private final Optional<RemoteConnection> remoteConnection;
 
     private static final Set<Class<? extends DecorationStrategy>> POSTS = Collections.singleton(VertexProgramStrategy.class);
@@ -92,10 +89,6 @@ public final class RemoteStrategy extends AbstractTraversalStrategy<TraversalStr
         if (!(traversal.getParent() instanceof EmptyStep))
             return;
 
-        // given that we send traversers over the wire, try our best to bulk to limit network traffic
-        if (!(traversal.getEndStep() instanceof Barrier))
-            traversal.addStep(new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE));
-
         // verifications to ensure unsupported steps do not exist in the traversal
         if (Boolean.valueOf(System.getProperty("is.testing", "false")) &&
                 (TraversalHelper.hasStepOfAssignableClassRecursively(ProfileSideEffectStep.class, traversal) ||

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b635c801/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TraverserIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TraverserIterator.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TraverserIterator.java
index d4bf5c0..8ea6e55 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TraverserIterator.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TraverserIterator.java
@@ -22,6 +22,8 @@ import org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraver
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.HaltedTraverserStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.TraverserSet;
 
 import java.util.Iterator;
 
@@ -32,9 +34,12 @@ public class TraverserIterator implements Iterator<Object> {
 
     private final Traversal.Admin traversal;
     private final HaltedTraverserStrategy haltedTraverserStrategy;
+    private final TraverserSet bulker = new TraverserSet();
+    private final int barrierSize;
 
     public TraverserIterator(final Traversal.Admin traversal) {
         this.traversal = traversal;
+        this.barrierSize = traversal.getTraverserRequirements().contains(TraverserRequirement.ONE_BULK) ? 1 : 1000;
         this.haltedTraverserStrategy = traversal.getStrategies().getStrategy(HaltedTraverserStrategy.class).orElse(
                 Boolean.valueOf(System.getProperty("is.testing", "false")) ?
                         HaltedTraverserStrategy.detached() :
@@ -42,17 +47,27 @@ public class TraverserIterator implements Iterator<Object> {
     }
 
     public Traversal.Admin getTraversal() {
-        return traversal;
+        return this.traversal;
     }
 
     @Override
     public boolean hasNext() {
-        return this.traversal.hasNext();
+        if (this.bulker.isEmpty())
+            this.fillBulker();
+        return !this.bulker.isEmpty();
     }
 
     @Override
     public Object next() {
-        final Traverser.Admin t = this.haltedTraverserStrategy.halt(traversal.nextTraverser());
+        if (this.bulker.isEmpty())
+            this.fillBulker();
+        final Traverser.Admin t = this.haltedTraverserStrategy.halt(this.bulker.remove());
         return new DefaultRemoteTraverser<>(t.get(), t.bulk());
     }
+
+    private final void fillBulker() {
+        while (this.traversal.hasNext() && this.bulker.size() < this.barrierSize) {
+            this.bulker.add(this.traversal.nextTraverser());
+        }
+    }
 }
\ No newline at end of file