TINKERPOP-1968 Added edge ids to sink and grateful generator Edge ids should have always been statically defined - not sure how/why that was missed. Also added grateful dead dataset to TinkerFactory to make that easier to programmatically setup.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/68bdaed4 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/68bdaed4 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/68bdaed4 Branch: refs/heads/master Commit: 68bdaed44f120f30857930f927e5faf99379b83c Parents: f411f1d Author: Stephen Mallette <sp...@genoprime.com> Authored: Fri May 18 14:34:44 2018 -0400 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Thu May 31 16:18:08 2018 -0400 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + data/tinkerpop-sink-typed.json | 6 +- data/tinkerpop-sink-v2d0-typed.json | 6 +- data/tinkerpop-sink-v2d0.json | 6 +- data/tinkerpop-sink.json | 6 +- data/tinkerpop-sink.kryo | Bin 234 -> 240 bytes .../io/graphson/tinkerpop-sink-typed.json | 6 +- .../io/graphson/tinkerpop-sink-v2d0-typed.json | 6 +- .../io/graphson/tinkerpop-sink-v2d0.json | 6 +- .../structure/io/graphson/tinkerpop-sink.json | 6 +- .../structure/io/gryo/tinkerpop-sink.kryo | Bin 234 -> 240 bytes .../tinkergraph/structure/TinkerFactory.java | 82 ++++++++++++++++++- 12 files changed, 104 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 6251b6d..6a06a1a 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima * Fixed bug in `branch()` where reducing steps as options would produce incorrect results. * Removed recursive handling of streaming results from Gremlin-Python driver to avoid max recursion depth errors. * Improved performance of `TraversalVertexProgram` and related infrastructure. +* Added `createGratefulDead()`to `TinkerFactory` to help make it easier to try to instantiate that toy graph. * Fixed bug in `GroovyTranslator` that didn't properly handle empty `Map` objects. * Added concrete configuration methods to `SparkGraphComputer` to make a more clear API for configuring it. * Fixed a bug in `TinkerGraphCountStrategy`, which didn't consider that certain map steps may not emit an element. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/data/tinkerpop-sink-typed.json ---------------------------------------------------------------------- diff --git a/data/tinkerpop-sink-typed.json b/data/tinkerpop-sink-typed.json index 2e83384..9f16788 100644 --- a/data/tinkerpop-sink-typed.json +++ b/data/tinkerpop-sink-typed.json @@ -1,3 +1,3 @@ -{"@class":"java.util.HashMap","id":2000,"label":"message","inE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":5,"outV":2000}]]},"outE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":4,"inV":2001},{"@class":"java.util.HashMap","id":5,"inV":2000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",2],"value":"a"}]]}} -{"@class":"java.util.HashMap","id":2001,"label":"message","inE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":4,"outV":2000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",3],"value":"b"}]]}} -{"@class":"java.util.HashMap","id":1000,"label":"loops","inE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":1,"outV":1000}]]},"outE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":1,"inV":1000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",0],"value":"loop"}]]}} +{"@class":"java.util.HashMap","id":2000,"label":"message","inE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":2003,"outV":2000}]]},"outE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":2002,"inV":2001},{"@class":"java.util.HashMap","id":2003,"inV":2000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",1],"value":"a"}]]}} +{"@class":"java.util.HashMap","id":2001,"label":"message","inE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":2002,"outV":2000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",2],"value":"b"}]]}} +{"@class":"java.util.HashMap","id":1000,"label":"loops","inE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":1001,"outV":1000}]]},"outE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":1001,"inV":1000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",0],"value":"loop"}]]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/data/tinkerpop-sink-v2d0-typed.json ---------------------------------------------------------------------- diff --git a/data/tinkerpop-sink-v2d0-typed.json b/data/tinkerpop-sink-v2d0-typed.json index 7a27853..906d74a 100644 --- a/data/tinkerpop-sink-v2d0-typed.json +++ b/data/tinkerpop-sink-v2d0-typed.json @@ -1,3 +1,3 @@ -{"id":{"@type":"g:Int32","@value":2000},"label":"message","inE":{"link":[{"id":{"@type":"g:Int32","@value":5},"outV":{"@type":"g:Int32","@value":2000}}]},"outE":{"link":[{"id":{"@type":"g:Int32","@value":4},"inV":{"@type":"g:Int32","@value":2001}},{"id":{"@type":"g:Int32","@value":5},"inV":{"@type":"g:Int32","@value":2000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":2},"value":"a"}]}} -{"id":{"@type":"g:Int32","@value":2001},"label":"message","inE":{"link":[{"id":{"@type":"g:Int32","@value":4},"outV":{"@type":"g:Int32","@value":2000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":3},"value":"b"}]}} -{"id":{"@type":"g:Int32","@value":1000},"label":"loops","inE":{"self":[{"id":{"@type":"g:Int32","@value":1},"outV":{"@type":"g:Int32","@value":1000}}]},"outE":{"self":[{"id":{"@type":"g:Int32","@value":1},"inV":{"@type":"g:Int32","@value":1000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"loop"}]}} +{"id":{"@type":"g:Int32","@value":2000},"label":"message","inE":{"link":[{"id":{"@type":"g:Int32","@value":2003},"outV":{"@type":"g:Int32","@value":2000}}]},"outE":{"link":[{"id":{"@type":"g:Int32","@value":2002},"inV":{"@type":"g:Int32","@value":2001}},{"id":{"@type":"g:Int32","@value":2003},"inV":{"@type":"g:Int32","@value":2000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":1},"value":"a"}]}} +{"id":{"@type":"g:Int32","@value":2001},"label":"message","inE":{"link":[{"id":{"@type":"g:Int32","@value":2002},"outV":{"@type":"g:Int32","@value":2000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":2},"value":"b"}]}} +{"id":{"@type":"g:Int32","@value":1000},"label":"loops","inE":{"self":[{"id":{"@type":"g:Int32","@value":1001},"outV":{"@type":"g:Int32","@value":1000}}]},"outE":{"self":[{"id":{"@type":"g:Int32","@value":1001},"inV":{"@type":"g:Int32","@value":1000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/data/tinkerpop-sink-v2d0.json ---------------------------------------------------------------------- diff --git a/data/tinkerpop-sink-v2d0.json b/data/tinkerpop-sink-v2d0.json index 420e089..4d4811f 100644 --- a/data/tinkerpop-sink-v2d0.json +++ b/data/tinkerpop-sink-v2d0.json @@ -1,3 +1,3 @@ -{"id":2000,"label":"message","inE":{"link":[{"id":5,"outV":2000}]},"outE":{"link":[{"id":4,"inV":2001},{"id":5,"inV":2000}]},"properties":{"name":[{"id":2,"value":"a"}]}} -{"id":2001,"label":"message","inE":{"link":[{"id":4,"outV":2000}]},"properties":{"name":[{"id":3,"value":"b"}]}} -{"id":1000,"label":"loops","inE":{"self":[{"id":1,"outV":1000}]},"outE":{"self":[{"id":1,"inV":1000}]},"properties":{"name":[{"id":0,"value":"loop"}]}} +{"id":2000,"label":"message","inE":{"link":[{"id":2003,"outV":2000}]},"outE":{"link":[{"id":2002,"inV":2001},{"id":2003,"inV":2000}]},"properties":{"name":[{"id":1,"value":"a"}]}} +{"id":2001,"label":"message","inE":{"link":[{"id":2002,"outV":2000}]},"properties":{"name":[{"id":2,"value":"b"}]}} +{"id":1000,"label":"loops","inE":{"self":[{"id":1001,"outV":1000}]},"outE":{"self":[{"id":1001,"inV":1000}]},"properties":{"name":[{"id":0,"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/data/tinkerpop-sink.json ---------------------------------------------------------------------- diff --git a/data/tinkerpop-sink.json b/data/tinkerpop-sink.json index 420e089..4d4811f 100644 --- a/data/tinkerpop-sink.json +++ b/data/tinkerpop-sink.json @@ -1,3 +1,3 @@ -{"id":2000,"label":"message","inE":{"link":[{"id":5,"outV":2000}]},"outE":{"link":[{"id":4,"inV":2001},{"id":5,"inV":2000}]},"properties":{"name":[{"id":2,"value":"a"}]}} -{"id":2001,"label":"message","inE":{"link":[{"id":4,"outV":2000}]},"properties":{"name":[{"id":3,"value":"b"}]}} -{"id":1000,"label":"loops","inE":{"self":[{"id":1,"outV":1000}]},"outE":{"self":[{"id":1,"inV":1000}]},"properties":{"name":[{"id":0,"value":"loop"}]}} +{"id":2000,"label":"message","inE":{"link":[{"id":2003,"outV":2000}]},"outE":{"link":[{"id":2002,"inV":2001},{"id":2003,"inV":2000}]},"properties":{"name":[{"id":1,"value":"a"}]}} +{"id":2001,"label":"message","inE":{"link":[{"id":2002,"outV":2000}]},"properties":{"name":[{"id":2,"value":"b"}]}} +{"id":1000,"label":"loops","inE":{"self":[{"id":1001,"outV":1000}]},"outE":{"self":[{"id":1001,"inV":1000}]},"properties":{"name":[{"id":0,"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/data/tinkerpop-sink.kryo ---------------------------------------------------------------------- diff --git a/data/tinkerpop-sink.kryo b/data/tinkerpop-sink.kryo index ae68674..8db5f4f 100644 Binary files a/data/tinkerpop-sink.kryo and b/data/tinkerpop-sink.kryo differ http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed.json ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed.json b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed.json index 2e83384..9f16788 100644 --- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed.json +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed.json @@ -1,3 +1,3 @@ -{"@class":"java.util.HashMap","id":2000,"label":"message","inE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":5,"outV":2000}]]},"outE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":4,"inV":2001},{"@class":"java.util.HashMap","id":5,"inV":2000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",2],"value":"a"}]]}} -{"@class":"java.util.HashMap","id":2001,"label":"message","inE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":4,"outV":2000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",3],"value":"b"}]]}} -{"@class":"java.util.HashMap","id":1000,"label":"loops","inE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":1,"outV":1000}]]},"outE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":1,"inV":1000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",0],"value":"loop"}]]}} +{"@class":"java.util.HashMap","id":2000,"label":"message","inE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":2003,"outV":2000}]]},"outE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":2002,"inV":2001},{"@class":"java.util.HashMap","id":2003,"inV":2000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",1],"value":"a"}]]}} +{"@class":"java.util.HashMap","id":2001,"label":"message","inE":{"@class":"java.util.HashMap","link":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":2002,"outV":2000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",2],"value":"b"}]]}} +{"@class":"java.util.HashMap","id":1000,"label":"loops","inE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":1001,"outV":1000}]]},"outE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":1001,"inV":1000}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",0],"value":"loop"}]]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0-typed.json ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0-typed.json b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0-typed.json index 7a27853..906d74a 100644 --- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0-typed.json +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0-typed.json @@ -1,3 +1,3 @@ -{"id":{"@type":"g:Int32","@value":2000},"label":"message","inE":{"link":[{"id":{"@type":"g:Int32","@value":5},"outV":{"@type":"g:Int32","@value":2000}}]},"outE":{"link":[{"id":{"@type":"g:Int32","@value":4},"inV":{"@type":"g:Int32","@value":2001}},{"id":{"@type":"g:Int32","@value":5},"inV":{"@type":"g:Int32","@value":2000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":2},"value":"a"}]}} -{"id":{"@type":"g:Int32","@value":2001},"label":"message","inE":{"link":[{"id":{"@type":"g:Int32","@value":4},"outV":{"@type":"g:Int32","@value":2000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":3},"value":"b"}]}} -{"id":{"@type":"g:Int32","@value":1000},"label":"loops","inE":{"self":[{"id":{"@type":"g:Int32","@value":1},"outV":{"@type":"g:Int32","@value":1000}}]},"outE":{"self":[{"id":{"@type":"g:Int32","@value":1},"inV":{"@type":"g:Int32","@value":1000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"loop"}]}} +{"id":{"@type":"g:Int32","@value":2000},"label":"message","inE":{"link":[{"id":{"@type":"g:Int32","@value":2003},"outV":{"@type":"g:Int32","@value":2000}}]},"outE":{"link":[{"id":{"@type":"g:Int32","@value":2002},"inV":{"@type":"g:Int32","@value":2001}},{"id":{"@type":"g:Int32","@value":2003},"inV":{"@type":"g:Int32","@value":2000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":1},"value":"a"}]}} +{"id":{"@type":"g:Int32","@value":2001},"label":"message","inE":{"link":[{"id":{"@type":"g:Int32","@value":2002},"outV":{"@type":"g:Int32","@value":2000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":2},"value":"b"}]}} +{"id":{"@type":"g:Int32","@value":1000},"label":"loops","inE":{"self":[{"id":{"@type":"g:Int32","@value":1001},"outV":{"@type":"g:Int32","@value":1000}}]},"outE":{"self":[{"id":{"@type":"g:Int32","@value":1001},"inV":{"@type":"g:Int32","@value":1000}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0.json ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0.json b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0.json index 420e089..4d4811f 100644 --- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0.json +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0.json @@ -1,3 +1,3 @@ -{"id":2000,"label":"message","inE":{"link":[{"id":5,"outV":2000}]},"outE":{"link":[{"id":4,"inV":2001},{"id":5,"inV":2000}]},"properties":{"name":[{"id":2,"value":"a"}]}} -{"id":2001,"label":"message","inE":{"link":[{"id":4,"outV":2000}]},"properties":{"name":[{"id":3,"value":"b"}]}} -{"id":1000,"label":"loops","inE":{"self":[{"id":1,"outV":1000}]},"outE":{"self":[{"id":1,"inV":1000}]},"properties":{"name":[{"id":0,"value":"loop"}]}} +{"id":2000,"label":"message","inE":{"link":[{"id":2003,"outV":2000}]},"outE":{"link":[{"id":2002,"inV":2001},{"id":2003,"inV":2000}]},"properties":{"name":[{"id":1,"value":"a"}]}} +{"id":2001,"label":"message","inE":{"link":[{"id":2002,"outV":2000}]},"properties":{"name":[{"id":2,"value":"b"}]}} +{"id":1000,"label":"loops","inE":{"self":[{"id":1001,"outV":1000}]},"outE":{"self":[{"id":1001,"inV":1000}]},"properties":{"name":[{"id":0,"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink.json ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink.json b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink.json index 420e089..4d4811f 100644 --- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink.json +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink.json @@ -1,3 +1,3 @@ -{"id":2000,"label":"message","inE":{"link":[{"id":5,"outV":2000}]},"outE":{"link":[{"id":4,"inV":2001},{"id":5,"inV":2000}]},"properties":{"name":[{"id":2,"value":"a"}]}} -{"id":2001,"label":"message","inE":{"link":[{"id":4,"outV":2000}]},"properties":{"name":[{"id":3,"value":"b"}]}} -{"id":1000,"label":"loops","inE":{"self":[{"id":1,"outV":1000}]},"outE":{"self":[{"id":1,"inV":1000}]},"properties":{"name":[{"id":0,"value":"loop"}]}} +{"id":2000,"label":"message","inE":{"link":[{"id":2003,"outV":2000}]},"outE":{"link":[{"id":2002,"inV":2001},{"id":2003,"inV":2000}]},"properties":{"name":[{"id":1,"value":"a"}]}} +{"id":2001,"label":"message","inE":{"link":[{"id":2002,"outV":2000}]},"properties":{"name":[{"id":2,"value":"b"}]}} +{"id":1000,"label":"loops","inE":{"self":[{"id":1001,"outV":1000}]},"outE":{"self":[{"id":1001,"inV":1000}]},"properties":{"name":[{"id":0,"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-sink.kryo ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-sink.kryo b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-sink.kryo index ae68674..8db5f4f 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-sink.kryo and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-sink.kryo differ http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/68bdaed4/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerFactory.java ---------------------------------------------------------------------- diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerFactory.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerFactory.java index ef1ee7f..3a47f17 100644 --- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerFactory.java +++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerFactory.java @@ -24,8 +24,18 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo; + +import java.io.File; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.apache.tinkerpop.gremlin.structure.io.IoCore.gryo; /** + * Helps create a variety of different toy graphs for testing and learning purposes. + * * @author Marko A. Rodriguez (http://markorodriguez.com) * @author Stephen Mallette (http://stephen.genoprime.com) */ @@ -33,6 +43,9 @@ public final class TinkerFactory { private TinkerFactory() {} + /** + * Create the "classic" graph which was the original toy graph from TinkerPop 2.x. + */ public static TinkerGraph createClassic() { final Configuration conf = new BaseConfiguration(); conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, TinkerGraph.DefaultIdManager.INTEGER.name()); @@ -43,6 +56,9 @@ public final class TinkerFactory { return g; } + /** + * Generate the graph in {@link #createClassic()} into an existing graph. + */ public static void generateClassic(final TinkerGraph g) { final Vertex marko = g.addVertex(T.id, 1, "name", "marko", "age", 29); final Vertex vadas = g.addVertex(T.id, 2, "name", "vadas", "age", 27); @@ -58,12 +74,19 @@ public final class TinkerFactory { peter.addEdge("created", lop, T.id, 12, "weight", 0.2f); } + /** + * Create the "modern" graph which has the same structure as the "classic" graph from TinkerPop 2.x but includes + * 3.x features like vertex labels. + */ public static TinkerGraph createModern() { final TinkerGraph g = getTinkerGraphWithNumberManager(); generateModern(g); return g; } + /** + * Generate the graph in {@link #createModern()} into an existing graph. + */ public static void generateModern(final TinkerGraph g) { final Vertex marko = g.addVertex(T.id, 1, T.label, "person", "name", "marko", "age", 29); final Vertex vadas = g.addVertex(T.id, 2, T.label, "person", "name", "vadas", "age", 27); @@ -79,6 +102,10 @@ public final class TinkerFactory { peter.addEdge("created", lop, T.id, 12, "weight", 0.2d); } + /** + * Create the "the crew" graph which is a TinkerPop 3.x toy graph showcasing many 3.x features like meta-properties, + * multi-properties and graph variables. + */ public static TinkerGraph createTheCrew() { final Configuration conf = getNumberIdManagerConfiguration(); conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name()); @@ -87,6 +114,9 @@ public final class TinkerFactory { return g; } + /** + * Generate the graph in {@link #createTheCrew()} into an existing graph. + */ public static void generateTheCrew(final TinkerGraph g) { final Vertex marko = g.addVertex(T.id, 1, T.label, "person", "name", "marko"); final Vertex stephen = g.addVertex(T.id, 7, T.label, "person", "name", "stephen"); @@ -137,21 +167,67 @@ public final class TinkerFactory { g.variables().set("comment", "this graph was created to provide examples and test coverage for tinkerpop3 api advances"); } + /** + * Creates the "kitchen sink" graph which is a collection of structures (e.g. self-loops) that aren't represented + * in other graphs and are useful for various testing scenarios. + */ public static TinkerGraph createKitchenSink() { final TinkerGraph g = getTinkerGraphWithNumberManager(); generateKitchenSink(g); return g; } + /** + * Generate the graph in {@link #createKitchenSink()} into an existing graph. + */ public static void generateKitchenSink(final TinkerGraph graph) { final GraphTraversalSource g = graph.traversal(); g.addV("loops").property(T.id, 1000).property("name", "loop").as("me"). - addE("self").to("me"). + addE("self").to("me").property(T.id, 1001). iterate(); g.addV("message").property(T.id, 2000).property("name", "a").as("a"). addV("message").property(T.id, 2001).property("name", "b").as("b"). - addE("link").from("a").to("b"). - addE("link").from("a").to("a").iterate(); + addE("link").from("a").to("b").property(T.id, 2002). + addE("link").from("a").to("a").property(T.id, 2003).iterate(); + } + + /** + * Creates the "grateful dead" graph which is a larger graph than most of the toy graphs but has real-world + * structure and application and is therefore useful for demonstrating more complex traversals. Unlike the + * other graphs, this creation process relies on a local data files for creation. Specifically, it requires + * {@code grateful-dead.kryo} to be present. It will check the following common directories in the listed order + * to try to load this graph: {@code ./}, {@code data/}, {@code ../data/} as these are the common places to find + * this file from normal TinkerPop packaging. If the file cannot be found in those directories an + * {@code IllegalStateException}. + */ + public static TinkerGraph createGratefulDead() { + final TinkerGraph g = getTinkerGraphWithNumberManager(); + generateGratefulDead(g); + return g; + } + + /** + * Generate the graph in {@link #createGratefulDead()} into an existing graph. + */ + public static void generateGratefulDead(final TinkerGraph graph) { + final String fileName = "grateful-dead.kryo"; + final List<String> files = Arrays.asList(fileName, + "data/" + fileName, + ".." + File.separator + "data" + File.separator + fileName); + + for (String fn : files) { + final File f = new File(fn); + if (f.exists()) { + try { + graph.io(gryo()).readGraph(fn); + } catch (Exception ex) { + throw new IllegalStateException(ex); + } + } + } + + if (!graph.vertices().hasNext()) + throw new IllegalStateException("grateful-dead.kryo cannot be found"); } private static TinkerGraph getTinkerGraphWithNumberManager() {