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 2018/07/19 18:24:39 UTC

[2/2] tinkerpop git commit: TINKERPOP-1996 Added iterate() to read()/write() steps in docs

TINKERPOP-1996 Added iterate() to read()/write() steps in docs


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

Branch: refs/heads/TINKERPOP-1996
Commit: ae3b149789b8a9779d0549cee8a6ca2e2febbd2b
Parents: a580b6f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jul 19 14:24:15 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 14:24:15 2018 -0400

----------------------------------------------------------------------
 docs/src/recipes/centrality.asciidoc            |  2 +-
 .../reference/implementations-neo4j.asciidoc    |  4 +--
 .../implementations-tinkergraph.asciidoc        |  8 ++---
 docs/src/reference/the-traversal.asciidoc       | 35 +++++++++++---------
 4 files changed, 26 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae3b1497/docs/src/recipes/centrality.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/recipes/centrality.asciidoc b/docs/src/recipes/centrality.asciidoc
index 0c1d4bc..59e6a4d 100644
--- a/docs/src/recipes/centrality.asciidoc
+++ b/docs/src/recipes/centrality.asciidoc
@@ -156,7 +156,7 @@ give it the highest rank. Consider the following example using the Grateful Dead
 
 [gremlin-groovy]
 ----
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g.V().repeat(groupCount('m').by('name').out()).times(5).cap('m').                <1>
   order(local).by(values, desc).limit(local, 10).next()                          <2>
 g.V().repeat(groupCount('m').by('name').out().timeLimit(100)).times(5).cap('m'). <3>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae3b1497/docs/src/reference/implementations-neo4j.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/implementations-neo4j.asciidoc b/docs/src/reference/implementations-neo4j.asciidoc
index 1760bd6..cfbf612 100644
--- a/docs/src/reference/implementations-neo4j.asciidoc
+++ b/docs/src/reference/implementations-neo4j.asciidoc
@@ -94,7 +94,7 @@ labels), a linear scan of the vertex-label partition is still faster than a line
 ----
 graph = Neo4jGraph.open('/tmp/neo4j')
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g.tx().commit()
 clock(1000) {g.V().hasLabel('artist').has('name','Garcia').iterate()}  <1>
 graph.cypher("CREATE INDEX ON :artist(name)") <2>
@@ -162,7 +162,7 @@ It is possible to leverage Cypher from within Gremlin by using the `Neo4jGraph.c
 ----
 graph = Neo4jGraph.open('/tmp/neo4j')
 g = graph.traversal()
-g.io('data/tinkerpop-modern.kryo').read()
+g.io('data/tinkerpop-modern.kryo').read().iterate()
 graph.cypher('MATCH (a {name:"marko"}) RETURN a')
 graph.cypher('MATCH (a {name:"marko"}) RETURN a').select('a').out('knows').values('name')
 graph.close()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae3b1497/docs/src/reference/implementations-tinkergraph.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/implementations-tinkergraph.asciidoc b/docs/src/reference/implementations-tinkergraph.asciidoc
index acd37dd..fe14d0f 100644
--- a/docs/src/reference/implementations-tinkergraph.asciidoc
+++ b/docs/src/reference/implementations-tinkergraph.asciidoc
@@ -90,12 +90,12 @@ TinkerGraph over the Grateful Dead graph.
 ----
 graph = TinkerGraph.open()
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 clock(1000) {g.V().has('name','Garcia').iterate()} <1>
 graph = TinkerGraph.open()
 g = graph.traversal()
 graph.createIndex('name',Vertex.class)
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 clock(1000){g.V().has('name','Garcia').iterate()} <2>
 ----
 
@@ -159,12 +159,12 @@ cardinality to `list` or else the data will import as `single`.  Consider the fo
 ----
 graph = TinkerGraph.open()
 g = graph.traversal()
-g.io("data/tinkerpop-crew.kryo").read()
+g.io("data/tinkerpop-crew.kryo").read().iterate()
 g.V().properties()
 conf = new BaseConfiguration()
 conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality","list")
 graph = TinkerGraph.open(conf)
 g = graph.traversal()
-g.io("data/tinkerpop-crew.kryo").read()
+g.io("data/tinkerpop-crew.kryo").read().iterate()
 g.V().properties()
 ----

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae3b1497/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index cca71f6..cd2f5f2 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -401,7 +401,7 @@ made more salient on a larger graph. Therefore, the example below leverages the
 ----
 graph = TinkerGraph.open()
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g = graph.traversal().withoutStrategies(LazyBarrierStrategy) <1>
 clockWithResult(1){g.V().both().both().both().count().next()} <2>
 clockWithResult(1){g.V().repeat(both()).times(3).count().next()} <3>
@@ -424,7 +424,7 @@ optimization scenario with the added benefit of reducing the risk of an out-of-m
 ----
 graph = TinkerGraph.open()
 g = graph.traversal()  <1>
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 clockWithResult(1){g.V().both().both().both().count().next()}
 g.V().both().both().both().count().iterate().toString()  <2>
 ----
@@ -1066,10 +1066,13 @@ execute. Therefore, a typical usage of the `io()` step would look like this:
 
 [source,java]
 ----
-g.io(someInputFile).read()
-g.io(someOutputFile).write()
+g.io(someInputFile).read().iterate()
+g.io(someOutputFile).write().iterate()
 ----
 
+IMPORTANT: The commands above are still traversals and therefore require iteration to be executed, hence the use of
+`iterate()` as a termination step.
+
 By default, the `io()` step will try to detect the right file format using the file name extension. To gain greater
 control of the format use the `with()` step modulator to provide further information to `io()`. For example:
 
@@ -1077,13 +1080,13 @@ control of the format use the `with()` step modulator to provide further informa
 ----
 g.io(someInputFile).
     with(IO.reader, IO.graphson).
-  read()
+  read().iterate()
 g.io(someOutputFile).
     with(IO.writer,IO.graphml).
-  write()
+  write().iterate()
 ----
 
-The `IO` class is a helper that for the `io()` step that provides expressions that can be used to help configure it
+The `IO` class is a helper for the `io()` step that provides expressions that can be used to help configure it
 and in this case it allows direct specification of the "reader" or "writer" to use. The "reader" actually refers to
 a `GraphReader` implementation and the `writer" refers to a `GraphWriter` implementation. The implementations of
 those interfaces provided by default are the standard TinkerPop implementations.
@@ -1136,8 +1139,8 @@ GraphML to appear before all `<edge>` elements if vertex labels are important to
 
 [source,java]
 ----
-g.io("graph.xml").read()
-g.io("graph.xml").write()
+g.io("graph.xml").read().iterate()
+g.io("graph.xml").write().iterate()
 ----
 
 NOTE: If using GraphML generated from TinkerPop 2.x, read more about its incompatibilities in the
@@ -1157,8 +1160,8 @@ but it is generally best used in two cases:
 
 [source,java]
 ----
-g.io("graph.json").read()
-g.io("graph.json").write()
+g.io("graph.json").read().iterate()
+g.io("graph.json").write().iterate()
 ----
 
 NOTE: Additional documentation for GraphSON can be found in the link:http://tinkerpop.apache.org/docs/x.y.z/dev/io/#graphson[IO Reference].
@@ -1182,8 +1185,8 @@ other.  Failure to do so, may result in errors.
 
 [source,java]
 ----
-g.io("graph.kryo").read()
-g.io("graph.kryo").write()
+g.io("graph.kryo").read().iterate()
+g.io("graph.kryo").write().iterate()
 ----
 
 *Additional References*
@@ -1403,7 +1406,7 @@ songs which Jerry Garcia has both sung and written (using the Grateful Dead grap
 [gremlin-groovy]
 ----
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g.V().match(
         __.as('a').has('name', 'Garcia'),
         __.as('a').in('writtenBy').as('b'),
@@ -2495,7 +2498,7 @@ ranking.
 [gremlin-groovy]
 ----
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g.V().hasLabel('song').out('followedBy').groupCount().by('name').
       order(local).by(values,desc).limit(local, 5)
 g.V().hasLabel('song').out('followedBy').groupCount().by('name').
@@ -2509,7 +2512,7 @@ Similarly, for extracting the values from a path or map.
 [gremlin-groovy]
 ----
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g.V().hasLabel('song').out('sungBy').groupCount().by('name') <1>
 g.V().hasLabel('song').out('sungBy').groupCount().by('name').select(values) <2>
 g.V().hasLabel('song').out('sungBy').groupCount().by('name').select(values).unfold().