tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject tinkerpop git commit: TINKERPOP-1427 Migrate GraphSON v2 performance enhancement to v3
Date Sat, 01 Jul 2017 19:10:06 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1427 90f5ee331 -> 70dcc15e4


TINKERPOP-1427 Migrate GraphSON v2 performance enhancement to v3

This was for TinkerGraph whole graph serialization.


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

Branch: refs/heads/TINKERPOP-1427
Commit: 70dcc15e407fcb082a795b4b75f35bdfe62f0370
Parents: 90f5ee3
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Sat Jul 1 15:08:53 2017 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Sat Jul 1 15:08:53 2017 -0400

----------------------------------------------------------------------
 .../structure/TinkerIoRegistryV3d0.java         | 38 +++++++++-----------
 1 file changed, 17 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/70dcc15e/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV3d0.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV3d0.java
b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV3d0.java
index c2eebf9..c6ff44f 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV3d0.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV3d0.java
@@ -36,6 +36,7 @@ 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.core.JsonToken;
 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;
@@ -50,8 +51,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -191,26 +190,23 @@ public final class TinkerIoRegistryV3d0 extends AbstractIoRegistry {
             conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
             final TinkerGraph graph = TinkerGraph.open(conf);
 
-            final List<? extends Edge> edges;
-            final List<? extends Vertex> vertices;
-
-            jsonParser.nextToken();
-            final Map<String, Object> graphData = deserializationContext.readValue(jsonParser,
LinkedHashMap.class);
-            vertices = (List<DetachedVertex>) graphData.get(GraphSONTokens.VERTICES);
-            edges = (List<DetachedEdge>) graphData.get(GraphSONTokens.EDGES);
-
-
-            vertices.forEach(e -> {
-                if (e instanceof DetachedVertex) {
-                    ((DetachedVertex)e).attach(Attachable.Method.getOrCreate(graph));
+            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
+                if (jsonParser.getCurrentName().equals("vertices")) {
+                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
+                        if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
+                            final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser,
Vertex.class);
+                            v.attach(Attachable.Method.getOrCreate(graph));
+                        }
+                    }
+                } else if (jsonParser.getCurrentName().equals("edges")) {
+                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
+                        if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
+                            final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser,
Edge.class);
+                            e.attach(Attachable.Method.getOrCreate(graph));
+                        }
+                    }
                 }
-            });
-
-            edges.forEach(e -> {
-                if (e instanceof DetachedEdge) {
-                    ((DetachedEdge) e).attach(Attachable.Method.getOrCreate(graph));
-                }
-            });
+            }
 
             return graph;
         }


Mime
View raw message