You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/04/24 00:52:29 UTC

[1/2] incubator-tinkerpop git commit: fixed a withSack() issue in Groovy. Updated the docs with the new withXXX() work.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/refactor-io 358690f7c -> cbba981fa


fixed a withSack() issue in Groovy. Updated the docs with the new withXXX() work.


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

Branch: refs/heads/refactor-io
Commit: 9b7844caeeb00afc22296e2f2132fd765409136a
Parents: e8cf4e3
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Apr 23 13:51:47 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Apr 23 13:51:47 2015 -0600

----------------------------------------------------------------------
 docs/src/the-traversal.asciidoc                 | 24 +++++++++-----------
 .../step/sideEffect/GroovySackTest.groovy       |  4 ++--
 .../gremlin/groovy/loaders/StepLoader.groovy    | 18 +++++++++++----
 3 files changed, 27 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9b7844ca/docs/src/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/the-traversal.asciidoc b/docs/src/the-traversal.asciidoc
index 6b08cf1..270d4dd 100644
--- a/docs/src/the-traversal.asciidoc
+++ b/docs/src/the-traversal.asciidoc
@@ -71,14 +71,12 @@ The `Traverser<S>` object provides access to:
 image:map-lambda.png[width=150,float=right]
 [gremlin-groovy,modern]
 ----
-g.V(1).as('a').out() <1>
-g.V(1).as('a').out().map {it.path('a')} <2>
-g.V(1).as('a').out().select('a') <3>
+g.V(1).out().values('name') <1>
+g.V(1).out().map {it.get().value('name')} <2>
 ----
 
-<1> A standard outgoing traversal from vertex 1.
-<2> For each vertex outgoing adjacent to vertex 1, get the vertex at `a` (which is vertex 1).
-<3> The <<select-step,`select()`>>-step is implemented as a `map()`-step that accesses data in the historic path.
+<1> An outgoing traversal from vertex 1 to the name values of the adjacent vertices.
+<2> The same operation, but using a lambda to access the name property values.
 
 image:filter-lambda.png[width=160,float=right]
 [gremlin-groovy,modern]
@@ -1068,18 +1066,18 @@ Two trivial examples are presented below to demonstrate the *initial value suppl
 
 [gremlin-groovy,modern]
 ----
-g.V().withSack(1.0f).sack()
+g.withSack(1.0f).V().sack()
 rand = new Random()
-g.V().withSack {rand.nextFloat()}.sack()
+g.withSack {rand.nextFloat()}.V().sack()
 ----
 
 A more complicated initial value supplier example is presented below where the sack values are used in a running computation and then emitted at the end of the traversal. When an edge is traversed, the edge weight is multiplied by the sack value (`sack(mult,'weight')`).
 
 [gremlin-groovy,modern]
 ----
-g.V().withSack(1.0f).repeat(outE().sack(mult,'weight').inV()).times(2)
-g.V().withSack(1.0f).repeat(outE().sack(mult,'weight').inV()).times(2).sack()
-g.V().withSack(1.0f).repeat(outE().sack(mult,'weight').inV()).times(2).path().
+g.withSack(1.0f).V().repeat(outE().sack(mult,'weight').inV()).times(2)
+g.withSack(1.0f).V().repeat(outE().sack(mult,'weight').inV()).times(2).sack()
+g.withSack(1.0f).V().repeat(outE().sack(mult,'weight').inV()).times(2).path().
       by().by('weight')
 ----
 
@@ -1087,9 +1085,9 @@ image:gremlin-sacks-standing.png[width=100,float=left] When complex objects are
 
 [gremlin-groovy,modern]
 ----
-g.V().withSack {[:]}.out().out().
+g.withSack {[:]}.V().out().out().
       sack {m,v -> m[v.value('name')] = v.value('lang'); m}.sack() // BAD: single map
-g.V().withSack {[:]} {m -> m.clone()}.out().out().
+g.withSack {[:]}{it.clone()}.V().out().out().
       sack {m,v -> m[v.value('name')] = v.value('lang'); m}.sack() // GOOD: cloned map
 ----
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9b7844ca/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
index 10681b7..21929a0 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
@@ -47,7 +47,7 @@ public abstract class GroovySackTest {
 
         @Override
         public Traversal<Vertex, Map> get_g_withSackXmap__map_cloneX_V_out_out_sackXmap_a_nameX_sack() {
-            g.withSack([:]) { m -> m.clone() }.V.out().out().sack { m, v -> m['a'] = v.name; m }.sack()
+            g.withSack { [:] } { it.clone() }.V.out().out().sack { m, v -> m['a'] = v.name; m }.sack()
         }
     }
 
@@ -66,7 +66,7 @@ public abstract class GroovySackTest {
 
         @Override
         public Traversal<Vertex, Map> get_g_withSackXmap__map_cloneX_V_out_out_sackXmap_a_nameX_sack() {
-            ComputerTestHelper.compute("g.withSack ([:]) { m -> m.clone() }.V.out().out().sack { m, v -> m['a'] = v.name; m }.sack()", g);
+            ComputerTestHelper.compute("g.withSack{[:]}{ it.clone() }.V.out().out().sack { m, v -> m['a'] = v.name; m }.sack()", g);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9b7844ca/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
index 580c87d..52a7089 100644
--- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
+++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
@@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.groovy.function.GFunction
 import org.apache.tinkerpop.gremlin.groovy.function.GSupplier
 import org.apache.tinkerpop.gremlin.groovy.function.GUnaryOperator
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -44,12 +45,21 @@ class StepLoader {
             return ((GraphTraversal) delegate).by(1 == closure.getMaximumNumberOfParameters() ? new GFunction(closure) : new GComparator(closure));
         }
 
-        GraphTraversal.metaClass.withSack = { final Closure closure ->
-            return ((GraphTraversal) delegate).withSack(new GSupplier(closure));
+        GraphTraversalSource.metaClass.withSack = { final Closure closure ->
+            return ((GraphTraversalSource) delegate).withSack(new GSupplier(closure));
         }
 
-        GraphTraversal.metaClass.withSack = { final Closure closure, final Closure operator ->
-            return ((GraphTraversal) delegate).withSack(new GSupplier(closure), new GUnaryOperator(operator));
+        GraphTraversalSource.metaClass.withSack = { final Closure closure, final Closure operator ->
+            return ((GraphTraversalSource) delegate).withSack(new GSupplier(closure), new GUnaryOperator(operator));
+        }
+
+        GraphTraversalSource.GraphTraversalSourceStub.metaClass.withSack = { final Closure closure ->
+            return ((GraphTraversalSource.GraphTraversalSourceStub) delegate).withSack(new GSupplier(closure));
+        }
+
+        GraphTraversalSource.GraphTraversalSourceStub.metaClass.withSack = {
+            final Closure closure, final Closure operator ->
+                return ((GraphTraversalSource.GraphTraversalSourceStub) delegate).withSack(new GSupplier(closure), new GUnaryOperator(operator));
         }
     }
 }


[2/2] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/master' into refactor-io

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


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

Branch: refs/heads/refactor-io
Commit: cbba981fa818126c72202a8deb86555e41b42bf3
Parents: 358690f 9b7844c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 23 18:52:17 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Apr 23 18:52:17 2015 -0400

----------------------------------------------------------------------
 docs/src/the-traversal.asciidoc                 | 24 +++++++++-----------
 .../step/sideEffect/GroovySackTest.groovy       |  4 ++--
 .../gremlin/groovy/loaders/StepLoader.groovy    | 18 +++++++++++----
 3 files changed, 27 insertions(+), 19 deletions(-)
----------------------------------------------------------------------