You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/11/30 23:01:39 UTC

[1/7] incubator-tinkerpop git commit: Support a native TinkerGraph GraphSON serializer.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 4fb384465 -> e14019b34


Support a native TinkerGraph GraphSON serializer.

This change allows an ObjectMapper to take a TinkerGraph as a value.  This is in contrast to the approach taken for something like GraphSONWriter.writeGraph() where the pieces of the Graph are iterated and serialized independent of the Graph object itself.


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

Branch: refs/heads/master
Commit: e90c49fc737ad24f8f5ec5a89cf98e314533c25a
Parents: 086a258
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Nov 19 14:06:38 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Nov 19 14:06:38 2015 -0500

----------------------------------------------------------------------
 .../structure/io/graphson/GraphSONReader.java   |   4 +-
 .../structure/io/graphson/GraphSONTokens.java   |   2 +
 .../structure/io/graphson/GraphSONUtil.java     |  10 +-
 .../structure/io/graphson/GraphSONWriter.java   |   2 +-
 .../server/GremlinResultSetIntegrateTest.java   |  25 ++-
 .../tinkergraph/structure/TinkerIoRegistry.java | 176 ++++++++++++++++++-
 .../TinkerGraphGryoSerializerTest.java          |  81 +++++++++
 .../structure/TinkerGraphSerializerTest.java    |  81 ---------
 .../tinkergraph/structure/TinkerGraphTest.java  |  35 ++++
 9 files changed, 325 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e90c49fc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
index d10a382..7b5ade7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
@@ -252,8 +252,8 @@ public final class GraphSONReader implements GraphReader {
     private Stream<String> readVertexStrings(final InputStream inputStream) throws IOException {
         if (unwrapAdjacencyList) {
             final JsonNode root = mapper.readTree(inputStream);
-            final JsonNode vertices = root.get("vertices");
-            if (!vertices.getNodeType().equals(JsonNodeType.ARRAY)) throw new IOException("The 'vertices' key must be an array");
+            final JsonNode vertices = root.get(GraphSONTokens.VERTICES);
+            if (!vertices.getNodeType().equals(JsonNodeType.ARRAY)) throw new IOException(String.format("The '%s' key must be an array", GraphSONTokens.VERTICES));
             return IteratorUtils.stream(vertices.elements()).map(Object::toString);
         } else {
             final BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e90c49fc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
index 3ed9f41..599b6fa 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
@@ -32,7 +32,9 @@ public final class GraphSONTokens {
     public static final String PROPERTIES = "properties";
     public static final String KEY = "key";
     public static final String EDGE = "edge";
+    public static final String EDGES = "edges";
     public static final String VERTEX = "vertex";
+    public static final String VERTICES = "vertices";
     public static final String IN = "inV";
     public static final String OUT = "outV";
     public static final String IN_E = "inE";

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e90c49fc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
index 136d266..9ff427c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
@@ -34,18 +34,24 @@ public final class GraphSONUtil {
 
     private GraphSONUtil() {}
 
+    public static void writeWithType(final Object object, final JsonGenerator jsonGenerator,
+                                     final SerializerProvider serializerProvider,
+                                     final TypeSerializer typeSerializer) throws IOException {
+        writeWithType(null, object, jsonGenerator, serializerProvider, typeSerializer);
+    }
+
     public static void writeWithType(final String key, final Object object, final JsonGenerator jsonGenerator,
                                      final SerializerProvider serializerProvider,
                                      final TypeSerializer typeSerializer) throws IOException {
         final JsonSerializer<Object> serializer = serializerProvider.findValueSerializer(object.getClass(), null);
         if (typeSerializer != null) {
             // serialize with types embedded
-            jsonGenerator.writeFieldName(key);
+            if (key != null && !key.isEmpty()) jsonGenerator.writeFieldName(key);
             serializer.serializeWithType(object, jsonGenerator, serializerProvider, typeSerializer);
         } else {
             // types are not embedded, but use the serializer when possible or else custom serializers will get
             // bypassed and you end up with the default jackson serializer when you don't want it.
-            jsonGenerator.writeFieldName(key);
+            if (key != null && !key.isEmpty()) jsonGenerator.writeFieldName(key);
             serializer.serialize(object, jsonGenerator, serializerProvider);
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e90c49fc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONWriter.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONWriter.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONWriter.java
index 04818d6..37ed9a0 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONWriter.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONWriter.java
@@ -100,7 +100,7 @@ public final class GraphSONWriter implements GraphWriter {
     public void writeVertices(final OutputStream outputStream, final Iterator<Vertex> vertexIterator, final Direction direction) throws IOException {
         final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream));
         try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
-            if (wrapAdjacencyList) writer.write("{\"vertices\":[");
+            if (wrapAdjacencyList) writer.write("{\"" + GraphSONTokens.VERTICES + "\":[");
             while (vertexIterator.hasNext()) {
                 writeVertex(baos, vertexIterator.next(), direction);
                 writer.write(new String(baos.toByteArray()));

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e90c49fc/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
index 1128d5a..4a8eca9 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
@@ -20,18 +20,24 @@ package org.apache.tinkerpop.gremlin.server;
 
 import org.apache.tinkerpop.gremlin.driver.Client;
 import org.apache.tinkerpop.gremlin.driver.Cluster;
+import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
 import org.apache.tinkerpop.gremlin.driver.Result;
 import org.apache.tinkerpop.gremlin.driver.ResultSet;
+import org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0;
 import org.apache.tinkerpop.gremlin.process.traversal.Path;
 import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.io.IoTest;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPath;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistry;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -64,7 +70,13 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat
 
     @Before
     public void beforeTest() {
-        cluster = Cluster.open();
+        final MessageSerializer serializer = new GryoMessageSerializerV1d0();
+        final Map<String,Object> c = new HashMap<>();
+        c.put("ioRegistries", Arrays.asList(TinkerIoRegistry.class.getName()));
+        c.put("custom", Arrays.asList("groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer"));
+
+        serializer.configure(c, null);
+        cluster = Cluster.build().serializer(serializer).create();
         client = cluster.connect();
     }
 
@@ -127,6 +139,17 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat
     }
 
     @Test
+    public void shouldHandleTinkerGraphResult() throws Exception {
+        final ResultSet results = client.submit("graph");
+        final Graph graph = results.all().get().get(0).get(TinkerGraph.class);
+
+        // test is "lossy for id" because TinkerGraph is configured by default to use the ANY id manager
+        // and doesn't coerce to specific types - which is how it is on the server as well so we can expect
+        // some id shiftiness
+        IoTest.assertModernGraph(graph, true, true);
+    }
+
+    @Test
     public void shouldHandleMapIteratedResult() throws Exception {
         final ResultSet results = client.submit("g.V().groupCount().by(bothE().count())");
         final List<Result> resultList = results.all().get();

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e90c49fc/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
index 50690a3..60cebe6 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
@@ -18,18 +18,44 @@
  */
 package org.apache.tinkerpop.gremlin.tinkergraph.structure;
 
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry;
+import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
 import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONUtil;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
+import org.apache.tinkerpop.shaded.jackson.core.JsonGenerator;
+import org.apache.tinkerpop.shaded.jackson.core.JsonParser;
+import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException;
+import org.apache.tinkerpop.shaded.jackson.databind.DeserializationContext;
+import org.apache.tinkerpop.shaded.jackson.databind.SerializerProvider;
+import org.apache.tinkerpop.shaded.jackson.databind.deser.std.StdDeserializer;
+import org.apache.tinkerpop.shaded.jackson.databind.jsontype.TypeSerializer;
+import org.apache.tinkerpop.shaded.jackson.databind.module.SimpleModule;
+import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdSerializer;
 import org.apache.tinkerpop.shaded.kryo.Kryo;
 import org.apache.tinkerpop.shaded.kryo.Serializer;
 import org.apache.tinkerpop.shaded.kryo.io.Input;
 import org.apache.tinkerpop.shaded.kryo.io.Output;
+import org.javatuples.Pair;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * An implementation of the {@link IoRegistry} interface that provides serializers with custom configurations for
@@ -48,7 +74,8 @@ public final class TinkerIoRegistry extends AbstractIoRegistry {
     private static final TinkerIoRegistry INSTANCE = new TinkerIoRegistry();
 
     private TinkerIoRegistry() {
-        register(GryoIo.class, TinkerGraph.class, new TinkerGraphSerializer());
+        register(GryoIo.class, TinkerGraph.class, new TinkerGraphGryoSerializer());
+        register(GraphSONIo.class, null, new TinkerModule());
     }
 
     public static TinkerIoRegistry getInstance() {
@@ -56,10 +83,10 @@ public final class TinkerIoRegistry extends AbstractIoRegistry {
     }
 
     /**
-     * Provides a method to serialize an entire {@link TinkerGraph} into itself.  This is useful when shipping small
-     * graphs around through Gremlin Server. Reuses the existing Kryo instance for serialization.
+     * Provides a method to serialize an entire {@link TinkerGraph} into itself for Gryo.  This is useful when
+     * shipping small graphs around through Gremlin Server. Reuses the existing Kryo instance for serialization.
      */
-    final static class TinkerGraphSerializer extends Serializer<TinkerGraph> {
+    final static class TinkerGraphGryoSerializer extends Serializer<TinkerGraph> {
         @Override
         public void write(final Kryo kryo, final Output output, final TinkerGraph graph) {
             try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
@@ -86,4 +113,145 @@ public final class TinkerIoRegistry extends AbstractIoRegistry {
             return graph;
         }
     }
+
+    /**
+     * Provides a method to serialize an entire {@link TinkerGraph} into itself for GraphSON.  This is useful when
+     * shipping small graphs around through Gremlin Server.
+     */
+    final static class TinkerModule extends SimpleModule {
+        public TinkerModule() {
+            super("tinkergraph-1.0");
+            addSerializer(TinkerGraph.class, new TinkerGraphJacksonSerializer());
+            addDeserializer(TinkerGraph.class, new TinkerGraphJacksonDeserializer());
+        }
+    }
+
+    /**
+     * Serializes the graph into an edge list format.  Edge list is a better choices than adjacency list (which is
+     * typically standard from the {@link GraphReader} and {@link GraphWriter} perspective) in this case because
+     * the use case for this isn't around massive graphs.  The use case is for "small" subgraphs that are being
+     * shipped over the wire from Gremlin Server. Edge list is format is a bit easier for non-JVM languages to work
+     * with as a format and doesn't require a cache for loading (as vertex labels are not serialized in adjacency
+     * list).
+     */
+    final static class TinkerGraphJacksonSerializer extends StdSerializer<TinkerGraph> {
+
+        public TinkerGraphJacksonSerializer() {
+            super(TinkerGraph.class);
+        }
+
+        @Override
+        public void serialize(final TinkerGraph graph, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
+                throws IOException {
+            jsonGenerator.writeStartObject();
+
+            jsonGenerator.writeFieldName(GraphSONTokens.VERTICES);
+            jsonGenerator.writeStartArray();
+
+            final Iterator<Vertex> vertices = graph.vertices();
+            while (vertices.hasNext()) {
+                serializerProvider.defaultSerializeValue(vertices.next(), jsonGenerator);
+            }
+
+            jsonGenerator.writeEndArray();
+
+            jsonGenerator.writeFieldName(GraphSONTokens.EDGES);
+            jsonGenerator.writeStartArray();
+
+            final Iterator<Edge> edges = graph.edges();
+            while (edges.hasNext()) {
+                serializerProvider.defaultSerializeValue(edges.next(), jsonGenerator);
+            }
+
+            jsonGenerator.writeEndArray();
+
+            jsonGenerator.writeEndObject();
+        }
+
+        @Override
+        public void serializeWithType(final TinkerGraph graph, final JsonGenerator jsonGenerator,
+                                      final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException {
+            jsonGenerator.writeStartObject();
+            jsonGenerator.writeStringField(GraphSONTokens.CLASS, TinkerGraph.class.getName());
+
+            jsonGenerator.writeFieldName(GraphSONTokens.VERTICES);
+            jsonGenerator.writeStartArray();
+            jsonGenerator.writeString(ArrayList.class.getName());
+            jsonGenerator.writeStartArray();
+
+            final Iterator<Vertex> vertices = graph.vertices();
+            while (vertices.hasNext()) {
+                GraphSONUtil.writeWithType(vertices.next(), jsonGenerator, serializerProvider, typeSerializer);
+            }
+
+            jsonGenerator.writeEndArray();
+            jsonGenerator.writeEndArray();
+
+            jsonGenerator.writeFieldName(GraphSONTokens.EDGES);
+            jsonGenerator.writeStartArray();
+            jsonGenerator.writeString(ArrayList.class.getName());
+            jsonGenerator.writeStartArray();
+
+            final Iterator<Edge> edges = graph.edges();
+            while (edges.hasNext()) {
+                GraphSONUtil.writeWithType(edges.next(), jsonGenerator, serializerProvider, typeSerializer);
+            }
+
+            jsonGenerator.writeEndArray();
+            jsonGenerator.writeEndArray();
+
+            jsonGenerator.writeEndObject();
+        }
+    }
+
+    /**
+     * Deserializes the edge list format.
+     */
+    static class TinkerGraphJacksonDeserializer extends StdDeserializer<TinkerGraph> {
+        public TinkerGraphJacksonDeserializer() {
+            super(TinkerGraph.class);
+        }
+
+        @Override
+        public TinkerGraph deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+            final TinkerGraph graph = TinkerGraph.open();
+
+            final List<Map<String, Object>> edges;
+            final List<Map<String, Object>> vertices;
+            if (!jsonParser.getCurrentToken().isStructStart()) {
+                if (!jsonParser.getCurrentName().equals(GraphSONTokens.VERTICES))
+                    throw new IOException(String.format("Expected a '%s' key", GraphSONTokens.VERTICES));
+
+                jsonParser.nextToken();
+                vertices = (List<Map<String, Object>>) deserializationContext.readValue(jsonParser, ArrayList.class);
+                jsonParser.nextToken();
+
+                if (!jsonParser.getCurrentName().equals(GraphSONTokens.EDGES))
+                    throw new IOException(String.format("Expected a '%s' key", GraphSONTokens.EDGES));
+
+                jsonParser.nextToken();
+                edges = (List<Map<String, Object>>) deserializationContext.readValue(jsonParser, ArrayList.class);
+            } else {
+                final Map<String, Object> graphData = deserializationContext.readValue(jsonParser, HashMap.class);
+                vertices = (List<Map<String,Object>>) graphData.get("vertices");
+                edges = (List<Map<String,Object>>) graphData.get("edges");
+            }
+
+            for (Map<String, Object> vertexData : vertices) {
+                final DetachedVertex detached = new DetachedVertex(vertexData.get(GraphSONTokens.ID),
+                        vertexData.get(GraphSONTokens.LABEL).toString(), (Map<String,Object>) vertexData.get(GraphSONTokens.PROPERTIES));
+                detached.attach(Attachable.Method.getOrCreate(graph));
+            }
+
+            for (Map<String, Object> edgeData : edges) {
+                final DetachedEdge detached = new DetachedEdge(edgeData.get(GraphSONTokens.ID),
+                        edgeData.get(GraphSONTokens.LABEL).toString(), (Map<String,Object>) edgeData.get(GraphSONTokens.PROPERTIES),
+                        Pair.with(edgeData.get(GraphSONTokens.OUT), edgeData.get(GraphSONTokens.OUT_LABEL).toString()),
+                        Pair.with(edgeData.get(GraphSONTokens.IN), edgeData.get(GraphSONTokens.IN_LABEL).toString()));
+                detached.attach(Attachable.Method.getOrCreate(graph));
+            }
+
+            return graph;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e90c49fc/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGryoSerializerTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGryoSerializerTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGryoSerializerTest.java
new file mode 100644
index 0000000..3decd5f
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGryoSerializerTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.tinkergraph.structure;
+
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
+import org.apache.tinkerpop.shaded.kryo.Kryo;
+import org.apache.tinkerpop.shaded.kryo.Registration;
+import org.apache.tinkerpop.shaded.kryo.io.Input;
+import org.apache.tinkerpop.shaded.kryo.io.Output;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import java.util.Arrays;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * Unit tests for {@link TinkerIoRegistry.TinkerGraphGryoSerializer}
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class TinkerGraphGryoSerializerTest {
+
+    @Mock
+    private Kryo kryo;
+    @Mock
+    private Registration registration;
+    @Mock
+    private Output output;
+    @Mock
+    private Input input;
+
+    private TinkerGraph graph = TinkerGraph.open();
+    private TinkerIoRegistry.TinkerGraphGryoSerializer serializer = new TinkerIoRegistry.TinkerGraphGryoSerializer();
+
+    @Before
+    public void setUp() throws Exception {
+
+        when(kryo.getRegistration((Class) any())).thenReturn(registration);
+        when(input.readBytes(anyInt())).thenReturn(Arrays.copyOf(GryoMapper.HEADER, 100));
+    }
+
+    @Test
+    public void shouldVerifyKryoUsedForWrite() throws Exception {
+        serializer.write(kryo, output, graph);
+        verify(kryo, atLeastOnce()).getRegistration((Class) any());
+    }
+
+    @Test
+    public void shouldVerifyKryoUsedForRead() throws Exception {
+        // Not possible to mock an entire deserialization so just verify the same kryo instances are being used
+        try {
+            serializer.read(kryo, input, TinkerGraph.class);
+        } catch (RuntimeException ex) {
+            verify(kryo, atLeastOnce()).readObject(any(), any());
+            verify(kryo, atLeastOnce()).readClassAndObject(any());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e90c49fc/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphSerializerTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphSerializerTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphSerializerTest.java
deleted file mode 100644
index 1c494b5..0000000
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphSerializerTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.tinkergraph.structure;
-
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
-import org.apache.tinkerpop.shaded.kryo.Kryo;
-import org.apache.tinkerpop.shaded.kryo.Registration;
-import org.apache.tinkerpop.shaded.kryo.io.Input;
-import org.apache.tinkerpop.shaded.kryo.io.Output;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import java.util.Arrays;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-/**
- * Unit tests for {@link org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistry.TinkerGraphSerializer}
- */
-@RunWith(MockitoJUnitRunner.class)
-public class TinkerGraphSerializerTest {
-
-    @Mock
-    private Kryo kryo;
-    @Mock
-    private Registration registration;
-    @Mock
-    private Output output;
-    @Mock
-    private Input input;
-
-    private TinkerGraph graph = TinkerGraph.open();
-    private TinkerIoRegistry.TinkerGraphSerializer serializer = new TinkerIoRegistry.TinkerGraphSerializer();
-
-    @Before
-    public void setUp() throws Exception {
-
-        when(kryo.getRegistration((Class) any())).thenReturn(registration);
-        when(input.readBytes(anyInt())).thenReturn(Arrays.copyOf(GryoMapper.HEADER, 100));
-    }
-
-    @Test
-    public void shouldVerifyKryoUsedForWrite() throws Exception {
-        serializer.write(kryo, output, graph);
-        verify(kryo, atLeastOnce()).getRegistration((Class) any());
-    }
-
-    @Test
-    public void shouldVerifyKryoUsedForRead() throws Exception {
-        // Not possible to mock an entire deserialization so just verify the same kryo instances are being used
-        try {
-            serializer.read(kryo, input, TinkerGraph.class);
-        } catch (RuntimeException ex) {
-            verify(kryo, atLeastOnce()).readObject(any(), any());
-            verify(kryo, atLeastOnce()).readClassAndObject(any());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e90c49fc/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index b3dc64e..d1bf381 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@ -20,12 +20,19 @@ package org.apache.tinkerpop.gremlin.tinkergraph.structure;
 
 import org.apache.commons.configuration.BaseConfiguration;
 import org.apache.commons.configuration.Configuration;
+import org.apache.commons.io.IOUtils;
 import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
 import org.apache.tinkerpop.gremlin.structure.io.IoCore;
 import org.apache.tinkerpop.gremlin.structure.io.IoTest;
+import org.apache.tinkerpop.gremlin.structure.io.Mapper;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
+import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -282,6 +289,34 @@ public class TinkerGraphTest {
             }
         }
     }
+
+    @Test
+    public void shouldSerializeTinkerGraphToGraphSON() throws Exception {
+        final TinkerGraph graph = TinkerFactory.createModern();
+        try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+            graph.io(IoCore.graphson()).writer().create().writeObject(out, graph);
+            try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
+                final TinkerGraph target = graph.io(IoCore.graphson()).reader().create().readObject(inputStream, TinkerGraph.class);
+                IoTest.assertModernGraph(target, true, false);
+            }
+        }
+    }
+
+    @Test
+    public void shouldSerializeTinkerGraphToGraphSONWithTypes() throws Exception {
+        final TinkerGraph graph = TinkerFactory.createModern();
+        final Mapper<ObjectMapper> mapper = graph.io(IoCore.graphson()).mapper().embedTypes(true).create();
+        try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+            final GraphWriter writer = GraphSONWriter.build().mapper(mapper).create();
+            writer.writeObject(out, graph);
+            try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
+                final GraphReader reader = GraphSONReader.build().mapper(mapper).create();
+                final TinkerGraph target = reader.readObject(inputStream, TinkerGraph.class);
+                IoTest.assertModernGraph(target, true, false);
+            }
+        }
+    }
+
     @Test(expected = IllegalStateException.class)
     public void shouldRequireGraphLocationIfFormatIsSet() {
         final Configuration conf = new BaseConfiguration();


[5/7] incubator-tinkerpop git commit: Used GraphSONTokens where they should have been used

Posted by sp...@apache.org.
Used GraphSONTokens where they should have been used


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

Branch: refs/heads/master
Commit: 87607611042152a1c02e029cbde78e89ebe22f5c
Parents: 820297e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Nov 30 16:36:16 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Nov 30 16:36:16 2015 -0500

----------------------------------------------------------------------
 .../gremlin/tinkergraph/structure/TinkerIoRegistry.java          | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/87607611/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
index 60cebe6..abdef24 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
@@ -233,8 +233,8 @@ public final class TinkerIoRegistry extends AbstractIoRegistry {
                 edges = (List<Map<String, Object>>) deserializationContext.readValue(jsonParser, ArrayList.class);
             } else {
                 final Map<String, Object> graphData = deserializationContext.readValue(jsonParser, HashMap.class);
-                vertices = (List<Map<String,Object>>) graphData.get("vertices");
-                edges = (List<Map<String,Object>>) graphData.get("edges");
+                vertices = (List<Map<String,Object>>) graphData.get(GraphSONTokens.VERTICES);
+                edges = (List<Map<String,Object>>) graphData.get(GraphSONTokens.EDGES);
             }
 
             for (Map<String, Object> vertexData : vertices) {


[6/7] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/TINKERPOP3-978'

Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/TINKERPOP3-978'

Conflicts:
	CHANGELOG.asciidoc
	tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java


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

Branch: refs/heads/master
Commit: 141b7e841147d335380e6d282e9d096baa8db961
Parents: 6af274b 8760761
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Nov 30 17:01:04 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Nov 30 17:01:04 2015 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   1 +
 .../structure/io/graphson/GraphSONReader.java   |   4 +-
 .../structure/io/graphson/GraphSONTokens.java   |   2 +
 .../structure/io/graphson/GraphSONUtil.java     |  10 +-
 .../structure/io/graphson/GraphSONWriter.java   |   2 +-
 gremlin-server/conf/gremlin-server-min.yaml     |   4 +-
 gremlin-server/conf/gremlin-server-neo4j.yaml   |   8 +-
 .../conf/gremlin-server-rest-modern.yaml        |   4 +-
 .../conf/gremlin-server-rest-secure.yaml        |   8 +-
 gremlin-server/conf/gremlin-server-secure.yaml  |   8 +-
 gremlin-server/conf/gremlin-server-spark.yaml   |   8 +-
 gremlin-server/conf/gremlin-server.yaml         |   8 +-
 .../server/GremlinResultSetIntegrateTest.java   |  25 ++-
 .../server/GremlinServerHttpIntegrateTest.java  |  24 +++
 .../server/gremlin-server-integration.yaml      |   4 +-
 .../tinkergraph/structure/TinkerIoRegistry.java | 176 ++++++++++++++++++-
 .../TinkerGraphGryoSerializerTest.java          |  81 +++++++++
 .../structure/TinkerGraphSerializerTest.java    |  81 ---------
 .../tinkergraph/structure/TinkerGraphTest.java  |  34 ++++
 19 files changed, 375 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/141b7e84/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 7473fb7,0ccb1d7..a6acdd6
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -26,11 -26,7 +26,12 @@@ image::https://raw.githubusercontent.co
  TinkerPop 3.1.1 (NOT OFFICIALLY RELEASED YET)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
+ * `TinkerGraph` has "native" serialization in GraphSON, which enables it to be a return value from Gremlin Server.
 +* Improved the ability to embed Gremlin Server by providing a way to get the `ServerGremlinExecutor` and improve reusability of `AbstractEvalOpProcessor` and related classes.
 +* `ProfileStep` is now available off of `Traversal` via `profile()`. To be consistent with `Traversal.explain()`.
 +* If no comparator is provided to `order()`, `Order.incr` is assumed (previously, an exception occurred).
 +* Fixed various Gremlin-Groovy tests that assumed `toString()`-able ids.
 +* Split TinkerPop documentation into different directories.
  * Added `explain()`-step which yields a `TraversalExplanation` with a pretty `toString()` detailing the compilation process.
  * Fixed a traversal strategy ordering bug in `AdjacentToIncidentStrategy` and `IncidentToAdjacentStrategy`.
  * Made a number of changes to improve traversal startup and execution performance.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/141b7e84/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
diff --cc tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index 7ff797b,d1bf381..1ddc909
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@@ -23,12 -23,16 +23,18 @@@ import org.apache.commons.configuration
  import org.apache.tinkerpop.gremlin.TestHelper;
  import org.apache.tinkerpop.gremlin.process.traversal.P;
  import org.apache.tinkerpop.gremlin.structure.Edge;
 +import org.apache.tinkerpop.gremlin.structure.Graph;
  import org.apache.tinkerpop.gremlin.structure.Vertex;
 +import org.apache.tinkerpop.gremlin.structure.io.Io;
+ import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+ import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
  import org.apache.tinkerpop.gremlin.structure.io.IoCore;
 +import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
  import org.apache.tinkerpop.gremlin.structure.io.IoTest;
+ import org.apache.tinkerpop.gremlin.structure.io.Mapper;
+ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
+ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
+ import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
  import org.junit.Ignore;
  import org.junit.Test;
  


[2/7] incubator-tinkerpop git commit: Add GraphSON related tests over REST for serializing TinkerGraph.

Posted by sp...@apache.org.
Add GraphSON related tests over REST for serializing TinkerGraph.


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

Branch: refs/heads/master
Commit: ea6871ffa9b4054f628f3b5fcee02c25b14b365a
Parents: e90c49f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Nov 19 19:00:05 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Nov 19 19:00:05 2015 -0500

----------------------------------------------------------------------
 .../server/GremlinServerHttpIntegrateTest.java  | 24 ++++++++++++++++++++
 .../server/gremlin-server-integration.yaml      |  4 ++--
 2 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ea6871ff/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
index f46f022..c0f37f2 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
@@ -37,6 +37,7 @@ import java.io.File;
 import java.util.Arrays;
 import java.util.Base64;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import static org.junit.Assert.assertEquals;
@@ -423,6 +424,29 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
     }
 
     @Test
+    public void should200OnPOSTWithGremlinJsonEndcodedBodyWithTinkerGraphResult() throws Exception {
+        final CloseableHttpClient httpclient = HttpClients.createDefault();
+        final HttpPost httppost = new HttpPost("http://localhost:8182");
+        httppost.addHeader("Content-Type", "application/json");
+        httppost.setEntity(new StringEntity("{\"gremlin\":\"org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory.createModern()\"}", Consts.UTF_8));
+
+        try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
+            assertEquals(200, response.getStatusLine().getStatusCode());
+            assertEquals("application/json", response.getEntity().getContentType().getValue());
+            final String json = EntityUtils.toString(response.getEntity());
+            final JsonNode resultJson = mapper.readTree(json);
+            final JsonNode data = resultJson.get("result").get("data");
+            assertEquals(1, data.size());
+
+            final List<JsonNode> vertices = data.get(0).findValues(GraphSONTokens.VERTICES);
+            final List<JsonNode> edges = data.get(0).findValues(GraphSONTokens.EDGES);
+
+            assertEquals(6, vertices.get(0).size());
+            assertEquals(6, edges.get(0).size());
+        }
+    }
+
+    @Test
     public void should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResultAndAliases() throws Exception {
         // we can remove this first test when rebindings are completely removed
         final CloseableHttpClient httpclientLegacy = HttpClients.createDefault();

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ea6871ff/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
index 7b6e5c2..1a57a15 100644
--- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
+++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
@@ -36,8 +36,8 @@ scriptEngines: {
 serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph, 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.GraphSONMessageSerializerGremlinV1d0 }
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 }
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }}
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}
 processors:
   - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
 metrics: {


[4/7] incubator-tinkerpop git commit: Added useMapperFromGraph config to all config files.

Posted by sp...@apache.org.
Added useMapperFromGraph config to all config files.

Fixed other minor inconsistencies as well.


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

Branch: refs/heads/master
Commit: 820297ef8b4cc8222829436fc646a3e76995c724
Parents: cfe6e1a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Nov 30 06:40:20 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Nov 30 06:40:20 2015 -0500

----------------------------------------------------------------------
 gremlin-server/conf/gremlin-server-min.yaml         | 4 ++--
 gremlin-server/conf/gremlin-server-neo4j.yaml       | 8 ++++----
 gremlin-server/conf/gremlin-server-rest-modern.yaml | 4 ++--
 gremlin-server/conf/gremlin-server-rest-secure.yaml | 8 ++++----
 gremlin-server/conf/gremlin-server-secure.yaml      | 8 ++++----
 gremlin-server/conf/gremlin-server-spark.yaml       | 8 ++++----
 gremlin-server/conf/gremlin-server.yaml             | 8 ++++----
 7 files changed, 24 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/820297ef/gremlin-server/conf/gremlin-server-min.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-min.yaml b/gremlin-server/conf/gremlin-server-min.yaml
index 7c410ae..a769c16 100644
--- a/gremlin-server/conf/gremlin-server-min.yaml
+++ b/gremlin-server/conf/gremlin-server-min.yaml
@@ -29,8 +29,8 @@ scriptEngines: {
   gremlin-groovy: {
     imports: []}}
 serializers:
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 }  # application/vnd.gremlin-v1.0+json
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 }         # application/json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }}  # application/vnd.gremlin-v1.0+json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}         # application/json
 metrics: {
   slf4jReporter: {enabled: true, interval: 180000}}
 threadPoolBoss: 1

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/820297ef/gremlin-server/conf/gremlin-server-neo4j.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-neo4j.yaml b/gremlin-server/conf/gremlin-server-neo4j.yaml
index aef5403..81f257d 100644
--- a/gremlin-server/conf/gremlin-server-neo4j.yaml
+++ b/gremlin-server/conf/gremlin-server-neo4j.yaml
@@ -45,10 +45,10 @@ scriptEngines: {
       imports: [java.lang.Math],
       staticImports: [java.lang.Math.PI]}}
 serializers:
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0 }                                             # application/vnd.gremlin-v1.0+gryo
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}   # application/vnd.gremlin-v1.0+gryo-stringd
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 }                                  # application/vnd.gremlin-v1.0+json
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 }                                         # application/json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}            # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}        # application/vnd.gremlin-v1.0+gryo-stringd
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/json
 processors:
   - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
 metrics: {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/820297ef/gremlin-server/conf/gremlin-server-rest-modern.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-rest-modern.yaml b/gremlin-server/conf/gremlin-server-rest-modern.yaml
index 7d57f38..c15c15f 100644
--- a/gremlin-server/conf/gremlin-server-rest-modern.yaml
+++ b/gremlin-server/conf/gremlin-server-rest-modern.yaml
@@ -32,8 +32,8 @@ scriptEngines: {
     staticImports: [java.lang.Math.PI],
     scripts: [scripts/generate-modern.groovy]}}
 serializers:
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 }  # application/vnd.gremlin-v1.0+json
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 }         # application/json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }}  # application/vnd.gremlin-v1.0+json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}         # application/json
 metrics: {
   slf4jReporter: {enabled: true, interval: 180000}}
 threadPoolBoss: 1

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/820297ef/gremlin-server/conf/gremlin-server-rest-secure.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-rest-secure.yaml b/gremlin-server/conf/gremlin-server-rest-secure.yaml
index de1e674..e0c53cf 100644
--- a/gremlin-server/conf/gremlin-server-rest-secure.yaml
+++ b/gremlin-server/conf/gremlin-server-rest-secure.yaml
@@ -45,10 +45,10 @@ scriptEngines: {
               "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider":[10000],
               "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider":["org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension"]}}}}
 serializers:
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0 }                                             # application/vnd.gremlin-v1.0+gryo
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}   # application/vnd.gremlin-v1.0+gryo-stringd
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 }                                  # application/vnd.gremlin-v1.0+json
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 }                                         # application/json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}            # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}        # application/vnd.gremlin-v1.0+gryo-stringd
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/json
 processors:
   - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
 metrics: {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/820297ef/gremlin-server/conf/gremlin-server-secure.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-secure.yaml b/gremlin-server/conf/gremlin-server-secure.yaml
index 20ae461..b993cc4 100644
--- a/gremlin-server/conf/gremlin-server-secure.yaml
+++ b/gremlin-server/conf/gremlin-server-secure.yaml
@@ -45,10 +45,10 @@ scriptEngines: {
               "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider":[10000],
               "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider":["org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension"]}}}}
 serializers:
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}       # application/vnd.gremlin-v1.0+gryo
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}   # application/vnd.gremlin-v1.0+gryo-stringd
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 }                                  # application/vnd.gremlin-v1.0+json
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 }                                         # application/json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}            # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}        # application/vnd.gremlin-v1.0+gryo-stringd
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/json
 processors:
   - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
 metrics: {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/820297ef/gremlin-server/conf/gremlin-server-spark.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-spark.yaml b/gremlin-server/conf/gremlin-server-spark.yaml
index 1bba5cf..32626a4 100644
--- a/gremlin-server/conf/gremlin-server-spark.yaml
+++ b/gremlin-server/conf/gremlin-server-spark.yaml
@@ -58,10 +58,10 @@ scriptEngines: {
       imports: [java.lang.Math],
       staticImports: [java.lang.Math.PI]}}
 serializers:
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}       # application/vnd.gremlin-v1.0+gryo
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}   # application/vnd.gremlin-v1.0+gryo-stringd
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 }                                  # application/vnd.gremlin-v1.0+json
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 }                                         # application/json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}            # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}        # application/vnd.gremlin-v1.0+gryo-stringd
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/json
 processors:
   - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
 metrics: {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/820297ef/gremlin-server/conf/gremlin-server.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server.yaml b/gremlin-server/conf/gremlin-server.yaml
index 7899b56..b0cfaa0 100644
--- a/gremlin-server/conf/gremlin-server.yaml
+++ b/gremlin-server/conf/gremlin-server.yaml
@@ -35,10 +35,10 @@ scriptEngines: {
       imports: [java.lang.Math],
       staticImports: [java.lang.Math.PI]}}
 serializers:
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}       # application/vnd.gremlin-v1.0+gryo
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}   # application/vnd.gremlin-v1.0+gryo-stringd
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 }                                  # application/vnd.gremlin-v1.0+json
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 }                                         # application/json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}            # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}        # application/vnd.gremlin-v1.0+gryo-stringd
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/json
 processors:
   - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
 metrics: {


[7/7] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/master'

Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/master'


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

Branch: refs/heads/master
Commit: e14019b34f15eae60c242a3205893b7dfbc53bbf
Parents: 141b7e8 4fb3844
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Nov 30 17:01:29 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Nov 30 17:01:29 2015 -0500

----------------------------------------------------------------------
 .../gremlin/groovy/loaders/SugarLoaderPerformanceTest.groovy | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------



[3/7] incubator-tinkerpop git commit: Update changelog.

Posted by sp...@apache.org.
Update changelog.


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

Branch: refs/heads/master
Commit: cfe6e1af3d99aff2e92090dc3ed5431975939a45
Parents: ea6871f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Nov 19 19:02:20 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Nov 19 19:02:20 2015 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/cfe6e1af/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 5f3018a..0ccb1d7 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.1.1 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* `TinkerGraph` has "native" serialization in GraphSON, which enables it to be a return value from Gremlin Server.
 * Added `explain()`-step which yields a `TraversalExplanation` with a pretty `toString()` detailing the compilation process.
 * Fixed a traversal strategy ordering bug in `AdjacentToIncidentStrategy` and `IncidentToAdjacentStrategy`.
 * Made a number of changes to improve traversal startup and execution performance.