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/04/23 22:23:08 UTC

[2/2] incubator-tinkerpop git commit: Changed the GraphReader readVertex API to take Function, V>.

Changed the GraphReader readVertex API to take Function<Attachable<V>, V>.


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

Branch: refs/heads/refactor-io
Commit: 39868a859c2b7fbf319c9384600b0526a1cbf9a4
Parents: 2432374
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 23 16:22:15 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Apr 23 16:22:15 2015 -0400

----------------------------------------------------------------------
 .../gremlin/structure/io/GraphReader.java       |  10 +-
 .../structure/io/graphml/GraphMLReader.java     |  12 +-
 .../structure/io/graphson/GraphSONReader.java   |  22 ++--
 .../io/graphson/LegacyGraphSONReader.java       |  10 +-
 .../gremlin/structure/io/gryo/GryoReader.java   |  14 +--
 .../structure/io/gryo/GryoReaderWriterTest.java |   7 +-
 .../tinkerpop/gremlin/structure/IoTest.java     | 111 ++++++++++++-------
 .../io/graphson/GraphSONRecordReader.java       |   4 +-
 .../structure/io/gryo/GryoRecordReader.java     |   4 +-
 9 files changed, 113 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/39868a85/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphReader.java
index 4f3e913..1d28030 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphReader.java
@@ -55,7 +55,7 @@ public interface GraphReader {
      * @param vertexMaker a function to create a vertex where the first argument is the vertex identifier, the
      *                    second argument is vertex label and the last is the list of properties for it
      */
-    public Vertex readVertex(final InputStream inputStream, final Function<DetachedVertex, Vertex> vertexMaker) throws IOException;
+    public Vertex readVertex(final InputStream inputStream, final Function<Attachable<Vertex>, Vertex> vertexMaker) throws IOException;
 
     /**
      * Reads a single vertex from an {@link InputStream}.  This method will read vertex properties as well as edges
@@ -70,8 +70,8 @@ public interface GraphReader {
      *                    the fourth is the label, and the fifth is the list of properties as key/value pairs.
      */
     public Vertex readVertex(final InputStream inputStream, final Direction direction,
-                             final Function<DetachedVertex, Vertex> vertexMaker,
-                             final Function<DetachedEdge, Edge> edgeMaker) throws IOException;
+                             final Function<Attachable<Vertex>, Vertex> vertexMaker,
+                             final Function<Attachable<Edge>, Edge> edgeMaker) throws IOException;
 
     /**
      * Reads a set of vertices from an {@link InputStream} which were written by
@@ -87,8 +87,8 @@ public interface GraphReader {
      *                    the fourth is the label, and the fifth is the list of properties as key/value pairs.
      */
     public Iterator<Vertex> readVertices(final InputStream inputStream, final Direction direction,
-                                         final Function<DetachedVertex, Vertex> vertexMaker,
-                                         final Function<DetachedEdge, Edge> edgeMaker) throws IOException;
+                                         final Function<Attachable<Vertex>, Vertex> vertexMaker,
+                                         final Function<Attachable<Edge>, Edge> edgeMaker) throws IOException;
 
     /**
      * Reads a single edge from an {@link InputStream}.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/39868a85/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
index ce54fc7..e28533f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
@@ -77,8 +77,8 @@ public class GraphMLReader implements GraphReader {
 
     @Override
     public Iterator<Vertex> readVertices(final InputStream inputStream, final Direction direction,
-                                         final Function<DetachedVertex, Vertex> vertexMaker,
-                                         final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
+                                         final Function<Attachable<Vertex>, Vertex> vertexMaker,
+                                         final Function<Attachable<Edge>, Edge> edgeMaker) throws IOException {
         throw Io.Exceptions.readerFormatIsForFullGraphSerializationOnly(this.getClass());
     }
 
@@ -88,18 +88,18 @@ public class GraphMLReader implements GraphReader {
     }
 
     @Override
-    public Vertex readVertex(final InputStream inputStream, final Function<DetachedVertex, Vertex> vertexMaker) throws IOException {
+    public Vertex readVertex(final InputStream inputStream, final Function<Attachable<Vertex>, Vertex> vertexMaker) throws IOException {
         throw Io.Exceptions.readerFormatIsForFullGraphSerializationOnly(this.getClass());
     }
 
     @Override
-    public Vertex readVertex(final InputStream inputStream, final Direction direction, final Function<DetachedVertex, Vertex> vertexMaker,
-                             final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
+    public Vertex readVertex(final InputStream inputStream, final Direction direction, final Function<Attachable<Vertex>, Vertex> vertexMaker,
+                             final Function<Attachable<Edge>, Edge> edgeMaker) throws IOException {
         throw Io.Exceptions.readerFormatIsForFullGraphSerializationOnly(this.getClass());
     }
 
     @Override
-    public <C> C readObject(InputStream inputStream, Class<? extends C> clazz) throws IOException {
+    public <C> C readObject(final InputStream inputStream, final Class<? extends C> clazz) throws IOException {
         throw Io.Exceptions.readerFormatIsForFullGraphSerializationOnly(this.getClass());
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/39868a85/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 997db18..6ef75d7 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
@@ -108,7 +108,8 @@ public class GraphSONReader implements GraphReader {
                 } else if (fieldName.equals(GraphSONTokens.VERTICES)) {
                     while (parser.nextToken() != JsonToken.END_ARRAY) {
                         final Map<String, Object> vertexData = parser.readValueAs(mapTypeReference);
-                        readVertexData(vertexData, detachedVertex -> {
+                        readVertexData(vertexData, attachable -> {
+                            final Vertex detachedVertex = attachable.get();
                             final Iterator<Vertex> iterator = graph.vertices(detachedVertex.id());
                             final Vertex v = iterator.hasNext() ? iterator.next() : graph.addVertex(T.label, detachedVertex.label(), T.id, detachedVertex.id());
                             detachedVertex.properties().forEachRemaining(p -> createVertexProperty(graphToWriteTo, v, p));
@@ -118,7 +119,8 @@ public class GraphSONReader implements GraphReader {
                 } else if (fieldName.equals(GraphSONTokens.EDGES)) {
                     while (parser.nextToken() != JsonToken.END_ARRAY) {
                         final Map<String, Object> edgeData = parser.readValueAs(mapTypeReference);
-                        readEdgeData(edgeData, detachedEdge -> {
+                        readEdgeData(edgeData, attachable -> {
+                            final Edge detachedEdge = attachable.get();
                             final Vertex vOut = graph.vertices(detachedEdge.outVertex().id()).next();
                             final Vertex vIn = graph.vertices(detachedEdge.inVertex().id()).next();
                             // batchgraph checks for edge id support and uses it if possible.
@@ -139,8 +141,8 @@ public class GraphSONReader implements GraphReader {
 
     @Override
     public Iterator<Vertex> readVertices(final InputStream inputStream, final Direction direction,
-                                         final Function<DetachedVertex, Vertex> vertexMaker,
-                                         final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
+                                         final Function<Attachable<Vertex>, Vertex> vertexMaker,
+                                         final Function<Attachable<Edge>, Edge> edgeMaker) throws IOException {
         final BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
         return br.lines().<Vertex>map(FunctionUtils.wrapFunction(line -> readVertex(new ByteArrayInputStream(line.getBytes()), direction, vertexMaker, edgeMaker))).iterator();
     }
@@ -159,15 +161,15 @@ public class GraphSONReader implements GraphReader {
     }
 
     @Override
-    public Vertex readVertex(final InputStream inputStream, final Function<DetachedVertex, Vertex> vertexMaker) throws IOException {
+    public Vertex readVertex(final InputStream inputStream, final Function<Attachable<Vertex>, Vertex> vertexMaker) throws IOException {
         final Map<String, Object> vertexData = mapper.readValue(inputStream, mapTypeReference);
         return readVertexData(vertexData, vertexMaker);
     }
 
     @Override
     public Vertex readVertex(final InputStream inputStream, final Direction direction,
-                             final Function<DetachedVertex, Vertex> vertexMaker,
-                             final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
+                             final Function<Attachable<Vertex>, Vertex> vertexMaker,
+                             final Function<Attachable<Edge>, Edge> edgeMaker) throws IOException {
         final Map<String, Object> vertexData = mapper.readValue(inputStream, mapTypeReference);
         final Vertex v = readVertexData(vertexData, vertexMaker);
 
@@ -193,14 +195,14 @@ public class GraphSONReader implements GraphReader {
         v.property(VertexProperty.Cardinality.list, p.key(), p.value(), propertyArgs.toArray());
     }
 
-    private static void readVertexEdges(final Function<DetachedEdge, Edge> edgeMaker, final Map<String, Object> vertexData, final String direction) throws IOException {
+    private static void readVertexEdges(final Function<Attachable<Edge>, Edge> edgeMaker, final Map<String, Object> vertexData, final String direction) throws IOException {
         final List<Map<String, Object>> edgeDatas = (List<Map<String, Object>>) vertexData.get(direction);
         for (Map<String, Object> edgeData : edgeDatas) {
             readEdgeData(edgeData, edgeMaker);
         }
     }
 
-    private static Edge readEdgeData(final Map<String, Object> edgeData, final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
+    private static Edge readEdgeData(final Map<String, Object> edgeData, final Function<Attachable<Edge>, Edge> edgeMaker) throws IOException {
         final Map<String, Object> properties = (Map<String, Object>) edgeData.get(GraphSONTokens.PROPERTIES);
 
         final DetachedEdge edge = new DetachedEdge(edgeData.get(GraphSONTokens.ID),
@@ -212,7 +214,7 @@ public class GraphSONReader implements GraphReader {
         return edgeMaker.apply(edge);
     }
 
-    private static Vertex readVertexData(final Map<String, Object> vertexData, final Function<DetachedVertex, Vertex> vertexMaker) throws IOException {
+    private static Vertex readVertexData(final Map<String, Object> vertexData, final Function<Attachable<Vertex>, Vertex> vertexMaker) throws IOException {
         final Map<String, Object> vertexProperties = (Map<String, Object>) vertexData.get(GraphSONTokens.PROPERTIES);
         final DetachedVertex vertex = new DetachedVertex(vertexData.get(GraphSONTokens.ID),
                 vertexData.get(GraphSONTokens.LABEL).toString(),

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/39868a85/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/LegacyGraphSONReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/LegacyGraphSONReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/LegacyGraphSONReader.java
index c3cb860..e8bbfbf 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/LegacyGraphSONReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/LegacyGraphSONReader.java
@@ -122,8 +122,8 @@ public class LegacyGraphSONReader implements GraphReader {
 
     @Override
     public Iterator<Vertex> readVertices(final InputStream inputStream, final Direction direction,
-                                         final Function<DetachedVertex, Vertex> vertexMaker,
-                                         final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
+                                         final Function<Attachable<Vertex>, Vertex> vertexMaker,
+                                         final Function<Attachable<Edge>, Edge> edgeMaker) throws IOException {
         throw Io.Exceptions.readerFormatIsForFullGraphSerializationOnly(this.getClass());
     }
 
@@ -133,17 +133,17 @@ public class LegacyGraphSONReader implements GraphReader {
     }
 
     @Override
-    public Vertex readVertex(final InputStream inputStream, final Function<DetachedVertex, Vertex> vertexMaker) throws IOException {
+    public Vertex readVertex(final InputStream inputStream, final Function<Attachable<Vertex>, Vertex> vertexMaker) throws IOException {
         throw Io.Exceptions.readerFormatIsForFullGraphSerializationOnly(this.getClass());
     }
 
     @Override
-    public Vertex readVertex(final InputStream inputStream, final Direction direction, final Function<DetachedVertex, Vertex> vertexMaker, final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
+    public Vertex readVertex(final InputStream inputStream, final Direction direction, final Function<Attachable<Vertex>, Vertex> vertexMaker, final Function<Attachable<Edge>, Edge> edgeMaker) throws IOException {
         throw Io.Exceptions.readerFormatIsForFullGraphSerializationOnly(this.getClass());
     }
 
     @Override
-    public <C> C readObject(InputStream inputStream, Class<? extends C> clazz) throws IOException {
+    public <C> C readObject(final InputStream inputStream, final Class<? extends C> clazz) throws IOException {
         throw Io.Exceptions.readerFormatIsForFullGraphSerializationOnly(this.getClass());
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/39868a85/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
index 9aa898e..00b0c8d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
@@ -80,8 +80,8 @@ public class GryoReader implements GraphReader {
 
     @Override
     public Iterator<Vertex> readVertices(final InputStream inputStream, final Direction direction,
-                                         final Function<DetachedVertex, Vertex> vertexMaker,
-                                         final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
+                                         final Function<Attachable<Vertex>, Vertex> vertexMaker,
+                                         final Function<Attachable<Edge>, Edge> edgeMaker) throws IOException {
         final Input input = new Input(inputStream);
         return new Iterator<Vertex>() {
             @Override
@@ -114,12 +114,12 @@ public class GryoReader implements GraphReader {
     }
 
     @Override
-    public Vertex readVertex(final InputStream inputStream, final Function<DetachedVertex, Vertex> vertexMaker) throws IOException {
+    public Vertex readVertex(final InputStream inputStream, final Function<Attachable<Vertex>, Vertex> vertexMaker) throws IOException {
         return readVertex(inputStream, null, vertexMaker, null);
     }
 
     @Override
-    public Vertex readVertex(final InputStream inputStream, final Direction direction, Function<DetachedVertex, Vertex> vertexMaker, final Function<DetachedEdge, Edge> edgeMaker) throws IOException {
+    public Vertex readVertex(final InputStream inputStream, final Direction direction, Function<Attachable<Vertex>, Vertex> vertexMaker, final Function<Attachable<Edge>, Edge> edgeMaker) throws IOException {
         final Input input = new Input(inputStream);
         return readVertex(direction, vertexMaker, edgeMaker, input);
     }
@@ -218,8 +218,8 @@ public class GryoReader implements GraphReader {
         propertyArgs.add(val);
     }
 
-    private Vertex readVertex(final Direction directionRequested, final Function<DetachedVertex, Vertex> vertexMaker,
-                              final Function<DetachedEdge, Edge> edgeMaker, final Input input) throws IOException {
+    private Vertex readVertex(final Direction directionRequested, final Function<Attachable<Vertex>, Vertex> vertexMaker,
+                              final Function<Attachable<Edge>, Edge> edgeMaker, final Input input) throws IOException {
         if (null != directionRequested && null == edgeMaker)
             throw new IllegalArgumentException("If a directionRequested is specified then an edgeAdder function should also be specified");
 
@@ -262,7 +262,7 @@ public class GryoReader implements GraphReader {
         return vertex;
     }
 
-    private void readEdges(final Input input, final Function<DetachedEdge, Edge> edgeMaker) {
+    private void readEdges(final Input input, final Function<Attachable<Edge>, Edge> edgeMaker) {
         if (input.readBoolean()) {
             Object next = kryo.readClassAndObject(input);
             while (!next.equals(EdgeTerminator.INSTANCE)) {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/39868a85/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReaderWriterTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReaderWriterTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReaderWriterTest.java
index 2e39040..82f9c65 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReaderWriterTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReaderWriterTest.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.structure.io.gryo;
 
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.junit.Test;
 
@@ -56,7 +57,7 @@ public class GryoReaderWriterTest {
             try {
                 latch.await();
                 final GryoReader reader = builder.create();
-                final Vertex v = reader.readVertex(new ByteArrayInputStream(bytes), dv -> dv);
+                final Vertex v = reader.readVertex(new ByteArrayInputStream(bytes), Attachable::get);
                 assertProcess1.set(v.id().equals(1));
             } catch (Exception ex) {
                 throw new RuntimeException(ex);
@@ -67,7 +68,7 @@ public class GryoReaderWriterTest {
             try {
                 latch.await();
                 final GryoReader reader = builder.create();
-                final Vertex v = reader.readVertex(new ByteArrayInputStream(bytes), dv -> dv);
+                final Vertex v = reader.readVertex(new ByteArrayInputStream(bytes), Attachable::get);
                 assertProcess2.set(v.id().equals(1));
             } catch (Exception ex) {
                 throw new RuntimeException(ex);
@@ -78,7 +79,7 @@ public class GryoReaderWriterTest {
             try {
                 latch.await();
                 final GryoReader reader = builder.create();
-                final Vertex v = reader.readVertex(new ByteArrayInputStream(bytes), dv -> dv);
+                final Vertex v = reader.readVertex(new ByteArrayInputStream(bytes), Attachable::get);
                 assertProcess3.set(v.id().equals(1));
             } catch (Exception ex) {
                 throw new RuntimeException(ex);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/39868a85/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/IoTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/IoTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/IoTest.java
index 8ad4166..bb284c6 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/IoTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/IoTest.java
@@ -986,7 +986,8 @@ public class IoTest extends AbstractGremlinTest {
             final AtomicBoolean called = new AtomicBoolean(false);
             final GryoReader reader = graph.io(gryo).reader().workingDirectory(tempPath).create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, detachedVertex -> {
+                reader.readVertex(bais, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), detachedVertex.id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(2, IteratorUtils.count(detachedVertex.properties()));
@@ -1017,7 +1018,8 @@ public class IoTest extends AbstractGremlinTest {
             final AtomicBoolean called = new AtomicBoolean(false);
             final GryoReader reader = graph.io(gryo).reader().workingDirectory(tempPath).create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, detachedVertex -> {
+                reader.readVertex(bais, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), detachedVertex.id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(2, IteratorUtils.count(detachedVertex.properties()));
@@ -1049,7 +1051,8 @@ public class IoTest extends AbstractGremlinTest {
             final AtomicBoolean called = new AtomicBoolean(false);
             final GryoReader reader = graph.io(gryo).reader().workingDirectory(tempPath).create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, detachedVertex -> {
+                reader.readVertex(bais, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), detachedVertex.id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(2, IteratorUtils.count(detachedVertex.properties()));
@@ -1081,7 +1084,8 @@ public class IoTest extends AbstractGremlinTest {
             final AtomicBoolean called = new AtomicBoolean(false);
             final GryoReader reader = graph.io(gryo).reader().workingDirectory(tempPath).create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, detachedVertex -> {
+                reader.readVertex(bais, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), detachedVertex.id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(0, IteratorUtils.count(detachedVertex.properties()));
@@ -1113,7 +1117,8 @@ public class IoTest extends AbstractGremlinTest {
             final AtomicBoolean called = new AtomicBoolean(false);
             final GryoReader reader = graph.io(gryo).reader().workingDirectory(tempPath).create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, detachedVertex -> {
+                reader.readVertex(bais, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), detachedVertex.id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(4, IteratorUtils.count(detachedVertex.properties()));
@@ -1148,7 +1153,8 @@ public class IoTest extends AbstractGremlinTest {
             final AtomicBoolean called = new AtomicBoolean(false);
             final GraphSONReader reader = graph.io(graphson).reader().create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, detachedVertex -> {
+                reader.readVertex(bais, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(2, IteratorUtils.count(detachedVertex.properties()));
@@ -1182,7 +1188,8 @@ public class IoTest extends AbstractGremlinTest {
             final AtomicBoolean called = new AtomicBoolean(false);
             final GraphSONReader reader = graph.io(graphson).reader().create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, detachedVertex -> {
+                reader.readVertex(bais, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(2, IteratorUtils.count(detachedVertex.properties()));
@@ -1216,7 +1223,8 @@ public class IoTest extends AbstractGremlinTest {
             final AtomicBoolean called = new AtomicBoolean(false);
             final GraphSONReader reader = graph.io(graphson).reader().create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, detachedVertex -> {
+                reader.readVertex(bais, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(0, IteratorUtils.count(detachedVertex.properties()));
@@ -1250,7 +1258,8 @@ public class IoTest extends AbstractGremlinTest {
             final AtomicBoolean called = new AtomicBoolean(false);
             final GraphSONReader reader = graph.io(graphson).reader().create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, detachedVertex -> {
+                reader.readVertex(bais, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(4, IteratorUtils.count(detachedVertex.properties()));
@@ -1279,13 +1288,15 @@ public class IoTest extends AbstractGremlinTest {
 
             try (final VertexByteArrayInputStream vbais = new VertexByteArrayInputStream(new ByteArrayInputStream(os.toByteArray()))) {
                 reader.readVertex(new ByteArrayInputStream(vbais.readVertexBytes().toByteArray()),
-                        detachedVertex -> {
+                        attachable -> {
+                            final Vertex detachedVertex = attachable.get();
                             called.incrementAndGet();
                             return detachedVertex;
                         });
 
                 reader.readVertex(new ByteArrayInputStream(vbais.readVertexBytes().toByteArray()),
-                        detachedVertex -> {
+                        attachable -> {
+                            final Vertex detachedVertex = attachable.get();
                             called.incrementAndGet();
                             return detachedVertex;
                         });
@@ -1307,7 +1318,8 @@ public class IoTest extends AbstractGremlinTest {
 
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
                 final Iterator<Vertex> itty = reader.readVertices(bais, null,
-                        detachedVertex -> {
+                        attachable -> {
+                            final Vertex detachedVertex = attachable.get();
                             called.incrementAndGet();
                             return detachedVertex;
                         }, null);
@@ -1333,7 +1345,8 @@ public class IoTest extends AbstractGremlinTest {
             final BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(os.toByteArray())));
             String line = br.readLine();
             reader.readVertex(new ByteArrayInputStream(line.getBytes()),
-                    detachedVertex -> {
+                    attachable -> {
+                        final Vertex detachedVertex = attachable.get();
                         called.incrementAndGet();
                         return mock(Vertex.class);
                     });
@@ -1370,7 +1383,8 @@ public class IoTest extends AbstractGremlinTest {
             final GryoReader reader = graph.io(gryo).reader().workingDirectory(tempPath).create();
 
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, Direction.OUT, detachedVertex -> {
+                reader.readVertex(bais, Direction.OUT, attachable -> {
+                            final Vertex detachedVertex = attachable.get();
                             assertEquals(v1.id(), detachedVertex.id());
                             assertEquals(v1.label(), detachedVertex.label());
                             assertEquals(1, IteratorUtils.count(detachedVertex.properties()));
@@ -1378,7 +1392,8 @@ public class IoTest extends AbstractGremlinTest {
                             calledVertex.set(true);
                             return detachedVertex;
                         },
-                        detachedEdge -> {
+                        attachable -> {
+                            final Edge detachedEdge = attachable.get();
                             assertEquals(e.id(), detachedEdge.id());
                             assertEquals(v1.id(), detachedEdge.outVertex().id());
                             assertEquals(v2.id(), detachedEdge.inVertex().id());
@@ -1418,15 +1433,16 @@ public class IoTest extends AbstractGremlinTest {
             final AtomicBoolean calledEdge = new AtomicBoolean(false);
             final GraphSONReader reader = graph.io(graphson).reader().create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, Direction.OUT, detachedVertex -> {
+                reader.readVertex(bais, Direction.OUT, attachable -> {
+                            final Vertex detachedVertex = attachable.get();
                             assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
                             assertEquals(v1.label(), detachedVertex.label());
                             assertEquals(1, IteratorUtils.count(detachedVertex.properties()));
                             assertEquals("marko", detachedVertex.value("name"));
                             calledVertex.set(true);
                             return null;
-                        },
-                        detachedEdge -> {
+                        },attachable -> {
+                            final Edge detachedEdge = attachable.get();
                             assertEquals(e.id(), graph.edges(detachedEdge.id().toString()).next().id());
                             assertEquals(v1.id(), graph.vertices(detachedEdge.outVertex().id().toString()).next().id());
                             assertEquals(v2.id(), graph.vertices(detachedEdge.inVertex().id().toString()).next().id());
@@ -1466,7 +1482,8 @@ public class IoTest extends AbstractGremlinTest {
 
             final GryoReader reader = graph.io(gryo).reader().workingDirectory(tempPath).create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, Direction.IN, detachedVertex -> {
+                reader.readVertex(bais, Direction.IN, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), detachedVertex.id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(1, IteratorUtils.count(detachedVertex.properties()));
@@ -1474,7 +1491,8 @@ public class IoTest extends AbstractGremlinTest {
                     calledVertex.set(true);
 
                     return detachedVertex;
-                }, detachedEdge -> {
+                }, attachable -> {
+                    final Edge detachedEdge = attachable.get();
                     assertEquals(e.id(), detachedEdge.id());
                     assertEquals(v2.id(), detachedEdge.outVertex().id());
                     assertEquals(v1.id(), detachedEdge.inVertex().id());
@@ -1515,15 +1533,16 @@ public class IoTest extends AbstractGremlinTest {
             final AtomicBoolean calledEdge = new AtomicBoolean(false);
             final GraphSONReader reader = graph.io(graphson).reader().create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, Direction.IN, detachedVertex -> {
+                reader.readVertex(bais, Direction.IN, attachable -> {
+                            final Vertex detachedVertex = attachable.get();
                             assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
                             assertEquals(v1.label(), detachedVertex.label());
                             assertEquals(1, IteratorUtils.count(detachedVertex.properties()));
                             assertEquals("marko", detachedVertex.value("name"));
                             calledVertex.set(true);
                             return null;
-                        },
-                        detachedEdge -> {
+                        },attachable -> {
+                            final Edge detachedEdge = attachable.get();
                             assertEquals(e.id(), graph.edges(detachedEdge.id().toString()).next().id());
                             assertEquals(v1.id(), graph.vertices(detachedEdge.inVertex().id().toString()).next().id());
                             assertEquals(v2.id(), graph.vertices(detachedEdge.outVertex().id().toString()).next().id());
@@ -1565,7 +1584,8 @@ public class IoTest extends AbstractGremlinTest {
 
             final GryoReader reader = graph.io(gryo).reader().workingDirectory(tempPath).create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, Direction.BOTH, detachedVertex -> {
+                reader.readVertex(bais, Direction.BOTH, attachable -> {
+                            final Vertex detachedVertex = attachable.get();
                             assertEquals(v1.id(), detachedVertex.id());
                             assertEquals(v1.label(), detachedVertex.label());
                             assertEquals(1, IteratorUtils.count(detachedVertex.properties()));
@@ -1573,8 +1593,8 @@ public class IoTest extends AbstractGremlinTest {
                             calledVertex.set(true);
 
                             return detachedVertex;
-                        },
-                        detachedEdge -> {
+                        },attachable -> {
+                            final Edge detachedEdge = attachable.get();
                             if (detachedEdge.id().equals(e1.id())) {
                                 assertEquals(v2.id(), detachedEdge.outVertex().id());
                                 assertEquals(v1.id(), detachedEdge.inVertex().id());
@@ -1629,15 +1649,16 @@ public class IoTest extends AbstractGremlinTest {
 
             final GraphSONReader reader = graph.io(graphson).reader().create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, Direction.BOTH, detachedVertex -> {
+                reader.readVertex(bais, Direction.BOTH, attachable -> {
+                            final Vertex detachedVertex = attachable.get();
                             assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
                             assertEquals(v1.label(), detachedVertex.label());
                             assertEquals(1, IteratorUtils.count(detachedVertex.properties()));
                             assertEquals("marko", detachedVertex.value("name"));
                             vertexCalled.set(true);
                             return null;
-                        },
-                        detachedEdge -> {
+                        },attachable -> {
+                            final Edge detachedEdge = attachable.get();
                             if (graph.edges(detachedEdge.id().toString()).next().id().equals(e1.id())) {
                                 assertEquals(e1.id(), graph.edges(detachedEdge.id().toString()).next().id());
                                 assertEquals(v1.id(), graph.vertices(detachedEdge.inVertex().id().toString()).next().id());
@@ -1694,7 +1715,8 @@ public class IoTest extends AbstractGremlinTest {
 
             final GraphSONReader reader = graph.io(graphson).reader().mapper(graph.io(graphson).mapper().embedTypes(true).create()).create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, Direction.BOTH, detachedVertex -> {
+                reader.readVertex(bais, Direction.BOTH, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     // a quick reminder here that the purpose of these id assertions is to ensure that those with
                     // complex ids that are not simply toString'd (i.e. are complex objects in JSON as well)
                     // properly respond to filtering in Graph.edges/vertices
@@ -1704,7 +1726,8 @@ public class IoTest extends AbstractGremlinTest {
                     assertEquals(v1.value("name"), detachedVertex.value("name").toString());
                     vertexCalled.set(true);
                     return null;
-                }, detachedEdge -> {
+                }, attachable -> {
+                    final Edge detachedEdge = attachable.get();
                     // a quick reminder here that the purpose of these id assertions is to ensure that those with
                     // complex ids that are not simply toString'd (i.e. are complex objects in JSON as well)
                     // properly respond to filtering in Graph.edges/vertices
@@ -1761,7 +1784,8 @@ public class IoTest extends AbstractGremlinTest {
 
             final GryoReader reader = graph.io(gryo).reader().workingDirectory(tempPath).create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, Direction.IN, detachedVertex -> {
+                reader.readVertex(bais, Direction.IN, attachable -> {
+                            final Vertex detachedVertex = attachable.get();
                             assertEquals(v1.id(), detachedVertex.id());
                             assertEquals(v1.label(), detachedVertex.label());
                             assertEquals(1, IteratorUtils.count(detachedVertex.properties()));
@@ -1769,8 +1793,8 @@ public class IoTest extends AbstractGremlinTest {
                             vertexCalled.set(true);
 
                             return detachedVertex;
-                        },
-                        detachedEdge -> {
+                        },attachable -> {
+                            final Edge detachedEdge = attachable.get();
                             if (detachedEdge.id().equals(e1.id())) {
                                 assertEquals(v2.id(), detachedEdge.outVertex().id());
                                 assertEquals(v1.id(), detachedEdge.inVertex().id());
@@ -1814,7 +1838,8 @@ public class IoTest extends AbstractGremlinTest {
 
             final GraphSONReader reader = graph.io(graphson).reader().create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, Direction.IN, detachedVertex -> {
+                reader.readVertex(bais, Direction.IN, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(1, IteratorUtils.count(detachedVertex.properties()));
@@ -1822,7 +1847,8 @@ public class IoTest extends AbstractGremlinTest {
                     vertexCalled.set(true);
 
                     return null;
-                }, detachedEdge -> {
+                }, attachable -> {
+                    final Edge detachedEdge = attachable.get();
                     if (graph.edges(detachedEdge.id().toString()).next().id().equals(e1.id())) {
                         assertEquals(e1.id(), graph.edges(detachedEdge.id().toString()).next().id());
                         assertEquals(v1.id(), graph.vertices(detachedEdge.inVertex().id().toString()).next().id());
@@ -1867,7 +1893,8 @@ public class IoTest extends AbstractGremlinTest {
 
             final GryoReader reader = graph.io(gryo).reader().workingDirectory(tempPath).create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, Direction.OUT, detachedVertex -> {
+                reader.readVertex(bais, Direction.OUT, attachable -> {
+                            final Vertex detachedVertex = attachable.get();
                             assertEquals(v1.id(), detachedVertex.id());
                             assertEquals(v1.label(), detachedVertex.label());
                             assertEquals(1, IteratorUtils.count(detachedVertex.properties()));
@@ -1875,8 +1902,8 @@ public class IoTest extends AbstractGremlinTest {
                             vertexCalled.set(true);
 
                             return detachedVertex;
-                        },
-                        detachedEdge -> {
+                        },attachable -> {
+                            final Edge detachedEdge = attachable.get();
                             if (detachedEdge.id().equals(e2.id())) {
                                 assertEquals(v1.id(), detachedEdge.outVertex().id());
                                 assertEquals(v2.id(), detachedEdge.inVertex().id());
@@ -1921,14 +1948,16 @@ public class IoTest extends AbstractGremlinTest {
 
             final GraphSONReader reader = graph.io(graphson).reader().create();
             try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
-                reader.readVertex(bais, Direction.OUT, detachedVertex -> {
+                reader.readVertex(bais, Direction.OUT, attachable -> {
+                    final Vertex detachedVertex = attachable.get();
                     assertEquals(v1.id(), graph.vertices(detachedVertex.id().toString()).next().id());
                     assertEquals(v1.label(), detachedVertex.label());
                     assertEquals(1, IteratorUtils.count(detachedVertex.properties()));
                     assertEquals("marko", detachedVertex.value("name"));
                     vertexCalled.set(true);
                     return null;
-                }, detachedEdge -> {
+                }, attachable -> {
+                    final Edge detachedEdge = attachable.get();
                     if (graph.edges(detachedEdge.id().toString()).next().id().equals(e2.id())) {
                         assertEquals(e2.id(), graph.edges(detachedEdge.id().toString()).next().id());
                         assertEquals(v2.id(), graph.vertices(detachedEdge.inVertex().id().toString()).next().id());

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/39868a85/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java
index a46494d..8ece131 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java
@@ -65,8 +65,8 @@ public class GraphSONRecordReader extends RecordReader<NullWritable, VertexWrita
             return false;
 
         final StarGraph starGraph = StarGraph.open();
-        final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> detachedVertex.attach(starGraph, Attachable.Method.CREATE);
-        final Function<DetachedEdge, Edge> edgeMaker = detachedEdge -> detachedEdge.attach(starGraph, Attachable.Method.CREATE);
+        final Function<Attachable<Vertex>, Vertex> vertexMaker = detachedVertex -> detachedVertex.attach(starGraph, Attachable.Method.CREATE);
+        final Function<Attachable<Edge>, Edge> edgeMaker = detachedEdge -> detachedEdge.attach(starGraph, Attachable.Method.CREATE);
         try (InputStream in = new ByteArrayInputStream(this.lineRecordReader.getCurrentValue().getBytes())) {
             this.vertexWritable.set(this.hasEdges ?
                     this.graphsonReader.readVertex(in, Direction.BOTH, vertexMaker, edgeMaker) :

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/39868a85/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java
index 5fff9c8..fe787c0 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java
@@ -131,8 +131,8 @@ public class GryoRecordReader extends RecordReader<NullWritable, VertexWritable>
 
             if (terminatorLocation >= TERMINATOR.length) {
                 final StarGraph starGraph = StarGraph.open();
-                final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> detachedVertex.attach(starGraph, Attachable.Method.CREATE);
-                final Function<DetachedEdge, Edge> edgeMaker = detachedEdge -> detachedEdge.attach(starGraph, Attachable.Method.CREATE);
+                final Function<Attachable<Vertex>, Vertex> vertexMaker = detachedVertex -> detachedVertex.attach(starGraph, Attachable.Method.CREATE);
+                final Function<Attachable<Edge>, Edge> edgeMaker = detachedEdge -> detachedEdge.attach(starGraph, Attachable.Method.CREATE);
                 try (InputStream in = new ByteArrayInputStream(output.toByteArray())) {
                     this.vertexWritable.set(this.hasEdges ?
                             this.gryoReader.readVertex(in, Direction.BOTH, vertexMaker, edgeMaker) :