You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/04/22 19:54:16 UTC

incubator-tinkerpop git commit: Added StarGraphSerializer which yields a 2-4x reduction in size of an adjacency list representation of vertex over DetachedVertex.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 1c5c2fb58 -> 08d11f686


Added StarGraphSerializer which yields a 2-4x reduction in size of an adjacency list representation of vertex over DetachedVertex.


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

Branch: refs/heads/master
Commit: 08d11f686b8e8888961aec5f626d2747600b7334
Parents: 1c5c2fb
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Apr 22 11:53:44 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Apr 22 11:54:12 2015 -0600

----------------------------------------------------------------------
 .../gremlin/structure/io/gryo/GryoMapper.java   |   3 +-
 .../gremlin/structure/util/star/StarGraph.java  |  14 +-
 .../util/star/StarGraphSerializer.java          | 136 +++++++++++++++++
 .../structure/util/star/StarGraphTest.java      | 152 ++++++++++---------
 .../tinkergraph/structure/TinkerGraphTest.java  |  55 +++++++
 5 files changed, 279 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/08d11f68/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
index 07417b2..e0a18cd 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
@@ -51,6 +51,7 @@ import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty;
 import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
+import org.apache.tinkerpop.gremlin.structure.util.star.StarGraphSerializer;
 import org.apache.tinkerpop.shaded.kryo.Kryo;
 import org.apache.tinkerpop.shaded.kryo.KryoSerializable;
 import org.apache.tinkerpop.shaded.kryo.Serializer;
@@ -197,7 +198,7 @@ public final class GryoMapper implements Mapper<Kryo> {
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(ReferenceVertex.class, null, 84));
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(ReferencePath.class, null, 85));
 
-            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(StarGraph.class, null, 86)); // ***LAST ID**
+            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(StarGraph.class, kryo -> StarGraphSerializer.instance(), 86)); // ***LAST ID**
 
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Edge.class, kryo -> new GraphSerializer.EdgeSerializer(), 65));
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Vertex.class, kryo -> new GraphSerializer.VertexSerializer(), 66));

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/08d11f68/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
index 772114a..ad745d3 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
@@ -58,11 +58,11 @@ public final class StarGraph implements Graph, Serializable {
         STAR_GRAPH_CONFIGURATION.setProperty(Graph.GRAPH, StarGraph.class.getCanonicalName());
     }
 
-    private Long nextId = 0l;
+    protected Long nextId = 0l;
 
-    private StarVertex starVertex = null;
-    private Map<Object, Map<String, Object>> edgeProperties = null;
-    private Map<Object, Map<String, Object>> metaProperties = null;
+    protected StarVertex starVertex = null;
+    protected Map<Object, Map<String, Object>> edgeProperties = null;
+    protected Map<Object, Map<String, Object>> metaProperties = null;
 
     private StarGraph() {
     }
@@ -237,9 +237,9 @@ public final class StarGraph implements Graph, Serializable {
 
     public final class StarVertex extends StarElement implements Vertex {
 
-        private Map<String, List<Edge>> outEdges = null;
-        private Map<String, List<Edge>> inEdges = null;
-        private Map<String, List<VertexProperty>> vertexProperties = null;
+        protected Map<String, List<Edge>> outEdges = null;
+        protected Map<String, List<Edge>> inEdges = null;
+        protected Map<String, List<VertexProperty>> vertexProperties = null;
 
         public StarVertex(final Object id, final String label) {
             super(id, label);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/08d11f68/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphSerializer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphSerializer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphSerializer.java
new file mode 100644
index 0000000..84d392c
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphSerializer.java
@@ -0,0 +1,136 @@
+/*
+ *
+ *  * 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.structure.util.star;
+
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+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 java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class StarGraphSerializer extends Serializer<StarGraph> {
+
+    private static StarGraphSerializer INSTANCE = new StarGraphSerializer();
+
+    private StarGraphSerializer() {
+
+    }
+
+    @Override
+    public void write(final Kryo kryo, final Output output, final StarGraph starGraph) {
+        kryo.writeObject(output, starGraph.nextId);
+        kryo.writeObjectOrNull(output, starGraph.edgeProperties, HashMap.class);
+        kryo.writeObjectOrNull(output, starGraph.metaProperties, HashMap.class);
+        kryo.writeClassAndObject(output, starGraph.starVertex.id());
+        kryo.writeObject(output, starGraph.starVertex.label());
+        writeEdges(kryo, output, starGraph.starVertex.inEdges, Direction.IN);
+        writeEdges(kryo, output, starGraph.starVertex.outEdges, Direction.OUT);
+        kryo.writeObject(output, null != starGraph.starVertex.vertexProperties);
+        if (null != starGraph.starVertex.vertexProperties) {
+            kryo.writeObject(output, starGraph.starVertex.vertexProperties.size());
+            for (final Map.Entry<String, List<VertexProperty>> vertexProperties : starGraph.starVertex.vertexProperties.entrySet()) {
+                kryo.writeObject(output, vertexProperties.getKey());
+                kryo.writeObject(output, vertexProperties.getValue().size());
+                for (final VertexProperty vertexProperty : vertexProperties.getValue()) {
+                    kryo.writeClassAndObject(output, vertexProperty.id());
+                    kryo.writeClassAndObject(output, vertexProperty.value());
+                }
+            }
+        }
+    }
+
+    @Override
+    public StarGraph read(final Kryo kryo, final Input input, final Class<StarGraph> aClass) {
+        StarGraph starGraph = StarGraph.open();
+        starGraph.nextId = kryo.readObject(input, Long.class);
+        starGraph.edgeProperties = kryo.readObjectOrNull(input, HashMap.class);
+        starGraph.metaProperties = kryo.readObjectOrNull(input, HashMap.class);
+        final Object starVertexId = kryo.readClassAndObject(input);
+        final String starVertexLabel = kryo.readObject(input, String.class);
+        starGraph.addVertex(T.id, starVertexId, T.label, starVertexLabel);
+        readEdges(kryo, input, starGraph, Direction.IN);
+        readEdges(kryo, input, starGraph, Direction.OUT);
+        if (kryo.readObject(input, Boolean.class)) {
+            final int labelSize = kryo.readObject(input, Integer.class);
+            for (int i = 0; i < labelSize; i++) {
+                final String key = kryo.readObject(input, String.class);
+                final int vertexPropertySize = kryo.readObject(input, Integer.class);
+                for (int j = 0; j < vertexPropertySize; j++) {
+                    final Object id = kryo.readClassAndObject(input);
+                    final Object value = kryo.readClassAndObject(input);
+                    starGraph.starVertex.property(VertexProperty.Cardinality.list, key, value, T.id, id);
+                }
+            }
+        }
+        return starGraph;
+    }
+
+    //////
+
+    private static void writeEdges(final Kryo kryo, final Output output, final Map<String, List<Edge>> starEdges, final Direction direction) {
+        kryo.writeObject(output, null != starEdges);
+        if (null != starEdges) {
+            kryo.writeObject(output, starEdges.size());
+            for (final Map.Entry<String, List<Edge>> edges : starEdges.entrySet()) {
+                kryo.writeObject(output, edges.getKey());
+                kryo.writeObject(output, edges.getValue().size());
+                for (final Edge edge : edges.getValue()) {
+                    kryo.writeClassAndObject(output, edge.id());
+                    kryo.writeClassAndObject(output, direction.equals(Direction.OUT) ? edge.inVertex().id() : edge.outVertex().id());
+                }
+            }
+        }
+    }
+
+    private static void readEdges(final Kryo kryo, final Input input, final StarGraph starGraph, final Direction direction) {
+        final boolean hasEdges = kryo.readObject(input, Boolean.class);
+        if (hasEdges) {
+            final int labelSize = kryo.readObject(input, Integer.class);
+            for (int i = 0; i < labelSize; i++) {
+                final String label = kryo.readObject(input, String.class);
+                final int edgeSize = kryo.readObject(input, Integer.class);
+                for (int j = 0; j < edgeSize; j++) {
+                    final Object edgeId = kryo.readClassAndObject(input);
+                    final Object otherVertexId = kryo.readClassAndObject(input);
+                    if (direction.equals(Direction.OUT))
+                        starGraph.starVertex.addOutEdge(label, starGraph.addVertex(T.id, otherVertexId), T.id, edgeId);
+                    else
+                        starGraph.starVertex.addInEdge(label, starGraph.addVertex(T.id, otherVertexId), T.id, edgeId);
+                }
+            }
+        }
+    }
+
+    public static StarGraphSerializer instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/08d11f68/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
index c9db32d..4afa16c 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
@@ -26,10 +26,13 @@ import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Test;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -57,115 +60,118 @@ public class StarGraphTest extends AbstractGremlinTest {
         assertEquals(1, set.size());
     }
 
-
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.CREW)
     public void originalAndStarVerticesShouldHaveTheSameTopology() {
-        final Vertex gremlin = g.V(convertToVertexId("gremlin")).next();
-        final StarGraph starGraph = StarGraph.of(gremlin);
-        final StarGraph.StarVertex gremlinStar = starGraph.getStarVertex();
-        assertEquals(gremlin, gremlinStar);
-        assertEquals(gremlinStar, gremlin);
-        assertEquals(gremlinStar.id(), gremlin.id());
-        assertEquals(gremlinStar.label(), gremlin.label());
-        ///
-        gremlin.properties().forEachRemaining(vp -> {
-            assertEquals(vp, gremlinStar.property(vp.key()));
-            assertEquals(vp.id(), gremlinStar.property(vp.key()).id());
-            assertEquals(vp.value(), gremlinStar.property(vp.key()).value());
-
-        });
-        //
-        List<Edge> originalEdges = new ArrayList<>(IteratorUtils.set(gremlin.edges(Direction.OUT)));
-        List<Edge> starEdges = new ArrayList<>(IteratorUtils.set(gremlinStar.edges(Direction.OUT)));
-        assertEquals(originalEdges.size(), starEdges.size());
-        assertEquals(1,originalEdges.size());
-        for (int i = 0; i < starEdges.size(); i++) {
-            final Edge starEdge = starEdges.get(i);
-            final Edge originalEdge = originalEdges.get(i);
-            assertEquals(starEdge, originalEdge);
-            assertEquals(starEdge.id(), originalEdge.id());
-            assertEquals(starEdge.label(), originalEdge.label());
-            assertEquals(starEdge.inVertex(), originalEdge.inVertex());
-            assertEquals(starEdge.outVertex(), originalEdge.outVertex());
-            originalEdge.properties().forEachRemaining(p -> assertEquals(p, starEdge.property(p.key())));
-            starEdge.properties().forEachRemaining(p -> assertEquals(p, originalEdge.property(p.key())));
-        }
-
-        originalEdges = new ArrayList<>(IteratorUtils.set(gremlin.edges(Direction.IN)));
-        starEdges = new ArrayList<>(IteratorUtils.set(gremlinStar.edges(Direction.IN)));
-        assertEquals(7,starEdges.size());
-        assertEquals(originalEdges.size(), starEdges.size());
-        for (int i = 0; i < starEdges.size(); i++) {
-            final Edge starEdge = starEdges.get(i);
-            final Edge originalEdge = originalEdges.get(i);
-            assertEquals(starEdge, originalEdge);
-            assertEquals(starEdge.id(), originalEdge.id());
-            assertEquals(starEdge.label(), originalEdge.label());
-            assertEquals(starEdge.inVertex(), originalEdge.inVertex());
-            assertEquals(starEdge.outVertex(), originalEdge.outVertex());
-            originalEdge.properties().forEachRemaining(p -> assertEquals(p, starEdge.property(p.key())));
-            starEdge.properties().forEachRemaining(p -> assertEquals(p, originalEdge.property(p.key())));
-        }
+        g.V().forEachRemaining(vertex -> validateVertex(vertex, StarGraph.of(vertex).getStarVertex()));
     }
 
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.CREW)
-    public void originalAndStarVerticesShouldHaveSameMetaProperties() {
-        final Vertex matthias = g.V(convertToVertexId("matthias")).next();
-        final StarGraph starGraph = StarGraph.of(matthias);
-        final StarGraph.StarVertex matthiasStar = starGraph.getStarVertex();
-        final AtomicInteger originalCounter = new AtomicInteger(0);
+    public void shouldSerializeCorrectlyUsingGryo() {
+        g.V().forEachRemaining(vertex -> {
+            StarGraph starGraph = StarGraph.of(vertex);
+            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+            GryoWriter.build().create().writeObject(outputStream, starGraph);
+            starGraph = GryoReader.build().create().readObject(new ByteArrayInputStream(outputStream.toByteArray()));
+            validateVertex(vertex, starGraph.getStarVertex());
+        });
+    }
+
+    private void validateVertex(final Vertex originalVertex, final StarGraph.StarVertex starVertex) {
+        ////////////////  VALIDATE PROPERTIES
         final AtomicInteger originalPropertyCounter = new AtomicInteger(0);
-        final AtomicInteger starCounter = new AtomicInteger(0);
-        matthias.properties().forEachRemaining(vertexProperty -> {
-            originalCounter.incrementAndGet();
-            matthiasStar.properties(vertexProperty.label()).forEachRemaining(starVertexProperty -> {
+        final AtomicInteger originalMetaPropertyCounter = new AtomicInteger(0);
+        final AtomicInteger starPropertyCounter = new AtomicInteger(0);
+        final AtomicInteger starMetaPropertyCounter = new AtomicInteger(0);
+
+        originalVertex.properties().forEachRemaining(vertexProperty -> {
+            originalPropertyCounter.incrementAndGet();
+            starVertex.properties(vertexProperty.label()).forEachRemaining(starVertexProperty -> {
                 if (starVertexProperty.equals(vertexProperty)) {
+                    starPropertyCounter.incrementAndGet();
                     assertEquals(starVertexProperty.id(), vertexProperty.id());
                     assertEquals(starVertexProperty.label(), vertexProperty.label());
                     assertEquals(starVertexProperty.value(), vertexProperty.value());
                     assertEquals(starVertexProperty.key(), vertexProperty.key());
                     assertEquals(starVertexProperty.element(), vertexProperty.element());
-                    starCounter.incrementAndGet();
+                    //
                     vertexProperty.properties().forEachRemaining(p -> {
-                        originalPropertyCounter.incrementAndGet();
+                        originalMetaPropertyCounter.incrementAndGet();
                         assertEquals(p.value(), starVertexProperty.property(p.key()).value());
                         assertEquals(p.key(), starVertexProperty.property(p.key()).key());
                         assertEquals(p.element(), starVertexProperty.property(p.key()).element());
                     });
+                    starVertexProperty.properties().forEachRemaining(p -> starMetaPropertyCounter.incrementAndGet());
                 }
             });
         });
-        assertEquals(5, originalCounter.get());
-        assertEquals(5, starCounter.get());
-        assertEquals(7, originalPropertyCounter.get());
 
-        originalCounter.set(0);
-        starCounter.set(0);
-        originalPropertyCounter.set(0);
+        assertEquals(originalPropertyCounter.get(), starPropertyCounter.get());
+        assertEquals(originalMetaPropertyCounter.get(), starMetaPropertyCounter.get());
 
-        matthiasStar.properties().forEachRemaining(starVertexProperty -> {
-            starCounter.incrementAndGet();
-            matthias.properties(starVertexProperty.label()).forEachRemaining(vertexProperty -> {
+        originalPropertyCounter.set(0);
+        starPropertyCounter.set(0);
+        originalMetaPropertyCounter.set(0);
+        starMetaPropertyCounter.set(0);
+        //
+        starVertex.properties().forEachRemaining(starVertexProperty -> {
+            starPropertyCounter.incrementAndGet();
+            originalVertex.properties(starVertexProperty.label()).forEachRemaining(vertexProperty -> {
                 if (starVertexProperty.equals(vertexProperty)) {
+                    originalPropertyCounter.incrementAndGet();
                     assertEquals(vertexProperty.id(), starVertexProperty.id());
                     assertEquals(vertexProperty.label(), starVertexProperty.label());
                     assertEquals(vertexProperty.value(), starVertexProperty.value());
                     assertEquals(vertexProperty.key(), starVertexProperty.key());
                     assertEquals(vertexProperty.element(), starVertexProperty.element());
-                    originalCounter.incrementAndGet();
                     starVertexProperty.properties().forEachRemaining(p -> {
-                        originalPropertyCounter.incrementAndGet();
+                        starMetaPropertyCounter.incrementAndGet();
                         assertEquals(p.value(), vertexProperty.property(p.key()).value());
                         assertEquals(p.key(), vertexProperty.property(p.key()).key());
                         assertEquals(p.element(), vertexProperty.property(p.key()).element());
                     });
+                    vertexProperty.properties().forEachRemaining(p -> originalMetaPropertyCounter.incrementAndGet());
                 }
             });
         });
-        assertEquals(5, originalCounter.get());
-        assertEquals(5, starCounter.get());
-        assertEquals(7, originalPropertyCounter.get());
+        assertEquals(originalPropertyCounter.get(), starPropertyCounter.get());
+        assertEquals(originalMetaPropertyCounter.get(),starMetaPropertyCounter.get());
+
+        ////////////////  VALIDATE EDGES
+        assertEquals(originalVertex, starVertex);
+        assertEquals(starVertex, originalVertex);
+        assertEquals(starVertex.id(), originalVertex.id());
+        assertEquals(starVertex.label(), originalVertex.label());
+        ///
+        List<Edge> originalEdges = new ArrayList<>(IteratorUtils.set(originalVertex.edges(Direction.OUT)));
+        List<Edge> starEdges = new ArrayList<>(IteratorUtils.set(starVertex.edges(Direction.OUT)));
+        assertEquals(originalEdges.size(), starEdges.size());
+        for (int i = 0; i < starEdges.size(); i++) {
+            final Edge starEdge = starEdges.get(i);
+            final Edge originalEdge = originalEdges.get(i);
+            assertEquals(starEdge, originalEdge);
+            assertEquals(starEdge.id(), originalEdge.id());
+            assertEquals(starEdge.label(), originalEdge.label());
+            assertEquals(starEdge.inVertex(), originalEdge.inVertex());
+            assertEquals(starEdge.outVertex(), originalEdge.outVertex());
+            originalEdge.properties().forEachRemaining(p -> assertEquals(p, starEdge.property(p.key())));
+            starEdge.properties().forEachRemaining(p -> assertEquals(p, originalEdge.property(p.key())));
+        }
+
+        originalEdges = new ArrayList<>(IteratorUtils.set(originalVertex.edges(Direction.IN)));
+        starEdges = new ArrayList<>(IteratorUtils.set(starVertex.edges(Direction.IN)));
+        assertEquals(originalEdges.size(), starEdges.size());
+        for (int i = 0; i < starEdges.size(); i++) {
+            final Edge starEdge = starEdges.get(i);
+            final Edge originalEdge = originalEdges.get(i);
+            assertEquals(starEdge, originalEdge);
+            assertEquals(starEdge.id(), originalEdge.id());
+            assertEquals(starEdge.label(), originalEdge.label());
+            assertEquals(starEdge.inVertex(), originalEdge.inVertex());
+            assertEquals(starEdge.outVertex(), originalEdge.outVertex());
+            originalEdge.properties().forEachRemaining(p -> assertEquals(p, starEdge.property(p.key())));
+            starEdge.properties().forEachRemaining(p -> assertEquals(p, originalEdge.property(p.key())));
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/08d11f68/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 e8dd072..b12769e 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
@@ -38,10 +38,13 @@ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
 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.star.StarGraph;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -49,6 +52,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Random;
 import java.util.Set;
 import java.util.function.Supplier;
 import java.util.stream.IntStream;
@@ -174,6 +178,57 @@ public class TinkerGraphTest {
 
     @Test
     @Ignore
+    public void testPlay5() throws Exception {
+        Graph graph = TinkerGraph.open();
+        final Random random = new Random();
+        final Vertex vertex = graph.addVertex("person");
+        System.out.println(randomString(4));
+        for(int i=0;i<100000;i++) {
+            vertex.addEdge("knows",graph.addVertex("person"),"since",random.nextLong(),"created","blah");
+        }
+        StarGraph starGraph = StarGraph.of(vertex);
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        GryoWriter.build().create().writeObject(outputStream, starGraph);
+        outputStream.flush();
+        System.out.println("Size of star graph (1): " + outputStream.size());
+        ///
+        starGraph = GryoReader.build().create().readObject(new ByteArrayInputStream(outputStream.toByteArray()));
+        outputStream = new ByteArrayOutputStream();
+        GryoWriter.build().create().writeObject(outputStream, starGraph);
+        outputStream.flush();
+        System.out.println("Size of star graph (2): " + outputStream.size());
+        //
+        starGraph = GryoReader.build().create().readObject(new ByteArrayInputStream(outputStream.toByteArray()));
+        outputStream = new ByteArrayOutputStream();
+        GryoWriter.build().create().writeObject(outputStream, starGraph);
+        outputStream.flush();
+        System.out.println("Size of star graph (3): " + outputStream.size());
+
+       //starGraph.getStarVertex().edges(Direction.OUT).forEachRemaining(System.out::println);
+
+        /////////
+
+        outputStream = new ByteArrayOutputStream();
+        GryoWriter.build().create().writeVertex(outputStream, vertex, Direction.BOTH);
+        outputStream.flush();
+        System.out.println("Size of detached vertex (1): " + outputStream.size());
+
+
+
+    }
+
+    private String randomString(final int length) {
+        Random random = new Random();
+        String randomString = new String();
+        for(int i =0;i<length;i++) {
+            final String temp =  String.valueOf((char) random.nextInt());
+            randomString = randomString + (temp.equals("~") ? "a" : temp);
+        }
+        return randomString;
+    }
+
+    @Test
+    @Ignore
     public void testPlayDK() throws Exception {
         GraphTraversalSource g = TinkerFactory.createModern().traversal();
         Traversal t = g.V().hasLabel("person").as("person").local(bothE().label().groupCount("x").cap("x")).as("relations").select().by("name").by();