Repository: tinkerpop Updated Branches: refs/heads/TINKERPOP-1877 [created] 5f67d9c88
TINKERPOP-1877 Added the "kitchen sink" toy graph Contains a single self-loop subgraph at this point. Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5f67d9c8 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5f67d9c8 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5f67d9c8 Branch: refs/heads/TINKERPOP-1877 Commit: 5f67d9c88cf637984a2982b4beeda9134eb01fe5 Parents: 0f58b7c Author: Stephen Mallette <[email protected]> Authored: Wed Jan 31 10:46:22 2018 -0500 Committer: Stephen Mallette <[email protected]> Committed: Wed Jan 31 10:46:22 2018 -0500 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + data/tinkerpop-sink-typed.json | 1 + data/tinkerpop-sink-v2d0-typed.json | 1 + data/tinkerpop-sink-v2d0.json | 1 + data/tinkerpop-sink.json | 1 + data/tinkerpop-sink.kryo | Bin 0 -> 76 bytes .../upgrade/release-3.2.x-incubating.asciidoc | 24 ++++++++- .../step/branch/GroovyRepeatTest.groovy | 5 ++ gremlin-server/scripts/generate-all.groovy | 6 ++- .../driver/remote/RemoteGraphProvider.java | 7 +-- .../remote/gremlin-server-integration.yaml | 3 +- .../apache/tinkerpop/gremlin/LoadGraphWith.java | 16 +++++- .../apache/tinkerpop/gremlin/TestHelper.java | 3 +- .../traversal/step/branch/RepeatTest.java | 25 ++++++++- .../io/graphson/tinkerpop-sink-typed.json | 1 + .../io/graphson/tinkerpop-sink-v2d0-typed.json | 1 + .../io/graphson/tinkerpop-sink-v2d0.json | 1 + .../structure/io/graphson/tinkerpop-sink.json | 1 + .../structure/io/gryo/tinkerpop-sink.kryo | Bin 0 -> 76 bytes .../gremlin/hadoop/HadoopGraphProvider.java | 10 ++-- .../tinkergraph/structure/TinkerFactory.java | 15 ++++++ .../tinkergraph/TinkerGraphProvider.java | 2 + .../structure/IoDataGenerationTest.java | 53 +++++++++++++++++++ 23 files changed, 162 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 938fc68..c562ccd 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -23,6 +23,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima [[release-3-2-8]] === TinkerPop 3.2.8 (Release Date: NOT OFFICIALLY RELEASED YET) +* Added the "Kitchen Sink" test data set. * Fixed a bug in `NumberHelper` that led to wrong min/max results if numbers exceeded the Integer limits. * Delayed setting of the request identifier until `RequestMessage` construction by the builder. * Removed hardcoded expectation in metrics serialization test suite as different providers may have different outputs. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/data/tinkerpop-sink-typed.json ---------------------------------------------------------------------- diff --git a/data/tinkerpop-sink-typed.json b/data/tinkerpop-sink-typed.json new file mode 100644 index 0000000..f62a717 --- /dev/null +++ b/data/tinkerpop-sink-typed.json @@ -0,0 +1 @@ +{"@class":"java.util.HashMap","id":["java.lang.Long",0],"label":"loops","inE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",2],"outV":["java.lang.Long",0]}]]},"outE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",2],"inV":["java.lang.Long",0]}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",1],"value":"loop"}]]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/data/tinkerpop-sink-v2d0-typed.json ---------------------------------------------------------------------- diff --git a/data/tinkerpop-sink-v2d0-typed.json b/data/tinkerpop-sink-v2d0-typed.json new file mode 100644 index 0000000..df22167 --- /dev/null +++ b/data/tinkerpop-sink-v2d0-typed.json @@ -0,0 +1 @@ +{"id":{"@type":"g:Int64","@value":0},"label":"loops","inE":{"self":[{"id":{"@type":"g:Int64","@value":2},"outV":{"@type":"g:Int64","@value":0}}]},"outE":{"self":[{"id":{"@type":"g:Int64","@value":2},"inV":{"@type":"g:Int64","@value":0}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":1},"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/data/tinkerpop-sink-v2d0.json ---------------------------------------------------------------------- diff --git a/data/tinkerpop-sink-v2d0.json b/data/tinkerpop-sink-v2d0.json new file mode 100644 index 0000000..39496ba --- /dev/null +++ b/data/tinkerpop-sink-v2d0.json @@ -0,0 +1 @@ +{"id":0,"label":"loops","inE":{"self":[{"id":2,"outV":0}]},"outE":{"self":[{"id":2,"inV":0}]},"properties":{"name":[{"id":1,"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/data/tinkerpop-sink.json ---------------------------------------------------------------------- diff --git a/data/tinkerpop-sink.json b/data/tinkerpop-sink.json new file mode 100644 index 0000000..39496ba --- /dev/null +++ b/data/tinkerpop-sink.json @@ -0,0 +1 @@ +{"id":0,"label":"loops","inE":{"self":[{"id":2,"outV":0}]},"outE":{"self":[{"id":2,"inV":0}]},"properties":{"name":[{"id":1,"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/data/tinkerpop-sink.kryo ---------------------------------------------------------------------- diff --git a/data/tinkerpop-sink.kryo b/data/tinkerpop-sink.kryo new file mode 100644 index 0000000..9a26e15 Binary files /dev/null and b/data/tinkerpop-sink.kryo differ http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/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 bef13ed..00a6e83 100644 --- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc +++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc @@ -21,14 +21,34 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima *Nine Inch Gremlins* +== TinkerPop 3.2.8 + +*Release Date: NOT OFFICIALLY RELEASED YET* + +Please see the link:https://github.com/apache/tinkerpop/blob/3.2.8/CHANGELOG.asciidoc#release-3-2-8[changelog] for a complete list of all the modifications that are part of this release. + +=== Upgrading for Providers + +==== Graph System Providers + +===== Kitchen Sink Test Graph + +The "Kitchen Sink" test graph has been added to the `gremlin-test` module. It contains (or will contain) various +disconnected subgraphs of that offer unique structures (e.g. a self-loop) for specific test cases. Graph systems that +use the test suite should not have to make any changes to account for this new graph unless that system performs some +form or special pre-initialization of their system in preparation for loading (e.g. requires a schema) or does the +loading of the graph test data outside of the standard method in which TinkerPop provides. + +See: link:https://issues.apache.org/jira/browse/TINKERPOP-1877[TINKERPOP-1877] + == TinkerPop 3.2.7 *Release Date: December 17, 2017* -=== Upgrading for Users - Please see the link:https://github.com/apache/tinkerpop/blob/3.2.7/CHANGELOG.asciidoc#release-3-2-7[changelog] for a complete list of all the modifications that are part of this release. +=== Upgrading for Users + ==== Gremlin-Python Core Types With the addition of `UUID`, `Date`, and `Timestamp`, Gremlin-Python now implements serializers for all core GraphSON types. Users that were using other types to represent this data can now use the Python classes `datetime.datetime` and`uuid.UUID` in GLV traversals. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy ---------------------------------------------------------------------- diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy index 3c366dc..581c511 100644 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy +++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy @@ -102,5 +102,10 @@ public abstract class GroovyRepeatTest { public Traversal<Vertex, Path> get_g_V_hasXname_markoX_repeatXoutE_inV_simplePathX_untilXhasXname_rippleXX_path_byXnameX_byXlabelX() { new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('name', 'marko').repeat(__.outE.inV.simplePath).until(has('name', 'ripple')).path.by('name').by(label)") } + + @Override + public Traversal<Vertex, Path> get_g_V_hasXloop_name_loopX_repeatXinX_timesX5X_path_by_name() { + new ScriptTraversal<>(g, "gremlin-groovy", "g.V().has('loops','name','loop').repeat(__.in()).times(5).path().by('name')") + } } } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/gremlin-server/scripts/generate-all.groovy ---------------------------------------------------------------------- diff --git a/gremlin-server/scripts/generate-all.groovy b/gremlin-server/scripts/generate-all.groovy index 6b88b2b..66b1cb4 100644 --- a/gremlin-server/scripts/generate-all.groovy +++ b/gremlin-server/scripts/generate-all.groovy @@ -28,6 +28,7 @@ globals << [hook : [ TinkerFactory.generateModern(modern) TinkerFactory.generateTheCrew(crew) grateful.io(gryo()).readGraph('../data/grateful-dead.kryo') + TinkerFactory.generateKitchenSink(sink) // a wild bit of trickery here. the process tests use an INTEGER id manager when LoadGraphWith is used. this // closure provides a way to to manually override the various id managers for TinkerGraph - the graph on which @@ -45,7 +46,7 @@ globals << [hook : [ idManagerField.set(graph, TinkerGraph.DefaultIdManager.INTEGER) } - [classic, modern, crew].each{ + [classic, modern, crew, sink].each{ allowSetOfIdManager(it, "vertexIdManager") allowSetOfIdManager(it, "edgeIdManager") allowSetOfIdManager(it, "vertexPropertyIdManager") @@ -58,4 +59,5 @@ globals << [gclassic : classic.traversal()] globals << [gmodern : modern.traversal()] globals << [gcrew : crew.traversal()] globals << [ggraph : graph.traversal()] -globals << [ggrateful : grateful.traversal()] \ No newline at end of file +globals << [ggrateful : grateful.traversal()] +globals << [gsink : sink.traversal()] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java ---------------------------------------------------------------------- diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java index ab0093d..2c81078 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java @@ -23,7 +23,6 @@ import org.apache.tinkerpop.gremlin.AbstractGraphProvider; import org.apache.tinkerpop.gremlin.LoadGraphWith; import org.apache.tinkerpop.gremlin.driver.Client; import org.apache.tinkerpop.gremlin.driver.Cluster; -import org.apache.tinkerpop.gremlin.driver.ser.Serializers; import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.server.GremlinServer; @@ -51,7 +50,6 @@ public class RemoteGraphProvider extends AbstractGraphProvider implements AutoCl private static GremlinServer server; private final Map<String, RemoteGraph> remoteCache = new HashMap<>(); private final Cluster cluster = TestClientFactory.open(); - //private final Cluster cluster = Cluster.build().maxContentLength(1024000).serializer(Serializers.GRAPHSON_V2D0).create(); private final Client client = cluster.connect(); public RemoteGraphProvider() { @@ -96,7 +94,7 @@ public class RemoteGraphProvider extends AbstractGraphProvider implements AutoCl @Override public void clear(final Graph graph, final Configuration configuration) throws Exception { - // doesn't bother to clear grateful because i don't believe that ever gets mutated - read-only + // doesn't bother to clear grateful/sink because i don't believe that ever gets mutated - read-only client.submit("classic.clear();modern.clear();crew.clear();graph.clear();" + "TinkerFactory.generateClassic(classic);" + "TinkerFactory.generateModern(modern);" + @@ -159,6 +157,9 @@ public class RemoteGraphProvider extends AbstractGraphProvider implements AutoCl case CREW: serverGraphName = "crew"; break; + case SINK: + serverGraphName = "sink"; + break; default: serverGraphName = "graph"; break; http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml ---------------------------------------------------------------------- diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml index d1e7ba6..28ea1ac 100644 --- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml +++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml @@ -23,7 +23,8 @@ graphs: { classic: conf/tinkergraph-empty.properties, modern: conf/tinkergraph-empty.properties, crew: conf/tinkergraph-empty.properties, - grateful: conf/tinkergraph-empty.properties} + grateful: conf/tinkergraph-empty.properties, + sink: conf/tinkergraph-empty.properties} plugins: - tinkerpop.tinkergraph scriptEngines: { http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/LoadGraphWith.java ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/LoadGraphWith.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/LoadGraphWith.java index 071d579..9fc2056 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/LoadGraphWith.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/LoadGraphWith.java @@ -77,7 +77,13 @@ public @interface LoadGraphWith { * Loads the "grateful dead" graph which is a "large" graph which provides for the construction of more * complex traversals. */ - GRATEFUL; + GRATEFUL, + + /** + * Loads a test graph which contains disconnected subgraphs specialized for testing purposes (e.g. a subgraph + * with a self-loop). This graph is created with the {@link TestHelper#loadSinkGraph(Graph)} method. + */ + SINK; private static final List<FeatureRequirement> featuresRequiredByClassic = new ArrayList<FeatureRequirement>() {{ add(FeatureRequirement.Factory.create(FEATURE_STRING_VALUES, VertexPropertyFeatures.class)); @@ -104,6 +110,10 @@ public @interface LoadGraphWith { add(FeatureRequirement.Factory.create(FEATURE_INTEGER_VALUES, VertexPropertyFeatures.class)); }}; + private static final List<FeatureRequirement> featuresRequiredBySink = new ArrayList<FeatureRequirement>() {{ + add(FeatureRequirement.Factory.create(FEATURE_STRING_VALUES, VertexPropertyFeatures.class)); + }}; + public String location() { switch (this) { case CLASSIC: @@ -114,6 +124,8 @@ public @interface LoadGraphWith { return RESOURCE_PATH_PREFIX + "tinkerpop-modern.kryo"; case GRATEFUL: return RESOURCE_PATH_PREFIX + "grateful-dead.kryo"; + case SINK: + return RESOURCE_PATH_PREFIX + "tinkerpop-sink.kryo"; } throw new RuntimeException("No file for this GraphData type"); @@ -129,6 +141,8 @@ public @interface LoadGraphWith { return featuresRequiredByModern; case GRATEFUL: return featuresRequiredByGrateful; + case SINK: + return featuresRequiredBySink; } throw new RuntimeException("No features for this GraphData type"); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java index 382c39d..833a383 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java @@ -18,6 +18,7 @@ */ package org.apache.tinkerpop.gremlin; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Graph; @@ -32,8 +33,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URISyntaxException; import java.net.URL; import java.util.Iterator; import java.util.List; http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatTest.java ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatTest.java index ae1220f..75bb83f 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatTest.java @@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest; import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner; import org.apache.tinkerpop.gremlin.process.traversal.Path; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; import org.apache.tinkerpop.gremlin.process.traversal.step.util.MapHelper; import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -36,6 +37,7 @@ import java.util.List; import java.util.Map; import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN; +import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.SINK; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.both; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.groupCount; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.has; @@ -43,7 +45,9 @@ import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.in; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.loops; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.outE; -import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.values; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.collection.IsIterableContainingInOrder.contains; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -66,6 +70,8 @@ public abstract class RepeatTest extends AbstractGremlinProcessTest { public abstract Traversal<Vertex, Vertex> get_g_V_repeatXoutX_timesX2X_emit(); + public abstract Traversal<Vertex, Path> get_g_V_hasXloop_name_loopX_repeatXinX_timesX5X_path_by_name(); + // WHILE/DO public abstract Traversal<Vertex, String> get_g_VX1X_timesX2X_repeatXoutX_name(final Object v1Id); @@ -202,6 +208,16 @@ public abstract class RepeatTest extends AbstractGremlinProcessTest { } @Test + @LoadGraphWith(SINK) + public void g_V_hasXloop_name_loopX_repeatXinX_timesX5X_path_by_name() { + final Traversal<Vertex, Path> traversal = get_g_V_hasXloop_name_loopX_repeatXinX_timesX5X_path_by_name(); + printTraversalForm(traversal); + final Path path = traversal.next(); + assertThat(path, contains("loop", "loop", "loop", "loop", "loop", "loop")); + assertThat(traversal.hasNext(), is(false)); + } + + @Test @LoadGraphWith(MODERN) public void g_VX1X_emitXhasXlabel_personXX_repeatXoutX_name() { final Traversal<Vertex, String> traversal = get_g_VX1X_emitXhasXlabel_personXX_repeatXoutX_name(convertToVertexId("marko")); @@ -365,5 +381,10 @@ public abstract class RepeatTest extends AbstractGremlinProcessTest { public Traversal<Vertex, Path> get_g_V_hasXname_markoX_repeatXoutE_inV_simplePathX_untilXhasXname_rippleXX_path_byXnameX_byXlabelX() { return g.V().has("name", "marko").repeat(outE().inV().simplePath()).until(has("name", "ripple")).path().by("name").by(T.label); } - } + + @Override + public Traversal<Vertex, Path> get_g_V_hasXloop_name_loopX_repeatXinX_timesX5X_path_by_name() { + return g.V().has("loops","name","loop").repeat(__.in()).times(5).path().by("name"); + } + } } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/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 new file mode 100644 index 0000000..f62a717 --- /dev/null +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed.json @@ -0,0 +1 @@ +{"@class":"java.util.HashMap","id":["java.lang.Long",0],"label":"loops","inE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",2],"outV":["java.lang.Long",0]}]]},"outE":{"@class":"java.util.HashMap","self":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",2],"inV":["java.lang.Long",0]}]]},"properties":{"@class":"java.util.HashMap","name":["java.util.ArrayList",[{"@class":"java.util.HashMap","id":["java.lang.Long",1],"value":"loop"}]]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/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 new file mode 100644 index 0000000..df22167 --- /dev/null +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0-typed.json @@ -0,0 +1 @@ +{"id":{"@type":"g:Int64","@value":0},"label":"loops","inE":{"self":[{"id":{"@type":"g:Int64","@value":2},"outV":{"@type":"g:Int64","@value":0}}]},"outE":{"self":[{"id":{"@type":"g:Int64","@value":2},"inV":{"@type":"g:Int64","@value":0}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":1},"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/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 new file mode 100644 index 0000000..39496ba --- /dev/null +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0.json @@ -0,0 +1 @@ +{"id":0,"label":"loops","inE":{"self":[{"id":2,"outV":0}]},"outE":{"self":[{"id":2,"inV":0}]},"properties":{"name":[{"id":1,"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/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 new file mode 100644 index 0000000..39496ba --- /dev/null +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink.json @@ -0,0 +1 @@ +{"id":0,"label":"loops","inE":{"self":[{"id":2,"outV":0}]},"outE":{"self":[{"id":2,"inV":0}]},"properties":{"name":[{"id":1,"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/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 new file mode 100644 index 0000000..9a26e15 Binary files /dev/null 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/5f67d9c8/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java ---------------------------------------------------------------------- diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java index 9c6a352..0ad3637 100644 --- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java +++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java @@ -80,7 +80,8 @@ public class HadoopGraphProvider extends AbstractGraphProvider { "tinkerpop-modern.kryo", "grateful-dead.kryo", "tinkerpop-classic.kryo", - "tinkerpop-crew.kryo"); + "tinkerpop-crew.kryo", + "tinkerpop-sink.kryo"); for (final String fileName : kryoResources) { PATHS.put(fileName, TestHelper.generateTempFileFromResource(GryoResourceAccess.class, fileName, "").getAbsolutePath().replace('\\', '/')); } @@ -89,7 +90,8 @@ public class HadoopGraphProvider extends AbstractGraphProvider { "tinkerpop-modern.json", "grateful-dead.json", "tinkerpop-classic.json", - "tinkerpop-crew.json"); + "tinkerpop-crew.json", + "tinkerpop-sink.json"); for (final String fileName : graphsonResources) { PATHS.put(fileName, TestHelper.generateTempFileFromResource(GraphSONResourceAccess.class, fileName, "").getAbsolutePath().replace('\\', '/')); } @@ -149,7 +151,9 @@ public class HadoopGraphProvider extends AbstractGraphProvider { ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-classic." + type)); } else if (graphData.equals(LoadGraphWith.GraphData.CREW)) { ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-crew." + type)); - } else { + } else if (graphData.equals(LoadGraphWith.GraphData.SINK)) { + ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-sink." + type)); + }else { throw new RuntimeException("Could not load graph with " + graphData); } } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/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 0520ee2..96d26ca 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 @@ -20,6 +20,8 @@ package org.apache.tinkerpop.gremlin.tinkergraph.structure; import org.apache.commons.configuration.BaseConfiguration; import org.apache.commons.configuration.Configuration; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.VertexProperty; @@ -136,6 +138,19 @@ public final class TinkerFactory { g.variables().set("comment", "this graph was created to provide examples and test coverage for tinkerpop3 api advances"); } + public static TinkerGraph createKitchenSink() { + final TinkerGraph g = getTinkerGraphWithNumberManager(); + generateKitchenSink(g); + return g; + } + + 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"). + iterate(); + } + private static TinkerGraph getTinkerGraphWithNumberManager() { final Configuration conf = getNumberIdManagerConfiguration(); return TinkerGraph.open(conf); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/TinkerGraphProvider.java ---------------------------------------------------------------------- diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/TinkerGraphProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/TinkerGraphProvider.java index d6dd562..7f0e6f3 100644 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/TinkerGraphProvider.java +++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/TinkerGraphProvider.java @@ -200,6 +200,8 @@ public class TinkerGraphProvider extends AbstractGraphProvider { return TinkerGraph.DefaultIdManager.INTEGER; else if (loadGraphWith.equals(LoadGraphWith.GraphData.GRATEFUL)) return TinkerGraph.DefaultIdManager.INTEGER; + else if (loadGraphWith.equals(LoadGraphWith.GraphData.SINK)) + return TinkerGraph.DefaultIdManager.INTEGER; else throw new IllegalStateException(String.format("Need to define a new %s for %s", TinkerGraph.IdManager.class.getName(), loadGraphWith.name())); } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f67d9c8/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java ---------------------------------------------------------------------- diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java index d07105b..5aea149 100644 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java +++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java @@ -95,6 +95,16 @@ public class IoDataGenerationTest { } /** + * No assertions. Just write out the graph for convenience + */ + @Test + public void shouldWriteKitchenSinkAsGryo() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-sink.kryo"); + GryoWriter.build().create().writeGraph(os, TinkerFactory.createKitchenSink()); + os.close(); + } + + /** * No assertions. Just write out the graph for convenience. */ @Test @@ -145,6 +155,16 @@ public class IoDataGenerationTest { } /** + * No assertions. Just write out the graph for convenience + */ + @Test + public void shouldWriteKitchenSinkAsGraphSONNoTypes() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-sink.json"); + GraphSONWriter.build().create().writeGraph(os, TinkerFactory.createKitchenSink()); + os.close(); + } + + /** * No assertions. Just write out the graph for convenience. */ @Test @@ -198,6 +218,17 @@ public class IoDataGenerationTest { } /** + * No assertions. Just write out the graph for convenience + */ + @Test + public void shouldWriteKitchenSinkAsGraphSONWithTypes() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-sink-typed.json"); + GraphSONWriter.build().mapper(GraphSONMapper.build().embedTypes(true).create()) + .create().writeGraph(os, TinkerFactory.createKitchenSink()); + os.close(); + } + + /** * No assertions. Just write out the graph for convenience. */ @Test @@ -231,6 +262,17 @@ public class IoDataGenerationTest { } /** + * No assertions. Just write out the graph for convenience + */ + @Test + public void shouldWriteKitchenSinkAsGraphSONV2d0NoTypes() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-sink-v2d0.json"); + GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V2_0).typeInfo(TypeInfo.NO_TYPES).create()).create() + .writeGraph(os, TinkerFactory.createKitchenSink()); + os.close(); + } + + /** * No assertions. Just write out the graph for convenience. */ @Test @@ -285,6 +327,17 @@ public class IoDataGenerationTest { os.close(); } + /** + * No assertions. Just write out the graph for convenience + */ + @Test + public void shouldWriteKitchenSinkAsGraphSONV2d0WithTypes() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-sink-v2d0-typed.json"); + GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V2_0).create()).create() + .writeGraph(os, TinkerFactory.createKitchenSink()); + os.close(); + } + @Test public void shouldWriteSampleForGremlinServer() throws IOException { final Graph g = TinkerGraph.open();
