You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2015/06/03 02:12:54 UTC
[49/50] [abbrv] incubator-tinkerpop git commit: added dynamic code
sample for Neo4j
added dynamic code sample for Neo4j
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/62e4a1bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/62e4a1bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/62e4a1bd
Branch: refs/heads/preprocessor
Commit: 62e4a1bd5a4eb4a2d1fc885463939e077a2f6687
Parents: 1a60158
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Wed Jun 3 01:51:53 2015 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Wed Jun 3 01:51:53 2015 +0200
----------------------------------------------------------------------
docs/src/implementations.asciidoc | 38 ++++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/62e4a1bd/docs/src/implementations.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/implementations.asciidoc b/docs/src/implementations.asciidoc
index 2b01353..5c120d1 100644
--- a/docs/src/implementations.asciidoc
+++ b/docs/src/implementations.asciidoc
@@ -589,6 +589,20 @@ gremlin> g = graph.traversal(standard())
gremlin> g.V().hasLabel('person').has('name','marko').values('name')
==>marko
+[gremlin-groovy]
+----
+graph = Neo4jGraph.open('/tmp/neo4j')
+graph.cypher("CREATE INDEX ON :person(name)")
+graph.tx().commit() <1>
+graph.addVertex(label,'person','name','marko')
+graph.addVertex(label,'dog','name','puppy')
+g = graph.traversal(standard())
+g.V().hasLabel('person').has('name','marko').values('name')
+graph.close()
+----
+
+<1> schema mutations must happen in a different tx than graph mutations
+
Below demonstrates the runtime benefits of indices and demonstrates how if there is no defined index (only vertex labels), a linear scan of the vertex-label partition is still faster than a linear scan of all vertices.
[source,groovy]
@@ -613,6 +627,22 @@ gremlin> clock(1000){g.V().hasLabel('artist').has('name','Garcia').next()} <5>
gremlin> clock(1000){g.V().has('name','Garcia').next()} <6>
==>0.6293959999999993
+[gremlin-groovy]
+----
+graph = Neo4jGraph.open('/tmp/neo4j')
+graph.cypher("CREATE INDEX ON :artist(name)") <1>
+graph.tx().commit()
+graph.io(graphml()).readGraph('data/grateful-dead.xml')
+g = graph.traversal(standard())
+clock(1000) {g.V().hasLabel('artist').has('name','Garcia').next()} <2>
+clock(1000) {g.V().has('name','Garcia').next()} <3>
+graph.cypher("DROP INDEX ON :artist(name)") <4>
+g.tx().commit()
+clock(1000) {g.V().hasLabel('artist').has('name','Garcia').next()} <5>
+clock(1000) {g.V().has('name','Garcia').next()} <6>
+graph.close()
+----
+
<1> Create an index for all artist vertices on their name property.
<2> Find all artists whose name is Garcia which uses the pre-defined schema index.
<3> Find all vertices whose name is Garcia which requires a linear scan of all the data in the graph.
@@ -731,7 +761,7 @@ gremlin>
Properties Files
~~~~~~~~~~~~~~~~
-`HadoopGraph` makes heavy use of properties files which ultimately get turned into Apache configurations and Hadoop configurations. The example properties file presented below is located at `conf/hadoop-gryo.properties`.
+`HadoopGraph` makes heavy use of properties files which ultimately get turned into Apache configurations and Hadoop configurations. The example properties file presented below is located at `conf/hadoop/hadoop-gryo.properties`.
[source,text]
gremlin.graph=org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph
@@ -807,7 +837,7 @@ gremlin> g.V().group().by{it.value('name')[1]}.by('name').next()
----
hdfs.copyFromLocal('data/tinkerpop-modern.kryo', 'tinkerpop-modern.kryo')
hdfs.ls()
-graph = GraphFactory.open('conf/hadoop-gryo.properties')
+graph = GraphFactory.open('conf/hadoop/hadoop-gryo.properties')
g = graph.traversal(standard())
g.V().count()
g.V().out().out().values('name')
@@ -871,7 +901,7 @@ INFO org.apache.hadoop.mapred.JobClient - map 0% reduce 0%
[gremlin-groovy]
----
-graph = GraphFactory.open('conf/hadoop-gryo.properties')
+graph = GraphFactory.open('conf/hadoop/hadoop-gryo.properties')
g = graph.traversal(computer())
g.V().count()
g.V().out().out().values('name')
@@ -924,7 +954,7 @@ gremlin> g.V().out().out().values('name')
[gremlin-groovy]
----
-graph = GraphFactory.open('conf/hadoop-gryo.properties')
+graph = GraphFactory.open('conf/hadoop/hadoop-gryo.properties')
g = graph.traversal(computer(SparkGraphComputer))
g.V().count()
g.V().out().out().values('name')