Merge branch 'TINKERPOP-1877' into TINKERPOP-1877-master Conflicts: gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/LoadGraphWith.java hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/eb6bf217 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/eb6bf217 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/eb6bf217 Branch: refs/heads/master Commit: eb6bf217c90fa9da40f1a155f024991cadff3deb Parents: b86b183 5f67d9c Author: Stephen Mallette <sp...@genoprime.com> Authored: Thu Feb 1 07:48:20 2018 -0500 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Thu Feb 1 07:48:20 2018 -0500 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + .../upgrade/release-3.2.x-incubating.asciidoc | 24 ++++++- .../gremlin/util/TinkerGraphProvider.java | 2 + 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-v1d0.json | 1 + .../io/graphson/tinkerpop-sink-typed-v2d0.json | 1 + .../io/graphson/tinkerpop-sink-v1d0.json | 1 + .../io/graphson/tinkerpop-sink-v2d0.json | 1 + .../io/graphson/tinkerpop-sink-v3d0.json | 1 + .../structure/io/gryo/tinkerpop-sink-v3d0.kryo | Bin 0 -> 79 bytes .../gremlin/hadoop/HadoopGraphProvider.java | 8 ++- .../tinkergraph/structure/TinkerFactory.java | 15 +++++ .../tinkergraph/TinkerGraphProvider.java | 2 + .../structure/IoDataGenerationTest.java | 64 +++++++++++++++++++ 19 files changed, 166 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --cc CHANGELOG.asciidoc index 11b0816,c562ccd..1ba3aa8 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@@ -272,9 -23,9 +272,10 @@@ image::https://raw.githubusercontent.co [[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. +* `ReferenceElement` avoids `UnsupportedOperationException` handling in construction thus improving performance. * Removed hardcoded expectation in metrics serialization test suite as different providers may have different outputs. * Added `IndexedTraverserSet` which indexes on the value of a `Traverser` thus improving performance when used. * Utilized `IndexedTraverserSet` in `TraversalVertexProgram` to avoid extra iteration when doing `Vertex` lookups. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/docs/src/upgrade/release-3.2.x-incubating.asciidoc ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/util/TinkerGraphProvider.java ---------------------------------------------------------------------- diff --cc gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/util/TinkerGraphProvider.java index c71a31b,0000000..7a87414 mode 100644,000000..100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/util/TinkerGraphProvider.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/util/TinkerGraphProvider.java @@@ -1,206 -1,0 +1,208 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tinkerpop.gremlin.util; + +import org.apache.commons.configuration.Configuration; +import org.apache.tinkerpop.gremlin.AbstractGraphProvider; +import org.apache.tinkerpop.gremlin.LoadGraphWith; +import org.apache.tinkerpop.gremlin.TestHelper; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.GraphTest; +import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest; +import org.apache.tinkerpop.gremlin.structure.io.IoVertexTest; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedGraphTest; +import org.apache.tinkerpop.gremlin.structure.util.star.StarGraphTest; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerEdge; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerElement; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraphVariables; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerProperty; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertexProperty; + +import java.io.File; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public class TinkerGraphProvider extends AbstractGraphProvider { + + private static final Set<Class> IMPLEMENTATION = new HashSet<Class>() {{ + add(TinkerEdge.class); + add(TinkerElement.class); + add(TinkerGraph.class); + add(TinkerGraphVariables.class); + add(TinkerProperty.class); + add(TinkerVertex.class); + add(TinkerVertexProperty.class); + }}; + + @Override + public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName, + final LoadGraphWith.GraphData loadGraphWith) { + final TinkerGraph.DefaultIdManager idManager = selectIdMakerFromGraphData(loadGraphWith); + final String idMaker = (idManager.equals(TinkerGraph.DefaultIdManager.ANY) ? selectIdMakerFromTest(test, testMethodName) : idManager).name(); + return new HashMap<String, Object>() {{ + put(Graph.GRAPH, TinkerGraph.class.getName()); + put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, idMaker); + put(TinkerGraph.GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, idMaker); + put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, idMaker); + if (requiresListCardinalityAsDefault(loadGraphWith, test, testMethodName)) + put(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name()); + if (requiresPersistence(test, testMethodName)) { + put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo"); + final File tempDir = TestHelper.makeTestDataPath(test, "temp"); + put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, + tempDir.getAbsolutePath() + File.separator + testMethodName + ".kryo"); + } + }}; + } + + @Override + public void clear(final Graph graph, final Configuration configuration) throws Exception { + if (graph != null) + graph.close(); + + // in the even the graph is persisted we need to clean up + final String graphLocation = configuration.getString(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, null); + if (graphLocation != null) { + final File f = new File(graphLocation); + f.delete(); + } + } + + @Override + public Set<Class> getImplementations() { + return IMPLEMENTATION; + } + + /** + * Determines if a test requires TinkerGraph persistence to be configured with graph location and format. + */ + protected static boolean requiresPersistence(final Class<?> test, final String testMethodName) { + return test == GraphTest.class && testMethodName.equals("shouldPersistDataOnClose"); + } + + /** + * Determines if a test requires a different cardinality as the default or not. + */ + protected static boolean requiresListCardinalityAsDefault(final LoadGraphWith.GraphData loadGraphWith, + final Class<?> test, final String testMethodName) { + return loadGraphWith == LoadGraphWith.GraphData.CREW + || (test == StarGraphTest.class && testMethodName.equals("shouldAttachWithCreateMethod")) + || (test == DetachedGraphTest.class && testMethodName.equals("testAttachableCreateMethod")); + } + + /** + * Some tests require special configuration for TinkerGraph to properly configure the id manager. + */ + protected TinkerGraph.DefaultIdManager selectIdMakerFromTest(final Class<?> test, final String testMethodName) { + if (test.equals(GraphTest.class)) { + final Set<String> testsThatNeedLongIdManager = new HashSet<String>(){{ + add("shouldIterateVerticesWithNumericIdSupportUsingDoubleRepresentation"); + add("shouldIterateVerticesWithNumericIdSupportUsingDoubleRepresentations"); + add("shouldIterateVerticesWithNumericIdSupportUsingIntegerRepresentation"); + add("shouldIterateVerticesWithNumericIdSupportUsingIntegerRepresentations"); + add("shouldIterateVerticesWithNumericIdSupportUsingFloatRepresentation"); + add("shouldIterateVerticesWithNumericIdSupportUsingFloatRepresentations"); + add("shouldIterateVerticesWithNumericIdSupportUsingStringRepresentation"); + add("shouldIterateVerticesWithNumericIdSupportUsingStringRepresentations"); + add("shouldIterateEdgesWithNumericIdSupportUsingDoubleRepresentation"); + add("shouldIterateEdgesWithNumericIdSupportUsingDoubleRepresentations"); + add("shouldIterateEdgesWithNumericIdSupportUsingIntegerRepresentation"); + add("shouldIterateEdgesWithNumericIdSupportUsingIntegerRepresentations"); + add("shouldIterateEdgesWithNumericIdSupportUsingFloatRepresentation"); + add("shouldIterateEdgesWithNumericIdSupportUsingFloatRepresentations"); + add("shouldIterateEdgesWithNumericIdSupportUsingStringRepresentation"); + add("shouldIterateEdgesWithNumericIdSupportUsingStringRepresentations"); + }}; + + final Set<String> testsThatNeedUuidIdManager = new HashSet<String>(){{ + add("shouldIterateVerticesWithUuidIdSupportUsingStringRepresentation"); + add("shouldIterateVerticesWithUuidIdSupportUsingStringRepresentations"); + add("shouldIterateEdgesWithUuidIdSupportUsingStringRepresentation"); + add("shouldIterateEdgesWithUuidIdSupportUsingStringRepresentations"); + }}; + + if (testsThatNeedLongIdManager.contains(testMethodName)) + return TinkerGraph.DefaultIdManager.LONG; + else if (testsThatNeedUuidIdManager.contains(testMethodName)) + return TinkerGraph.DefaultIdManager.UUID; + } else if (test.equals(IoEdgeTest.class)) { + final Set<String> testsThatNeedLongIdManager = new HashSet<String>(){{ + add("shouldReadWriteEdge[graphson-v1]"); + add("shouldReadWriteDetachedEdgeAsReference[graphson-v1]"); + add("shouldReadWriteDetachedEdge[graphson-v1]"); + add("shouldReadWriteEdge[graphson-v2]"); + add("shouldReadWriteDetachedEdgeAsReference[graphson-v2]"); + add("shouldReadWriteDetachedEdge[graphson-v2]"); + }}; + + if (testsThatNeedLongIdManager.contains(testMethodName)) + return TinkerGraph.DefaultIdManager.LONG; + } else if (test.equals(IoVertexTest.class)) { + final Set<String> testsThatNeedLongIdManager = new HashSet<String>(){{ + add("shouldReadWriteVertexWithBOTHEdges[graphson-v1]"); + add("shouldReadWriteVertexWithINEdges[graphson-v1]"); + add("shouldReadWriteVertexWithOUTEdges[graphson-v1]"); + add("shouldReadWriteVertexNoEdges[graphson-v1]"); + add("shouldReadWriteDetachedVertexNoEdges[graphson-v1]"); + add("shouldReadWriteDetachedVertexAsReferenceNoEdges[graphson-v1]"); + add("shouldReadWriteVertexMultiPropsNoEdges[graphson-v1]"); + add("shouldReadWriteVertexWithBOTHEdges[graphson-v2]"); + add("shouldReadWriteVertexWithINEdges[graphson-v2]"); + add("shouldReadWriteVertexWithOUTEdges[graphson-v2]"); + add("shouldReadWriteVertexNoEdges[graphson-v2]"); + add("shouldReadWriteDetachedVertexNoEdges[graphson-v2]"); + add("shouldReadWriteDetachedVertexAsReferenceNoEdges[graphson-v2]"); + add("shouldReadWriteVertexMultiPropsNoEdges[graphson-v2]"); + }}; + + if (testsThatNeedLongIdManager.contains(testMethodName)) + return TinkerGraph.DefaultIdManager.LONG; + } + + return TinkerGraph.DefaultIdManager.ANY; + } + + /** + * Test that load with specific graph data can be configured with a specific id manager as the data type to + * be used in the test for that graph is known. + */ + protected TinkerGraph.DefaultIdManager selectIdMakerFromGraphData(final LoadGraphWith.GraphData loadGraphWith) { + if (null == loadGraphWith) return TinkerGraph.DefaultIdManager.ANY; + if (loadGraphWith.equals(LoadGraphWith.GraphData.CLASSIC)) + return TinkerGraph.DefaultIdManager.INTEGER; + else if (loadGraphWith.equals(LoadGraphWith.GraphData.MODERN)) + return TinkerGraph.DefaultIdManager.INTEGER; + else if (loadGraphWith.equals(LoadGraphWith.GraphData.CREW)) + 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/eb6bf217/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml ---------------------------------------------------------------------- diff --cc gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml index cf95f0a,28ea1ac..686ea9c --- 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,21 -23,22 +23,22 @@@ 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: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/generate-all.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-all.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0], custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} + - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0], custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0], custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} - - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true}} + - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true}} - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0] }} - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2d0] }} - - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0] }} + - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0] }} processors: - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }} metrics: { http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/LoadGraphWith.java ---------------------------------------------------------------------- diff --cc gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/LoadGraphWith.java index 737d975,9fc2056..212305c --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/LoadGraphWith.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/LoadGraphWith.java @@@ -107,13 -117,15 +117,15 @@@ public @interface LoadGraphWith public String location() { switch (this) { case CLASSIC: - return RESOURCE_PATH_PREFIX + "tinkerpop-classic.kryo"; + return RESOURCE_PATH_PREFIX + "tinkerpop-classic-v3d0.kryo"; case CREW: - return RESOURCE_PATH_PREFIX + "tinkerpop-crew.kryo"; + return RESOURCE_PATH_PREFIX + "tinkerpop-crew-v3d0.kryo"; case MODERN: - return RESOURCE_PATH_PREFIX + "tinkerpop-modern.kryo"; + return RESOURCE_PATH_PREFIX + "tinkerpop-modern-v3d0.kryo"; case GRATEFUL: - return RESOURCE_PATH_PREFIX + "grateful-dead.kryo"; + return RESOURCE_PATH_PREFIX + "grateful-dead-v3d0.kryo"; + case SINK: - return RESOURCE_PATH_PREFIX + "tinkerpop-sink.kryo"; ++ return RESOURCE_PATH_PREFIX + "tinkerpop-sink-v3d0.kryo"; } throw new RuntimeException("No file for this GraphData type"); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed-v1d0.json ---------------------------------------------------------------------- diff --cc gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed-v1d0.json index 0000000,0000000..c37b54a new file mode 100644 --- /dev/null +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed-v1d0.json @@@ -1,0 -1,0 +1,1 @@@ ++{"@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"}]]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed-v2d0.json ---------------------------------------------------------------------- diff --cc gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed-v2d0.json index 0000000,0000000..c953075 new file mode 100644 --- /dev/null +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-typed-v2d0.json @@@ -1,0 -1,0 +1,1 @@@ ++{"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"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v1d0.json ---------------------------------------------------------------------- diff --cc gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v1d0.json index 0000000,0000000..a69b24f new file mode 100644 --- /dev/null +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v1d0.json @@@ -1,0 -1,0 +1,1 @@@ ++{"id":1000,"label":"loops","inE":{"self":[{"id":1,"outV":1000}]},"outE":{"self":[{"id":1,"inV":1000}]},"properties":{"name":[{"id":0,"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0.json ---------------------------------------------------------------------- diff --cc gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v2d0.json index 0000000,39496ba..a69b24f mode 000000,100644..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,0 -1,1 +1,1 @@@ -{"id":0,"label":"loops","inE":{"self":[{"id":2,"outV":0}]},"outE":{"self":[{"id":2,"inV":0}]},"properties":{"name":[{"id":1,"value":"loop"}]}} ++{"id":1000,"label":"loops","inE":{"self":[{"id":1,"outV":1000}]},"outE":{"self":[{"id":1,"inV":1000}]},"properties":{"name":[{"id":0,"value":"loop"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v3d0.json ---------------------------------------------------------------------- diff --cc gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v3d0.json index 0000000,0000000..c953075 new file mode 100644 --- /dev/null +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/tinkerpop-sink-v3d0.json @@@ -1,0 -1,0 +1,1 @@@ ++{"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"}]}} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-sink-v3d0.kryo ---------------------------------------------------------------------- diff --cc gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-sink-v3d0.kryo index 0000000,0000000..ffb944f new file mode 100644 Binary files differ http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java ---------------------------------------------------------------------- diff --cc hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java index 4410793,0ad3637..79a039a --- 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 @@@ -76,23 -77,21 +76,25 @@@ public class HadoopGraphProvider extend static { try { final List<String> kryoResources = Arrays.asList( - "tinkerpop-modern.kryo", - "grateful-dead.kryo", - "tinkerpop-classic.kryo", - "tinkerpop-crew.kryo", - "tinkerpop-sink.kryo"); + "tinkerpop-modern-v3d0.kryo", + "grateful-dead-v3d0.kryo", + "tinkerpop-classic-v3d0.kryo", - "tinkerpop-crew-v3d0.kryo"); ++ "tinkerpop-crew-v3d0.kryo", ++ "tinkerpop-sink-v3d0.kryo"); for (final String fileName : kryoResources) { PATHS.put(fileName, TestHelper.generateTempFileFromResource(GryoResourceAccess.class, fileName, "").getAbsolutePath().replace('\\', '/')); } final List<String> graphsonResources = Arrays.asList( - "tinkerpop-modern.json", - "grateful-dead.json", - "tinkerpop-classic.json", - "tinkerpop-crew.json", - "tinkerpop-sink.json"); + "tinkerpop-modern-typed-v2d0.json", + "tinkerpop-modern-v3d0.json", + "grateful-dead-typed-v2d0.json", + "grateful-dead-v3d0.json", + "tinkerpop-classic-typed-v2d0.json", + "tinkerpop-classic-v3d0.json", + "tinkerpop-crew-typed-v2d0.json", - "tinkerpop-crew-v3d0.json"); ++ "tinkerpop-crew-v3d0.json", ++ "tinkerpop-sink-v3d0.json"); for (final String fileName : graphsonResources) { PATHS.put(fileName, TestHelper.generateTempFileFromResource(GraphSONResourceAccess.class, fileName, "").getAbsolutePath().replace('\\', '/')); } @@@ -141,17 -141,19 +143,19 @@@ } public void loadGraphDataViaHadoopConfig(final Graph g, final LoadGraphWith.GraphData graphData) { - final String type = this.graphSONInput ? "json" : "kryo"; + final String type = this.graphSONInput ? "-v3d0.json" : "-v3d0.kryo"; if (graphData.equals(LoadGraphWith.GraphData.GRATEFUL)) { - ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("grateful-dead." + type)); + ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("grateful-dead" + type)); } else if (graphData.equals(LoadGraphWith.GraphData.MODERN)) { - ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-modern." + type)); + ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-modern" + type)); } else if (graphData.equals(LoadGraphWith.GraphData.CLASSIC)) { - ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-classic." + type)); + ((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)); + ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-crew" + type)); + } else if (graphData.equals(LoadGraphWith.GraphData.SINK)) { + ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-sink." + type)); - }else { + } else { throw new RuntimeException("Could not load graph with " + graphData); } } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eb6bf217/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java ---------------------------------------------------------------------- diff --cc tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java index 313716f,5aea149..1fb2ee6 --- 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 @@@ -97,62 -95,12 +97,72 @@@ public class IoDataGenerationTest } /** - * No assertions. Just write out the graph for convenience + * No assertions. Just write out the graph for convenience. + */ + @Test + public void shouldWriteClassicGraphAsGryoV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-classic-v3d0.kryo"); + GryoWriter.build().mapper(GryoMapper.build().version(GryoVersion.V3_0).create()).create().writeGraph(os, TinkerFactory.createClassic()); + os.close(); + } + + /** + * No assertions. Just write out the graph for convenience. + */ + @Test + public void shouldWriteModernGraphAsGryoV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-modern-v3d0.kryo"); + GryoWriter.build().mapper(GryoMapper.build().version(GryoVersion.V3_0).create()).create().writeGraph(os, TinkerFactory.createModern()); + os.close(); + } + + /** + * No assertions. Just write out the graph for convenience. + */ + @Test + public void shouldWriteCrewGraphAsGryoV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-crew-v3d0.kryo"); + GryoWriter.build().mapper(GryoMapper.build().version(GryoVersion.V3_0).create()).create().writeGraph(os, TinkerFactory.createTheCrew()); + os.close(); + } + + /** + * No assertions. Just write out the graph for convenience. + */ + @Test ++ public void shouldWriteSinkGraphAsGryoV3d0() throws IOException { ++ final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-sink-v3d0.kryo"); ++ GryoWriter.build().mapper(GryoMapper.build().version(GryoVersion.V3_0).create()).create().writeGraph(os, TinkerFactory.createKitchenSink()); ++ os.close(); ++ } ++ ++ /** ++ * No assertions. Just write out the graph for convenience. ++ */ ++ @Test + public void shouldWriteDEFAULTClassicGraphAsGryoV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-classic.kryo"); + GryoWriter.build().mapper(GryoMapper.build().version(GryoVersion.V3_0).create()).create().writeGraph(os, TinkerFactory.createClassic()); + os.close(); + } + + /** + * 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()); + public void shouldWriteDEFAULTModernGraphAsGryoV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-modern.kryo"); + GryoWriter.build().mapper(GryoMapper.build().version(GryoVersion.V3_0).create()).create().writeGraph(os, TinkerFactory.createModern()); + os.close(); + } + + /** + * No assertions. Just write out the graph for convenience. + */ + @Test + public void shouldWriteDEFAULTCrewGraphAsGryoV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-crew.kryo"); + GryoWriter.build().mapper(GryoMapper.build().version(GryoVersion.V3_0).create()).create().writeGraph(os, TinkerFactory.createTheCrew()); os.close(); } @@@ -207,6 -155,16 +217,16 @@@ } /** + * 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()); ++ final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-sink-v1d0.json"); ++ GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V1_0).typeInfo(TypeInfo.NO_TYPES).create()).create().writeGraph(os, TinkerFactory.createKitchenSink()); + os.close(); + } + + /** * No assertions. Just write out the graph for convenience. */ @Test @@@ -260,6 -218,17 +280,17 @@@ } /** + * 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()) ++ final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-sink-typed-v1d0.json"); ++ GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V1_0).typeInfo(TypeInfo.PARTIAL_TYPES).create()) + .create().writeGraph(os, TinkerFactory.createKitchenSink()); + os.close(); + } + + /** * No assertions. Just write out the graph for convenience. */ @Test @@@ -348,93 -328,16 +390,115 @@@ } /** + * 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() ++ final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-sink-typed-v2d0.json"); ++ GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V2_0).typeInfo(TypeInfo.PARTIAL_TYPES).create()).create() ++ .writeGraph(os, TinkerFactory.createKitchenSink()); ++ os.close(); ++ } ++ ++ /** + * No assertions. Just write out the graph for convenience. + */ + @Test + public void shouldWriteClassicGraphAsGraphSONV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-classic-v3d0.json"); + GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V3_0).create()).create() + .writeGraph(os, TinkerFactory.createClassic()); + os.close(); + } + + /** + * No assertions. Just write out the graph for convenience. + */ + @Test + public void shouldWriteModernGraphAsGraphSONV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-modern-v3d0.json"); + GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V3_0).create()).create() + .writeGraph(os, TinkerFactory.createModern()); + os.close(); + } + + /** + * No assertions. Just write out the graph for convenience. + */ + @Test + public void shouldWriteCrewGraphAsGraphSONV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-crew-v3d0.json"); + GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V3_0).create()).create() + .writeGraph(os, TinkerFactory.createTheCrew()); + os.close(); + } + + /** + * No assertions. Just write out the graph for convenience. + */ + @Test ++ public void shouldWriteSinkGraphAsGraphSONV3d0() throws IOException { ++ final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-sink-v3d0.json"); ++ GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V3_0).create()).create() + .writeGraph(os, TinkerFactory.createKitchenSink()); + os.close(); + } + ++ /** ++ * No assertions. Just write out the graph for convenience. ++ */ ++ @Test + public void shouldWriteDEFAULTClassicGraphAsGraphSONV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-classic.json"); + GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V3_0).create()).create() + .writeGraph(os, TinkerFactory.createClassic()); + os.close(); + } + + /** + * No assertions. Just write out the graph for convenience. + */ + @Test + public void shouldWriteDEFAULTModernGraphAsGraphSONV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-modern.json"); + GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V3_0).create()).create() + .writeGraph(os, TinkerFactory.createModern()); + os.close(); + } + + /** + * No assertions. Just write out the graph for convenience. + */ + @Test + public void shouldWriteDEFAULTCrewGraphAsGraphSONV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-crew.json"); + GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V3_0).create()).create() + .writeGraph(os, TinkerFactory.createTheCrew()); + os.close(); + } + + /** + * No assertions. Just write out the graph for convenience. + */ + @Test + public void shouldWriteClassicGraphNormalizedAsGraphSONV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-classic-normalized-v3d0.json"); + GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V3_0).normalize(true).create()).create() + .writeGraph(os, TinkerFactory.createClassic()); + os.close(); + } + + /** + * No assertions. Just write out the graph for convenience. + */ + @Test + public void shouldWriteModernGraphNormalizedAsGraphSONV3d0() throws IOException { + final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-modern-normalized-v3d0.json"); + GraphSONWriter.build().mapper(GraphSONMapper.build().version(GraphSONVersion.V3_0).normalize(true).create()).create() + .writeGraph(os, TinkerFactory.createModern()); + os.close(); + } + @Test public void shouldWriteSampleForGremlinServer() throws IOException { final Graph g = TinkerGraph.open();