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/21 22:48:36 UTC

[1/5] incubator-tinkerpop git commit: not finished, but saving for now the new attachable work.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 8562f50e9 -> 037428f25


not finished, but saving for now the new attachable work.


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

Branch: refs/heads/master
Commit: 58a63998afa27c46c0f718ce741f941258f31a9f
Parents: 8562f50
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Apr 21 11:20:22 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Apr 21 11:20:22 2015 -0600

----------------------------------------------------------------------
 .../gremlin/structure/util/Attachable.java      | 266 ++++++++++++++++++-
 .../structure/util/detached/DetachedEdge.java   |  21 +-
 .../util/detached/DetachedElement.java          |   4 +
 .../structure/util/detached/DetachedPath.java   |  12 +-
 .../util/detached/DetachedProperty.java         |  18 +-
 .../structure/util/detached/DetachedVertex.java |  22 +-
 .../util/detached/DetachedVertexProperty.java   |  14 +-
 .../structure/util/reference/ReferenceEdge.java |  16 +-
 .../util/reference/ReferenceElement.java        |   4 +
 .../structure/util/reference/ReferencePath.java |  12 +-
 .../util/reference/ReferenceProperty.java       |  19 +-
 .../util/reference/ReferenceVertex.java         |  16 +-
 .../util/reference/ReferenceVertexProperty.java |  14 +-
 .../gremlin/structure/util/star/StarGraph.java  |  15 +-
 14 files changed, 373 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
index 8a9ed27..ba50374 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
@@ -18,21 +18,272 @@
  */
 package org.apache.tinkerpop.gremlin.structure.util;
 
+import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Element;
 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 java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.BiFunction;
+
 /**
  * An interface that provides methods for detached properties and elements to be re-attached to the {@link Graph}.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public interface Attachable<T> {
-    public abstract T attach(final Vertex hostVertex) throws IllegalStateException;
+    public enum Method implements BiFunction<Attachable, Object, Object> {
+
+        GET {
+            @Override
+            public Object apply(final Attachable attachable, final Object hostVertexOrGraph) {
+                final Object base = attachable.get();
+                if (base instanceof Vertex) {
+                    final Optional<Vertex> optional = hostVertexOrGraph instanceof Graph ?
+                            Method.getVertex(attachable, (Graph) hostVertexOrGraph) :
+                            Method.getVertex(attachable, (Vertex) hostVertexOrGraph);
+                    return optional.orElseThrow(() -> new IllegalStateException("Can not get the following attachable from " + hostVertexOrGraph + ": " + attachable));
+                } else if (base instanceof Edge) {
+                    final Optional<Edge> optional = hostVertexOrGraph instanceof Graph ?
+                            Method.getEdge(attachable, (Graph) hostVertexOrGraph) :
+                            Method.getEdge(attachable, (Vertex) hostVertexOrGraph);
+                    return optional.orElseThrow(() -> new IllegalStateException("Can not get the following attachable from " + hostVertexOrGraph + ": " + attachable));
+                } else if (base instanceof VertexProperty) {
+                    final Optional<VertexProperty> optional = hostVertexOrGraph instanceof Graph ?
+                            Method.getVertexProperty(attachable, (Graph) hostVertexOrGraph) :
+                            Method.getVertexProperty(attachable, (Vertex) hostVertexOrGraph);
+                    return optional.orElseThrow(() -> new IllegalStateException("Can not get the following attachable from " + hostVertexOrGraph + ": " + attachable));
+                } else if (base instanceof Property) {
+                    final Optional<Property> optional = hostVertexOrGraph instanceof Graph ?
+                            Method.getProperty(attachable, (Graph) hostVertexOrGraph) :
+                            Method.getProperty(attachable, (Vertex) hostVertexOrGraph);
+                    return optional.orElseThrow(() -> new IllegalStateException("Can not get the following attachable from " + hostVertexOrGraph + ": " + attachable));
+                } else {
+                    throw new IllegalArgumentException("The attachable must contain an graph object");
+                }
+            }
+        },
+
+        CREATE {
+            @Override
+            public Object apply(final Attachable attachable, final Object hostVertexOrGraph) {
+                final Object base = attachable.get();
+                if (base instanceof Vertex) {
+                    return hostVertexOrGraph instanceof Graph ?
+                            Method.createVertex(attachable, (Graph) hostVertexOrGraph) :
+                            Method.createVertex(attachable, (Vertex) hostVertexOrGraph);
+                } else if (base instanceof Edge) {
+                    return hostVertexOrGraph instanceof Graph ?
+                            Method.createEdge(attachable, (Graph) hostVertexOrGraph) :
+                            Method.createEdge(attachable, (Vertex) hostVertexOrGraph);
+                } else if (base instanceof VertexProperty) {
+                    return hostVertexOrGraph instanceof Graph ?
+                            Method.createVertexProperty(attachable, (Graph) hostVertexOrGraph) :
+                            Method.createVertexProperty(attachable, (Vertex) hostVertexOrGraph);
+                } else if (base instanceof Property) {
+                    return hostVertexOrGraph instanceof Graph ?
+                            Method.createProperty(attachable, (Graph) hostVertexOrGraph) :
+                            Method.createProperty(attachable, (Vertex) hostVertexOrGraph);
+                } else {
+                    throw new IllegalArgumentException("The attachable must contain an graph object");
+                }
+            }
+        };
+
+        ///////////////////
+
+        public static Optional<Vertex> getVertex(final Attachable<Vertex> attachableVertex, final Graph hostGraph) {
+            final Iterator<Vertex> vertexIterator = hostGraph.vertices(attachableVertex.get().id());
+            return vertexIterator.hasNext() ? Optional.of(vertexIterator.next()) : Optional.empty();
+        }
+
+        public static Optional<Vertex> getVertex(final Attachable<Vertex> attachableVertex, final Vertex hostVertex) {
+            return ElementHelper.areEqual(attachableVertex.get(), hostVertex) ? Optional.of(hostVertex) : Optional.empty();
+        }
+
+        public static Optional<Edge> getEdge(final Attachable<Edge> attachableEdge, final Graph hostGraph) {
+            final Iterator<Edge> edgeIterator = hostGraph.edges(attachableEdge.get().id());
+            return edgeIterator.hasNext() ? Optional.of(edgeIterator.next()) : Optional.empty();
+        }
+
+        public static Optional<Edge> getEdge(final Attachable<Edge> attachableEdge, final Vertex hostVertex) {
+            final Object baseId = attachableEdge.get().id();
+            final Iterator<Edge> edgeIterator = hostVertex.edges(Direction.OUT);
+            while (edgeIterator.hasNext()) {
+                final Edge edge = edgeIterator.next();
+                if (edge.id().equals(baseId))
+                    return Optional.of(edge);
+            }
+            return Optional.empty();
+        }
+
+        public static Optional<VertexProperty> getVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Graph hostGraph) {
+            final VertexProperty baseVertexProperty = attachableVertexProperty.get();
+            final Iterator<Vertex> vertexIterator = hostGraph.vertices(baseVertexProperty.element().id());
+            if (vertexIterator.hasNext()) {
+                final Iterator<VertexProperty<Object>> vertexPropertyIterator = vertexIterator.next().properties(baseVertexProperty.key());
+                while (vertexPropertyIterator.hasNext()) {
+                    final VertexProperty vertexProperty = vertexPropertyIterator.next();
+                    if (ElementHelper.areEqual(vertexProperty, baseVertexProperty))
+                        return Optional.of(vertexProperty);
+                }
+            }
+            return Optional.empty();
+        }
+
+        public static Optional<VertexProperty> getVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Vertex hostVertex) {
+            final VertexProperty baseVertexProperty = attachableVertexProperty.get();
+            final Iterator<VertexProperty<Object>> vertexPropertyIterator = hostVertex.properties(baseVertexProperty.key());
+            while (vertexPropertyIterator.hasNext()) {
+                final VertexProperty vertexProperty = vertexPropertyIterator.next();
+                if (ElementHelper.areEqual(vertexProperty, baseVertexProperty))
+                    return Optional.of(vertexProperty);
+            }
+            return Optional.empty();
+        }
+
+        public static Optional<Property> getProperty(final Attachable<Property> attachableProperty, final Graph hostGraph) {
+            final Property baseProperty = attachableProperty.get();
+            final Element propertyElement = attachableProperty.get().element();
+            if (propertyElement instanceof Edge) {
+                final Iterator<Edge> edgeIterator = hostGraph.edges(propertyElement.id());
+                if (edgeIterator.hasNext()) {
+                    final Property property = edgeIterator.next().property(baseProperty.key());
+                    if (property.isPresent() && property.value().equals(baseProperty.value()))
+                        return Optional.of(property);
+                }
+                return Optional.empty();
+            } else {
+                final Iterator<Vertex> vertexIterator = hostGraph.vertices(((VertexProperty) propertyElement).element().id());
+                if (vertexIterator.hasNext()) {
+                    final Iterator<VertexProperty<Object>> vertexPropertyIterator = vertexIterator.next().properties();
+                    while (vertexPropertyIterator.hasNext()) {
+                        final VertexProperty vertexProperty = vertexPropertyIterator.next();
+                        if (ElementHelper.areEqual(vertexProperty, baseProperty.element())) {
+                            final Property property = vertexProperty.property(baseProperty.key());
+                            if (property.isPresent() && property.value().equals(baseProperty.value()))
+                                return Optional.of(property);
+                            else
+                                return Optional.empty();
+                        }
+                    }
+                }
+                return Optional.empty();
+            }
+        }
+
+        public static Optional<Property> getProperty(final Attachable<Property> attachableProperty, final Vertex hostVertex) {
+            final Property baseProperty = attachableProperty.get();
+            final Element propertyElement = attachableProperty.get().element();
+            if (propertyElement instanceof Edge) {
+                final Iterator<Edge> edgeIterator = hostVertex.edges(Direction.OUT);
+                if (edgeIterator.hasNext()) {
+                    final Property property = edgeIterator.next().property(baseProperty.key());
+                    if (property.isPresent() && property.value().equals(baseProperty.value()))
+                        return Optional.of(property);
+                }
+                return Optional.empty();
+            } else {
+                final Iterator<VertexProperty<Object>> vertexPropertyIterator = hostVertex.properties();
+                while (vertexPropertyIterator.hasNext()) {
+                    final VertexProperty vertexProperty = vertexPropertyIterator.next();
+                    if (ElementHelper.areEqual(vertexProperty, baseProperty.element())) {
+                        final Property property = vertexProperty.property(baseProperty.key());
+                        if (property.isPresent() && property.value().equals(baseProperty.value()))
+                            return Optional.of(property);
+                        else
+                            return Optional.empty();
+                    }
+                }
+                return Optional.empty();
+            }
+        }
+
+        /////
+
+        public static Vertex createVertex(final Attachable<Vertex> attachableVertex, final Graph hostGraph) {
+            final Vertex baseVertex = attachableVertex.get();
+            final List<Object> keyValues = new ArrayList<>();
+            keyValues.add(org.apache.tinkerpop.gremlin.process.traversal.T.id);
+            keyValues.add(baseVertex.id());
+            keyValues.add(org.apache.tinkerpop.gremlin.process.traversal.T.label);
+            keyValues.add(baseVertex.label());
+            final Vertex vertex = hostGraph.addVertex(keyValues.toArray());
+            baseVertex.properties().forEachRemaining(vp -> {
+                final VertexProperty vertexProperty = vertex.property(VertexProperty.Cardinality.list, vp.key(), vp.value());
+                vp.properties().forEachRemaining(p -> vertexProperty.property(p.key(), p.value()));
+            });
+            return vertex;
+        }
+
+        public static Vertex createVertex(final Attachable<Vertex> attachableVertex, final Vertex hostVertex) {
+            throw new IllegalStateException("It is not possible to create a vertex at a host vertex");
+        }
+
+        public static Edge createEdge(final Attachable<Edge> attachableEdge, final Graph hostGraph) {
+            final Edge baseEdge = attachableEdge.get();
+            Iterator<Vertex> vertices = hostGraph.vertices(baseEdge.outVertex().id());
+            final Vertex outV = vertices.hasNext() ? vertices.next() : hostGraph.addVertex(org.apache.tinkerpop.gremlin.process.traversal.T.id, baseEdge.outVertex().id());
+            vertices = hostGraph.vertices(baseEdge.inVertex().id());
+            final Vertex inV = vertices.hasNext() ? vertices.next() : hostGraph.addVertex(org.apache.tinkerpop.gremlin.process.traversal.T.id, baseEdge.inVertex().id());
+            if (ElementHelper.areEqual(outV, inV)) {
+                final Iterator<Edge> itty = outV.edges(Direction.OUT, baseEdge.label());
+                while (itty.hasNext()) {
+                    final Edge e = itty.next();
+                    if (ElementHelper.areEqual(baseEdge, e))
+                        return e;
+                }
+            }
+            final Edge e = outV.addEdge(baseEdge.label(), inV, org.apache.tinkerpop.gremlin.process.traversal.T.id, baseEdge.id());
+            baseEdge.properties().forEachRemaining(p -> e.property(p.key(), p.value()));
+            return e;
+        }
+
+        public static Edge createEdge(final Attachable<Edge> attachableEdge, final Vertex hostVertex) {
+            return Method.createEdge(attachableEdge, hostVertex.graph());
+        }
+
+        public static VertexProperty createVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Graph hostGraph) {
+            final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.get();
+            final Iterator<Vertex> vertexIterator = hostGraph.vertices(baseVertexProperty.element().id());
+            if (vertexIterator.hasNext()) {
+                final VertexProperty vertexProperty = vertexIterator.next().property(VertexProperty.Cardinality.list, baseVertexProperty.key(), baseVertexProperty.value(), org.apache.tinkerpop.gremlin.process.traversal.T.id, baseVertexProperty.id());
+                baseVertexProperty.properties().forEachRemaining(p -> vertexProperty.property(p.key(), p.value()));
+                return vertexProperty;
+            }
+            throw new IllegalStateException("Could not find vertex to add the vertex property to");
+        }
+
+        public static VertexProperty createVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Vertex hostVertex) {
+            final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.get();
+            final VertexProperty vertexProperty = hostVertex.property(VertexProperty.Cardinality.list, baseVertexProperty.key(), baseVertexProperty.value(), org.apache.tinkerpop.gremlin.process.traversal.T.id, baseVertexProperty.id());
+            baseVertexProperty.properties().forEachRemaining(p -> vertexProperty.property(p.key(), p.value()));
+            return vertexProperty;
+        }
+
+        public static Property createProperty(final Attachable<Property> attachableProperty, final Graph hostGraph) {
+            return null;
+
+        }
+
+        public static Property createProperty(final Attachable<Property> attachableProperty, final Vertex hostVertex) {
+            return null;
+        }
+
+    }
+
+    public T get();
+
+    public T attach(final Vertex hostVertex, final Method method) throws IllegalStateException;
+
+    public T attach(final Graph hostGraph, final Method method) throws IllegalStateException;
 
-    public abstract T attach(final Graph hostGraph) throws IllegalStateException;
 
     public static class Exceptions {
 
@@ -70,7 +321,16 @@ public interface Attachable<T> {
         public static IllegalStateException canNotAttachPropertyToHostGraph(final Attachable<Property> property, final Graph hostGraph) {
             return new IllegalStateException("The provided property could not be attached the host graph: " + property + " not in " + hostGraph);
         }
-    }
 
+        ////
+
+        public static IllegalArgumentException illegalMethodOnHostVertex(final Attachable attachable, final Method method, final Vertex hostVertex) {
+            return new IllegalArgumentException("The following method on the host vertex is not legal: " + hostVertex + "." + method + "(" + attachable + ")");
+        }
+
+        public static IllegalArgumentException illegalMethodOnHostGraph(final Attachable attachable, final Method method, final Graph hostGraph) {
+            return new IllegalArgumentException("The following method on the host graph is not legal: " + hostGraph + "." + method + "(" + attachable + ")");
+        }
+    }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdge.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdge.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdge.java
index f32b77d..cffa268 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdge.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdge.java
@@ -18,14 +18,11 @@
  */
 package org.apache.tinkerpop.gremlin.structure.util.detached;
 
-import org.apache.tinkerpop.gremlin.process.traversal.T;
 import org.apache.tinkerpop.gremlin.structure.Direction;
 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.util.Attachable;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.javatuples.Pair;
@@ -95,22 +92,24 @@ public class DetachedEdge extends DetachedElement<Edge> implements Edge {
     }
 
     @Override
-    public Edge attach(final Vertex hostVertex) {
-        final Iterator<Edge> edges = IteratorUtils.filter(hostVertex.edges(Direction.OUT, this.label), edge -> edge.equals(this));
+    public Edge attach(final Vertex hostVertex, final Method method) {
+        return (Edge) method.apply(this, hostVertex);
+        /*final Iterator<Edge> edges = IteratorUtils.filter(hostVertex.edges(Direction.OUT, this.label), edge -> edge.equals(this));
         if (!edges.hasNext())
             throw Attachable.Exceptions.canNotAttachEdgeToHostVertex(this, hostVertex);
-        return edges.next();
+        return edges.next();*/
     }
 
     @Override
-    public Edge attach(final Graph hostGraph) {
-        final Iterator<Edge> edges = hostGraph.edges(this.id);
+    public Edge attach(final Graph hostGraph, final Method method) {
+        return (Edge) method.apply(this, hostGraph);
+        /*final Iterator<Edge> edges = hostGraph.edges(this.id);
         if (!edges.hasNext())
             throw Attachable.Exceptions.canNotAttachEdgeToHostGraph(this, hostGraph);
-        return edges.next();
+        return edges.next();*/
     }
 
-    public static Edge addTo(final Graph graph, final DetachedEdge detachedEdge) {
+    /*public static Edge addTo(final Graph graph, final DetachedEdge detachedEdge) {
         Iterator<Vertex> vertices = graph.vertices(detachedEdge.outVertex.id());
         final Vertex outV = vertices.hasNext() ? vertices.next() : graph.addVertex(T.id, detachedEdge.outVertex.id());
         vertices = graph.vertices(detachedEdge.inVertex.id());
@@ -127,7 +126,7 @@ public class DetachedEdge extends DetachedElement<Edge> implements Edge {
         if (null != detachedEdge.properties)
             detachedEdge.properties.entrySet().forEach(kv -> kv.getValue().forEach(p -> e.<Object>property(kv.getKey(), p.value())));
         return e;
-    }
+    }*/
 
     @Override
     public Vertex inVertex() {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
index 54e448c..b748633 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
@@ -96,4 +96,8 @@ public abstract class DetachedElement<E> implements Element, Serializable, Attac
                 Collections.emptyIterator() :
                 (Iterator) this.properties.entrySet().stream().filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys)).flatMap(entry -> entry.getValue().stream()).iterator();
     }
+
+    public E get() {
+        return (E) this;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
index 90160e5..8610922 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
@@ -35,6 +35,10 @@ public class DetachedPath extends MutablePath implements Attachable<Path> {
 
     }
 
+    public Path get() {
+        return this;
+    }
+
     protected DetachedPath(final Path path, final boolean withProperties) {
         path.forEach((object, labels) -> {
             if (object instanceof DetachedElement || object instanceof DetachedProperty || object instanceof DetachedPath) {
@@ -57,16 +61,16 @@ public class DetachedPath extends MutablePath implements Attachable<Path> {
     }
 
     @Override
-    public Path attach(final Graph hostGraph) {
+    public Path attach(final Graph hostGraph, final Method method) {
         final Path path = MutablePath.make();  // TODO: Use ImmutablePath?
-        this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostGraph) : object, labels.toArray(new String[labels.size()])));
+        this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostGraph, method) : object, labels.toArray(new String[labels.size()])));
         return path;
     }
 
     @Override
-    public Path attach(final Vertex hostVertex) {
+    public Path attach(final Vertex hostVertex, final Method method) {
         final Path path = MutablePath.make();  // TODO: Use ImmutablePath?
-        this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostVertex) : object, labels.toArray(new String[labels.size()])));
+        this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostVertex, method) : object, labels.toArray(new String[labels.size()])));
         return path;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
index 1394f89..c5b3a9d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
@@ -53,6 +53,10 @@ public class DetachedProperty<V> implements Property, Serializable, Attachable<P
         this.element = DetachedFactory.detach(element, false);
     }
 
+    public Property get() {
+        return this;
+    }
+
     @Override
     public boolean isPresent() {
         return true;
@@ -95,22 +99,24 @@ public class DetachedProperty<V> implements Property, Serializable, Attachable<P
     }
 
     @Override
-    public Property<V> attach(final Vertex hostVertex) {
-        final Element element = (Element) this.element.attach(hostVertex);
+    public Property<V> attach(final Vertex hostVertex, final Method method) {
+        return (Property<V>) method.apply(this, hostVertex);
+        /*final Element element = (Element) this.element.attach(hostVertex);
         final Property<V> property = element.property(this.key);
         if (property.isPresent() && property.value().equals(this.value))
             return property;
         else
-            throw Attachable.Exceptions.canNotAttachPropertyToHostVertex(this, hostVertex);
+            throw Attachable.Exceptions.canNotAttachPropertyToHostVertex(this, hostVertex);*/
     }
 
     @Override
-    public Property<V> attach(final Graph hostGraph) {
-        final Element hostElement = (Element) this.element.attach(hostGraph);
+    public Property<V> attach(final Graph hostGraph, final Method method) {
+        return (Property<V>) method.apply(this, method);
+        /*final Element hostElement = (Element) this.element.attach(hostGraph);
         final Property<V> property = hostElement.property(this.key);
         if (property.isPresent() && property.value().equals(this.value))
             return property;
         else
-            throw Attachable.Exceptions.canNotAttachPropertyToHostGraph(this, hostGraph);
+            throw Attachable.Exceptions.canNotAttachPropertyToHostGraph(this, hostGraph); */
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertex.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertex.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertex.java
index a4857ef..f0b9b75 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertex.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertex.java
@@ -26,7 +26,6 @@ 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.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
 import java.util.ArrayList;
@@ -126,23 +125,16 @@ public class DetachedVertex extends DetachedElement<Vertex> implements Vertex {
     }
 
     @Override
-    public Vertex attach(final Vertex hostVertex) {
-        if (hostVertex.equals(this))
-            return hostVertex;
-        else
-            throw Attachable.Exceptions.canNotAttachVertexToHostVertex(this, hostVertex);
+    public Vertex attach(final Vertex hostVertex, final Method method) {
+        return (Vertex) method.apply(this, hostVertex);
     }
 
     @Override
-    public Vertex attach(final Graph hostGraph) {
-        final Iterator<Vertex> iterator = hostGraph.vertices(this.id);
-        if(iterator.hasNext())
-            return iterator.next();
-        else
-            throw Attachable.Exceptions.canNotAttachVertexToHostGraph(this, hostGraph);
+    public Vertex attach(final Graph hostGraph, final Method method) {
+        return (Vertex) method.apply(this, hostGraph);
     }
 
-    public static Vertex addTo(final Graph graph, final DetachedVertex detachedVertex) {
+    /*public static Vertex addTo(final Graph graph, final DetachedVertex detachedVertex) {
         final Vertex vertex = graph.addVertex(T.id, detachedVertex.id(), T.label, detachedVertex.label());
         if (null != detachedVertex.properties) {
             detachedVertex.properties.values().forEach(list -> {
@@ -164,7 +156,7 @@ public class DetachedVertex extends DetachedElement<Vertex> implements Vertex {
             });
         }
         return vertex;
-    }
+    } */
 
     @Override
     public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
@@ -178,7 +170,7 @@ public class DetachedVertex extends DetachedElement<Vertex> implements Vertex {
 
     @Override
     public Iterator<Vertex> vertices(final Direction direction, final String... labels) {
-      return Collections.emptyIterator();
+        return Collections.emptyIterator();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
index 8ee0759..675244a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
@@ -22,10 +22,8 @@ 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.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -111,16 +109,18 @@ public class DetachedVertexProperty<V> extends DetachedElement<Property<V>> impl
     }
 
     @Override
-    public VertexProperty<V> attach(final Vertex hostVertex) {
-        final Iterator<VertexProperty<V>> vertexPropertyIterator = IteratorUtils.filter(hostVertex.<V>properties(this.label), vp -> ElementHelper.areEqual(this, vp));
+    public VertexProperty<V> attach(final Vertex hostVertex, final Method method) {
+        return (VertexProperty<V>) method.apply(this, hostVertex);
+        /*final Iterator<VertexProperty<V>> vertexPropertyIterator = IteratorUtils.filter(hostVertex.<V>properties(this.label), vp -> ElementHelper.areEqual(this, vp));
         if (!vertexPropertyIterator.hasNext())
             throw Attachable.Exceptions.canNotAttachVertexPropertyToHostVertex((Attachable) this, hostVertex);
-        return vertexPropertyIterator.next();
+        return vertexPropertyIterator.next(); */
     }
 
     @Override
-    public VertexProperty<V> attach(final Graph hostGraph) {
-        return this.attach(this.vertex.attach(hostGraph));
+    public VertexProperty<V> attach(final Graph hostGraph, final Method method) {
+        return (VertexProperty<V>) method.apply(this, hostGraph);
+        //return this.attach(this.vertex.attach(hostGraph));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java
index b221cc8..2788d3a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java
@@ -27,8 +27,6 @@ import org.apache.tinkerpop.gremlin.structure.Element;
 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.util.Attachable;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
 import java.util.Collections;
 import java.util.Iterator;
@@ -47,19 +45,21 @@ public class ReferenceEdge extends ReferenceElement<Edge> implements Edge {
     }
 
     @Override
-    public Edge attach(final Vertex hostVertex) {
-        final Iterator<Edge> edges = IteratorUtils.filter(hostVertex.edges(Direction.OUT), edge -> edge.id().equals(this.id));
+    public Edge attach(final Vertex hostVertex, final Method method) {
+        return (Edge) method.apply(this, hostVertex);
+       /* final Iterator<Edge> edges = IteratorUtils.filter(hostVertex.edges(Direction.OUT), edge -> edge.id().equals(this.id));
         if (!edges.hasNext())
             throw Attachable.Exceptions.canNotAttachEdgeToHostVertex(this, hostVertex);
-        return edges.next();
+        return edges.next();  */
     }
 
     @Override
-    public Edge attach(final Graph hostGraph) {
-        final Iterator<Edge> edges = hostGraph.edges(this.id);
+    public Edge attach(final Graph hostGraph, final Method method) {
+        return (Edge) method.apply(this, hostGraph);
+        /*final Iterator<Edge> edges = hostGraph.edges(this.id);
         if (!edges.hasNext())
             throw Attachable.Exceptions.canNotAttachEdgeToHostGraph(this, hostGraph);
-        return edges.next();
+        return edges.next(); */
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
index f330395..c7b68b7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
@@ -71,4 +71,8 @@ public abstract class ReferenceElement<E extends Element> implements Element, Se
     public boolean equals(final Object other) {
         return ElementHelper.areEqual(this, other);
     }
+
+    public E get() {
+        return (E) this;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
index c91299e..7b85c17 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
@@ -38,6 +38,10 @@ public class ReferencePath extends MutablePath implements Attachable<Path> {
 
     }
 
+    public Path get() {
+        return this;
+    }
+
     protected ReferencePath(final Path path) {
         path.forEach((object, labels) -> {
             if (object instanceof ReferenceElement || object instanceof ReferenceProperty || object instanceof ReferencePath) {
@@ -60,16 +64,16 @@ public class ReferencePath extends MutablePath implements Attachable<Path> {
     }
 
     @Override
-    public Path attach(final Graph hostGraph) {
+    public Path attach(final Graph hostGraph, final Method method) {
         final Path path = MutablePath.make();  // TODO: Use ImmutablePath?
-        this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostGraph) : object, labels.toArray(new String[labels.size()])));
+        this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostGraph, method) : object, labels.toArray(new String[labels.size()])));
         return path;
     }
 
     @Override
-    public Path attach(final Vertex hostVertex) {
+    public Path attach(final Vertex hostVertex, final Method method) {
         final Path path = MutablePath.make();  // TODO: Use ImmutablePath?
-        this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostVertex) : object, labels.toArray(new String[labels.size()])));
+        this.forEach((object, labels) -> path.extend(object instanceof Attachable ? ((Attachable) object).attach(hostVertex, method) : object, labels.toArray(new String[labels.size()])));
         return path;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
index 47850f5..d68d1aa 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
@@ -45,6 +45,10 @@ public class ReferenceProperty<V> implements Attachable<Property>, Serializable,
 
     }
 
+    public Property get() {
+        return this;
+    }
+
     public ReferenceProperty(final Property<V> property) {
         this.element = ReferenceFactory.detach(property.element());
         this.key = property.key();
@@ -52,21 +56,24 @@ public class ReferenceProperty<V> implements Attachable<Property>, Serializable,
     }
 
     @Override
-    public Property<V> attach(final Vertex hostVertex) throws IllegalStateException {
-        final Property<V> property = this.element.attach(hostVertex).property(this.key);
+    public Property<V> attach(final Vertex hostVertex, final Method method) throws IllegalStateException {
+        return (Property<V>) method.apply(this,hostVertex);
+        /*final Property<V> property = this.element.attach(hostVertex).property(this.key);
         if (property.isPresent() && property.value().equals(this.value))
             return property;
         else
-            throw Attachable.Exceptions.canNotAttachPropertyToHostVertex(this, hostVertex);
+            throw Attachable.Exceptions.canNotAttachPropertyToHostVertex(this, hostVertex); */
     }
 
     @Override
-    public Property<V> attach(final Graph hostGraph) throws IllegalStateException {
-        final Property<V> property = this.element.attach(hostGraph).property(this.key);
+    public Property<V> attach(final Graph hostGraph, final Method method) throws IllegalStateException {
+        return (Property<V>) method.apply(this,hostGraph);
+
+        /*final Property<V> property = this.element.attach(hostGraph).property(this.key);
         if (property.isPresent() && property.value().equals(this.value))
             return property;
         else
-            throw Attachable.Exceptions.canNotAttachPropertyToHostGraph(this, hostGraph);
+            throw Attachable.Exceptions.canNotAttachPropertyToHostGraph(this, hostGraph);*/
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java
index 415ca61..775305d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java
@@ -27,9 +27,7 @@ import org.apache.tinkerpop.gremlin.structure.Element;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 
 import java.util.Collections;
 import java.util.Iterator;
@@ -48,20 +46,22 @@ public class ReferenceVertex extends ReferenceElement<Vertex> implements Vertex
     }
 
     @Override
-    public Vertex attach(final Vertex hostVertex) {
-        if (ElementHelper.areEqual(this,hostVertex))
+    public Vertex attach(final Vertex hostVertex, final Method method) {
+        return (Vertex) method.apply(this, hostVertex);
+        /*if (ElementHelper.areEqual(this,hostVertex))
             return hostVertex;
         else
-            throw Attachable.Exceptions.canNotAttachVertexToHostVertex(this, hostVertex);
+            throw Attachable.Exceptions.canNotAttachVertexToHostVertex(this, hostVertex);  */
     }
 
     @Override
-    public Vertex attach(final Graph hostGraph) {
-        final Iterator<Vertex> iterator = hostGraph.vertices(this.id);
+    public Vertex attach(final Graph hostGraph, final Method method) {
+        return (Vertex) method.apply(this, hostGraph);
+        /*final Iterator<Vertex> iterator = hostGraph.vertices(this.id);
         if (iterator.hasNext())
             return iterator.next();
         else
-            throw Attachable.Exceptions.canNotAttachVertexToHostGraph(this, hostGraph);
+            throw Attachable.Exceptions.canNotAttachVertexToHostGraph(this, hostGraph);   */
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java
index c4cdcf4..8898e75 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java
@@ -26,8 +26,6 @@ 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.util.Attachable;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
 import java.util.Collections;
 import java.util.Iterator;
@@ -50,18 +48,20 @@ public class ReferenceVertexProperty<V> extends ReferenceElement<VertexProperty>
     }
 
     @Override
-    public VertexProperty<V> attach(final Vertex hostVertex) {
-        if (!hostVertex.equals(this.vertex))
+    public VertexProperty<V> attach(final Vertex hostVertex, final Method method) {
+        return (VertexProperty<V>) method.apply(this, hostVertex);
+        /*if (!hostVertex.equals(this.vertex))
             throw Attachable.Exceptions.canNotAttachVertexPropertyToHostVertex(this, hostVertex);
         final Iterator<VertexProperty<V>> vertexPropertyIterator = IteratorUtils.filter(hostVertex.<V>properties(), vp -> vp.id().equals(this.id));
         if (!vertexPropertyIterator.hasNext())
             throw Attachable.Exceptions.canNotAttachVertexPropertyToHostVertex(this, hostVertex);
-        return vertexPropertyIterator.next();
+        return vertexPropertyIterator.next();*/
     }
 
     @Override
-    public VertexProperty<V> attach(final Graph hostGraph) {
-        return this.attach(this.vertex.attach(hostGraph));
+    public VertexProperty<V> attach(final Graph hostGraph, final Method method) {
+        return (VertexProperty<V>) method.apply(this, hostGraph);
+        // return this.attach(this.vertex.attach(hostGraph));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/58a63998/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 9c7385c..b474fdb 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
@@ -33,6 +33,7 @@ import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Transaction;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
@@ -236,7 +237,7 @@ public final class StarGraph implements Graph {
     //// STAR VERTEX ////
     /////////////////////
 
-    public final class StarVertex extends StarElement implements Vertex {
+    public final class StarVertex extends StarElement implements Vertex, Attachable<Vertex> {
 
         private Map<String, List<Edge>> outEdges = new HashMap<>();
         private Map<String, List<Edge>> inEdges = new HashMap<>();
@@ -246,6 +247,18 @@ public final class StarGraph implements Graph {
             super(id, label);
         }
 
+        public Vertex get() {
+            return this;
+        }
+
+        public Vertex attach(final Vertex hostVertex, final Method method) {
+            return (Vertex) method.apply(this, hostVertex);
+        }
+
+        public Vertex attach(final Graph hostGraph, final Method method) {
+            return (Vertex) method.apply(this, hostGraph);
+        }
+
         public void dropEdges() {
             this.outEdges.clear();
             this.inEdges.clear();


[2/5] incubator-tinkerpop git commit: the Method.CREATE, Method.GET, etc. model works for Attachable. A few bugs here and there. Pushing for safety.

Posted by ok...@apache.org.
the Method.CREATE, Method.GET, etc. model works for Attachable. A few bugs here and there. Pushing for safety.


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

Branch: refs/heads/master
Commit: 3545da8da78a2f91ad0fd65aa0c73f3d3ea5754d
Parents: 58a6399
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Apr 21 11:54:45 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Apr 21 11:54:45 2015 -0600

----------------------------------------------------------------------
 .../computer/traversal/TraverserExecutor.java   |  3 +-
 .../traversal/step/map/ComputerResultStep.java  |  2 +-
 .../gremlin/process/traversal/Traverser.java    |  6 ++--
 .../traverser/B_O_PA_S_SE_SL_Traverser.java     |  6 ++--
 .../traverser/util/AbstractPathTraverser.java   | 18 +++++------
 .../traverser/util/AbstractTraverser.java       | 16 +++++----
 .../traverser/util/EmptyTraverser.java          |  9 ++++--
 .../gremlin/structure/util/Attachable.java      | 34 ++++++++++----------
 .../util/detached/DetachedElement.java          |  2 +-
 .../structure/util/detached/DetachedPath.java   |  2 +-
 .../util/detached/DetachedProperty.java         |  2 +-
 .../util/detached/DetachedVertexProperty.java   |  4 +--
 .../util/reference/ReferenceElement.java        |  2 +-
 .../structure/util/reference/ReferencePath.java |  2 +-
 .../util/reference/ReferenceProperty.java       |  2 +-
 .../gremlin/structure/util/star/StarGraph.java  | 10 +++++-
 .../util/detached/DetachedEdgeTest.java         |  5 +--
 .../util/detached/DetachedPropertyTest.java     |  5 +--
 .../detached/DetachedVertexPropertyTest.java    |  5 +--
 .../util/detached/DetachedVertexTest.java       |  5 +--
 .../util/reference/ReferenceEdgeTest.java       |  7 ++--
 .../reference/ReferenceVertexPropertyTest.java  |  5 +--
 .../util/reference/ReferenceVertexTest.java     |  5 +--
 .../process/computer/spark/SparkExecutor.java   | 12 +++++--
 .../computer/spark/SparkGraphComputer.java      |  5 +--
 25 files changed, 103 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraverserExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraverserExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraverserExecutor.java
index f030dfe..5c3ecdb 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraverserExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraverserExecutor.java
@@ -29,6 +29,7 @@ import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Element;
 import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedElement;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
 
@@ -50,7 +51,7 @@ public final class TraverserExecutor {
         messenger.receiveMessages().forEachRemaining(traverserSet -> {
             traverserSet.forEach(traverser -> {
                 traverser.setSideEffects(traversalSideEffects);
-                traverser.attach(vertex);
+                traverser.attach(vertex, Attachable.Method.GET);
                 aliveTraversers.add((Traverser.Admin) traverser);
             });
         });

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/ComputerResultStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/ComputerResultStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/ComputerResultStep.java
index 7ed0f06..b57ad3a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/ComputerResultStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/ComputerResultStep.java
@@ -84,7 +84,7 @@ public final class ComputerResultStep<S> extends AbstractStep<S, S> {
 
         final Traverser.Admin<S> traverser = this.traversers.next();
         if (this.attachElements && (traverser.get() instanceof Attachable))
-            traverser.set((S) ((Attachable) traverser.get()).attach(this.graph));
+            traverser.set((S) ((Attachable) traverser.get()).attach(this.graph, Attachable.Method.GET));
         return traverser;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traverser.java
index d177842..f8e80f6 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Traverser.java
@@ -145,7 +145,7 @@ public interface Traverser<T> extends Serializable, Comparable<Traverser<T>>, Cl
      * The methods in System.Traverser are useful to underlying Step and Traversal implementations.
      * They should not be accessed by the user during lambda-based manipulations.
      */
-    public interface Admin<T> extends Traverser<T>, Attachable<Admin<T>> {
+    public interface Admin<T> extends Traverser<T>, Attachable<T> {
 
         public static final String HALT = "halt";
 
@@ -250,7 +250,7 @@ public interface Traverser<T> extends Serializable, Comparable<Traverser<T>>, Cl
          * @return The inflated traverser
          */
         @Override
-        public Admin<T> attach(final Vertex hostVertex);
+        public T attach(final Vertex hostVertex, final Method method);
 
         /**
          * Traversers can not attach to graphs and thus, an {@link UnsupportedOperationException} is thrown.
@@ -260,7 +260,7 @@ public interface Traverser<T> extends Serializable, Comparable<Traverser<T>>, Cl
          * @throws UnsupportedOperationException is always thrown as it makes no sense to attach a traverser to a graph
          */
         @Override
-        public default Admin<T> attach(final Graph graph) throws UnsupportedOperationException {
+        public default T attach(final Graph graph, final Method method) throws UnsupportedOperationException {
             throw new UnsupportedOperationException("A traverser can only exist at the vertices of the graph, not the graph itself");
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_PA_S_SE_SL_Traverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_PA_S_SE_SL_Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_PA_S_SE_SL_Traverser.java
index 36e78f8..4a8925f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_PA_S_SE_SL_Traverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_PA_S_SE_SL_Traverser.java
@@ -62,12 +62,12 @@ public class B_O_PA_S_SE_SL_Traverser<T> extends AbstractPathTraverser<T> {
     }
 
     @Override
-    public Traverser.Admin<T> attach(final Vertex vertex) {
-        super.attach(vertex);
+    public T attach(final Vertex vertex, final Method method) {
+        super.attach(vertex, method);
         final Path newSparsePath = getOrCreateFromCache(this.sideEffects);
         this.path.forEach((object, labels) -> newSparsePath.extend(object, labels.toArray(new String[labels.size()])));
         this.path = newSparsePath;
-        return this;
+        return this.t;
     }
 
     //////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractPathTraverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractPathTraverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractPathTraverser.java
index ff77e77..73a52de 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractPathTraverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractPathTraverser.java
@@ -23,9 +23,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedElement;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
 
 import java.util.Optional;
 import java.util.function.UnaryOperator;
@@ -148,13 +147,14 @@ public abstract class AbstractPathTraverser<T> implements Traverser<T>, Traverse
     }
 
     @Override
-    public Traverser.Admin<T> attach(final Vertex vertex) {
-        if (this.t instanceof DetachedElement)
-            this.t = (T) ((DetachedElement) this.t).attach(vertex);
-        else if (this.t instanceof DetachedProperty)
-            this.t = (T) ((DetachedProperty) this.t).attach(vertex);
-        // you do not want to attach a path because it will reference graph objects not at the current vertex
-        return this;
+    public T attach(final Vertex vertex, final Method method) {
+        if (this.t instanceof Attachable && !(((Attachable) this.t).getBase() instanceof Path))
+            this.t = ((Attachable<T>) this.t).attach(vertex, method);
+        return this.t;
+    }
+
+    public T getBase() {
+        return this.get();
     }
 
     /////////////////

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
index cb86070..1420905 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
@@ -25,6 +25,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyPath;
 import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversalSideEffects;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceElement;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty;
@@ -108,13 +109,11 @@ public abstract class AbstractTraverser<T> implements Traverser<T>, Traverser.Ad
     }
 
     @Override
-    public Admin<T> attach(final Vertex hostVertex) {
-        if (this.t instanceof ReferenceElement)
-            this.t = (T) ((ReferenceElement) this.t).attach(hostVertex);
-        else if (this.t instanceof ReferenceProperty)
-            this.t = (T) ((ReferenceProperty) this.t).attach(hostVertex);
+    public T attach(final Vertex hostVertex, final Method method) {
+        if(this.t instanceof Attachable && !(((Attachable) this.t).getBase() instanceof Path))
+            this.t = (T) method.apply((Attachable)this.t,hostVertex);
         // you do not want to attach a path because it will reference graph objects not at the current vertex
-        return this;
+        return this.t;
     }
 
     @Override
@@ -134,6 +133,11 @@ public abstract class AbstractTraverser<T> implements Traverser<T>, Traverser.Ad
     }
 
     @Override
+    public T getBase() {
+        return this.t;
+    }
+
+    @Override
     public <S> S sack() {
         throw new UnsupportedOperationException("This traverser does not support sacks: " + this.getClass().getCanonicalName());
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
index 498f6b0..7d843fd 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
@@ -86,8 +86,8 @@ public final class EmptyTraverser<T> implements Traverser<T>, Traverser.Admin<T>
     }
 
     @Override
-    public Admin<T> attach(final Vertex hostVertex) {
-        return this;
+    public T attach(final Vertex hostVertex, final Method method) {
+        return null;
     }
 
     @Override
@@ -101,6 +101,11 @@ public final class EmptyTraverser<T> implements Traverser<T>, Traverser.Admin<T>
     }
 
     @Override
+    public T getBase() {
+        return null;
+    }
+
+    @Override
     public <S> S sack() {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
index ba50374..65bd610 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
@@ -43,7 +43,7 @@ public interface Attachable<T> {
         GET {
             @Override
             public Object apply(final Attachable attachable, final Object hostVertexOrGraph) {
-                final Object base = attachable.get();
+                final Object base = attachable.getBase();
                 if (base instanceof Vertex) {
                     final Optional<Vertex> optional = hostVertexOrGraph instanceof Graph ?
                             Method.getVertex(attachable, (Graph) hostVertexOrGraph) :
@@ -73,7 +73,7 @@ public interface Attachable<T> {
         CREATE {
             @Override
             public Object apply(final Attachable attachable, final Object hostVertexOrGraph) {
-                final Object base = attachable.get();
+                final Object base = attachable.getBase();
                 if (base instanceof Vertex) {
                     return hostVertexOrGraph instanceof Graph ?
                             Method.createVertex(attachable, (Graph) hostVertexOrGraph) :
@@ -99,21 +99,21 @@ public interface Attachable<T> {
         ///////////////////
 
         public static Optional<Vertex> getVertex(final Attachable<Vertex> attachableVertex, final Graph hostGraph) {
-            final Iterator<Vertex> vertexIterator = hostGraph.vertices(attachableVertex.get().id());
+            final Iterator<Vertex> vertexIterator = hostGraph.vertices(attachableVertex.getBase().id());
             return vertexIterator.hasNext() ? Optional.of(vertexIterator.next()) : Optional.empty();
         }
 
         public static Optional<Vertex> getVertex(final Attachable<Vertex> attachableVertex, final Vertex hostVertex) {
-            return ElementHelper.areEqual(attachableVertex.get(), hostVertex) ? Optional.of(hostVertex) : Optional.empty();
+            return ElementHelper.areEqual(attachableVertex.getBase(), hostVertex) ? Optional.of(hostVertex) : Optional.empty();
         }
 
         public static Optional<Edge> getEdge(final Attachable<Edge> attachableEdge, final Graph hostGraph) {
-            final Iterator<Edge> edgeIterator = hostGraph.edges(attachableEdge.get().id());
+            final Iterator<Edge> edgeIterator = hostGraph.edges(attachableEdge.getBase().id());
             return edgeIterator.hasNext() ? Optional.of(edgeIterator.next()) : Optional.empty();
         }
 
         public static Optional<Edge> getEdge(final Attachable<Edge> attachableEdge, final Vertex hostVertex) {
-            final Object baseId = attachableEdge.get().id();
+            final Object baseId = attachableEdge.getBase().id();
             final Iterator<Edge> edgeIterator = hostVertex.edges(Direction.OUT);
             while (edgeIterator.hasNext()) {
                 final Edge edge = edgeIterator.next();
@@ -124,7 +124,7 @@ public interface Attachable<T> {
         }
 
         public static Optional<VertexProperty> getVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Graph hostGraph) {
-            final VertexProperty baseVertexProperty = attachableVertexProperty.get();
+            final VertexProperty baseVertexProperty = attachableVertexProperty.getBase();
             final Iterator<Vertex> vertexIterator = hostGraph.vertices(baseVertexProperty.element().id());
             if (vertexIterator.hasNext()) {
                 final Iterator<VertexProperty<Object>> vertexPropertyIterator = vertexIterator.next().properties(baseVertexProperty.key());
@@ -138,7 +138,7 @@ public interface Attachable<T> {
         }
 
         public static Optional<VertexProperty> getVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Vertex hostVertex) {
-            final VertexProperty baseVertexProperty = attachableVertexProperty.get();
+            final VertexProperty baseVertexProperty = attachableVertexProperty.getBase();
             final Iterator<VertexProperty<Object>> vertexPropertyIterator = hostVertex.properties(baseVertexProperty.key());
             while (vertexPropertyIterator.hasNext()) {
                 final VertexProperty vertexProperty = vertexPropertyIterator.next();
@@ -149,8 +149,8 @@ public interface Attachable<T> {
         }
 
         public static Optional<Property> getProperty(final Attachable<Property> attachableProperty, final Graph hostGraph) {
-            final Property baseProperty = attachableProperty.get();
-            final Element propertyElement = attachableProperty.get().element();
+            final Property baseProperty = attachableProperty.getBase();
+            final Element propertyElement = attachableProperty.getBase().element();
             if (propertyElement instanceof Edge) {
                 final Iterator<Edge> edgeIterator = hostGraph.edges(propertyElement.id());
                 if (edgeIterator.hasNext()) {
@@ -179,8 +179,8 @@ public interface Attachable<T> {
         }
 
         public static Optional<Property> getProperty(final Attachable<Property> attachableProperty, final Vertex hostVertex) {
-            final Property baseProperty = attachableProperty.get();
-            final Element propertyElement = attachableProperty.get().element();
+            final Property baseProperty = attachableProperty.getBase();
+            final Element propertyElement = attachableProperty.getBase().element();
             if (propertyElement instanceof Edge) {
                 final Iterator<Edge> edgeIterator = hostVertex.edges(Direction.OUT);
                 if (edgeIterator.hasNext()) {
@@ -208,7 +208,7 @@ public interface Attachable<T> {
         /////
 
         public static Vertex createVertex(final Attachable<Vertex> attachableVertex, final Graph hostGraph) {
-            final Vertex baseVertex = attachableVertex.get();
+            final Vertex baseVertex = attachableVertex.getBase();
             final List<Object> keyValues = new ArrayList<>();
             keyValues.add(org.apache.tinkerpop.gremlin.process.traversal.T.id);
             keyValues.add(baseVertex.id());
@@ -227,7 +227,7 @@ public interface Attachable<T> {
         }
 
         public static Edge createEdge(final Attachable<Edge> attachableEdge, final Graph hostGraph) {
-            final Edge baseEdge = attachableEdge.get();
+            final Edge baseEdge = attachableEdge.getBase();
             Iterator<Vertex> vertices = hostGraph.vertices(baseEdge.outVertex().id());
             final Vertex outV = vertices.hasNext() ? vertices.next() : hostGraph.addVertex(org.apache.tinkerpop.gremlin.process.traversal.T.id, baseEdge.outVertex().id());
             vertices = hostGraph.vertices(baseEdge.inVertex().id());
@@ -250,7 +250,7 @@ public interface Attachable<T> {
         }
 
         public static VertexProperty createVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Graph hostGraph) {
-            final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.get();
+            final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.getBase();
             final Iterator<Vertex> vertexIterator = hostGraph.vertices(baseVertexProperty.element().id());
             if (vertexIterator.hasNext()) {
                 final VertexProperty vertexProperty = vertexIterator.next().property(VertexProperty.Cardinality.list, baseVertexProperty.key(), baseVertexProperty.value(), org.apache.tinkerpop.gremlin.process.traversal.T.id, baseVertexProperty.id());
@@ -261,7 +261,7 @@ public interface Attachable<T> {
         }
 
         public static VertexProperty createVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Vertex hostVertex) {
-            final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.get();
+            final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.getBase();
             final VertexProperty vertexProperty = hostVertex.property(VertexProperty.Cardinality.list, baseVertexProperty.key(), baseVertexProperty.value(), org.apache.tinkerpop.gremlin.process.traversal.T.id, baseVertexProperty.id());
             baseVertexProperty.properties().forEachRemaining(p -> vertexProperty.property(p.key(), p.value()));
             return vertexProperty;
@@ -278,7 +278,7 @@ public interface Attachable<T> {
 
     }
 
-    public T get();
+    public T getBase();
 
     public T attach(final Vertex hostVertex, final Method method) throws IllegalStateException;
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
index b748633..1da69f3 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
@@ -97,7 +97,7 @@ public abstract class DetachedElement<E> implements Element, Serializable, Attac
                 (Iterator) this.properties.entrySet().stream().filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys)).flatMap(entry -> entry.getValue().stream()).iterator();
     }
 
-    public E get() {
+    public E getBase() {
         return (E) this;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
index 8610922..9d971d9 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
@@ -35,7 +35,7 @@ public class DetachedPath extends MutablePath implements Attachable<Path> {
 
     }
 
-    public Path get() {
+    public Path getBase() {
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
index c5b3a9d..a4d4a0c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
@@ -53,7 +53,7 @@ public class DetachedProperty<V> implements Property, Serializable, Attachable<P
         this.element = DetachedFactory.detach(element, false);
     }
 
-    public Property get() {
+    public Property getBase() {
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
index 675244a..700f0d5 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
@@ -128,9 +128,9 @@ public class DetachedVertexProperty<V> extends DetachedElement<Property<V>> impl
         return (Iterator) super.properties(propertyKeys);
     }
 
-    public static <V> VertexProperty<V> addTo(final Vertex vertex, final DetachedVertexProperty<V> detachedVertexProperty) {
+    /*public static <V> VertexProperty<V> addTo(final Vertex vertex, final DetachedVertexProperty<V> detachedVertexProperty) {
         final VertexProperty<V> vertexProperty = vertex.property(VertexProperty.Cardinality.single, detachedVertexProperty.key(), detachedVertexProperty.value()); // TODO: this isn't right, is it? (need to remove views from Spark/Giraph)
         detachedVertexProperty.properties().forEachRemaining(property -> vertexProperty.property(property.key(), property.value()));
         return vertexProperty;
-    }
+    }*/
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
index c7b68b7..0bcf37c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
@@ -72,7 +72,7 @@ public abstract class ReferenceElement<E extends Element> implements Element, Se
         return ElementHelper.areEqual(this, other);
     }
 
-    public E get() {
+    public E getBase() {
         return (E) this;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
index 7b85c17..b52b93d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
@@ -38,7 +38,7 @@ public class ReferencePath extends MutablePath implements Attachable<Path> {
 
     }
 
-    public Path get() {
+    public Path getBase() {
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
index d68d1aa..c034629 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
@@ -45,7 +45,7 @@ public class ReferenceProperty<V> implements Attachable<Property>, Serializable,
 
     }
 
-    public Property get() {
+    public Property getBase() {
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/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 b474fdb..ccfe7d9 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
@@ -247,7 +247,7 @@ public final class StarGraph implements Graph {
             super(id, label);
         }
 
-        public Vertex get() {
+        public Vertex getBase() {
             return this;
         }
 
@@ -264,6 +264,14 @@ public final class StarGraph implements Graph {
             this.inEdges.clear();
         }
 
+        public void dropVertexProperties(final String... keys) {
+            if (null != keys) {  // TODO: this is bad
+                for (final String key : keys) {
+                    this.vertexProperties.remove(key);
+                }
+            }
+        }
+
         @Override
         public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
             return this.addOutEdge(label, inVertex, keyValues);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdgeTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdgeTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdgeTest.java
index eaf62b1..0bd9b1b 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdgeTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdgeTest.java
@@ -26,6 +26,7 @@ import org.apache.tinkerpop.gremlin.structure.Direction;
 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.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 import org.apache.tinkerpop.gremlin.util.StreamFactory;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
@@ -125,7 +126,7 @@ public class DetachedEdgeTest extends AbstractGremlinTest {
     public void shouldAttachToGraph() {
         final Edge toDetach = g.E(convertToEdgeId("josh", "created", "lop")).next();
         final DetachedEdge detachedEdge = DetachedFactory.detach(toDetach, true);
-        final Edge attached = detachedEdge.attach(graph);
+        final Edge attached = detachedEdge.attach(graph, Attachable.Method.GET);
 
         assertEquals(toDetach, attached);
         assertFalse(attached instanceof DetachedEdge);
@@ -137,7 +138,7 @@ public class DetachedEdgeTest extends AbstractGremlinTest {
         final Edge toDetach = g.E(convertToEdgeId("josh", "created", "lop")).next();
         final Vertex outV = toDetach.vertices(Direction.OUT).next();
         final DetachedEdge detachedEdge = DetachedFactory.detach(toDetach, true);
-        final Edge attached = detachedEdge.attach(outV);
+        final Edge attached = detachedEdge.attach(outV, Attachable.Method.GET);
 
         assertEquals(toDetach, attached);
         assertFalse(attached instanceof DetachedEdge);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
index 299d089..674bafc 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
@@ -27,6 +27,7 @@ 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.util.Attachable;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -72,7 +73,7 @@ public class DetachedPropertyTest extends AbstractGremlinTest {
         final Edge e = g.E(convertToEdgeId("josh", "created", "lop")).next();
         final Property toDetach = e.properties("weight").next();
         final DetachedProperty detachedProperty = DetachedFactory.detach(toDetach);
-        final Property attached = detachedProperty.attach(graph);
+        final Property attached = detachedProperty.attach(graph, Attachable.Method.GET);
 
         assertEquals(toDetach, attached);
         assertFalse(attached instanceof DetachedProperty);
@@ -84,7 +85,7 @@ public class DetachedPropertyTest extends AbstractGremlinTest {
         final Edge e = g.E(convertToEdgeId("josh", "created", "lop")).next();
         final Property toDetach = e.property("weight");
         final DetachedProperty detachedProperty = DetachedFactory.detach(toDetach);
-        final Property attached = detachedProperty.attach(e.outVertex());
+        final Property attached = detachedProperty.attach(e.outVertex(), Attachable.Method.GET);
 
         assertEquals(toDetach, attached);
         assertFalse(attached instanceof DetachedProperty);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
index b9ae3ba..a363373 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
@@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.util.StreamFactory;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Test;
@@ -127,7 +128,7 @@ public class DetachedVertexPropertyTest extends AbstractGremlinTest {
         final Vertex v = graph.addVertex();
         final VertexProperty toDetach = v.property(VertexProperty.Cardinality.single, "test", "this");
         final DetachedVertexProperty detached = DetachedFactory.detach(toDetach, true);
-        final VertexProperty attached = detached.attach(graph);
+        final VertexProperty attached = detached.attach(graph, Attachable.Method.GET);
 
         assertEquals(toDetach, attached);
         assertFalse(attached instanceof DetachedVertexProperty);
@@ -139,7 +140,7 @@ public class DetachedVertexPropertyTest extends AbstractGremlinTest {
         final Vertex v = graph.addVertex();
         final VertexProperty toDetach = v.property(VertexProperty.Cardinality.single, "test", "this");
         final DetachedVertexProperty detached = DetachedFactory.detach(toDetach, true);
-        final VertexProperty attached = detached.attach(v);
+        final VertexProperty attached = detached.attach(v, Attachable.Method.GET);
 
         assertEquals(toDetach, attached);
         assertEquals(toDetach.getClass(), attached.getClass());

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexTest.java
index add7797..f1fcc33 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexTest.java
@@ -25,6 +25,7 @@ import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Test;
@@ -136,7 +137,7 @@ public class DetachedVertexTest extends AbstractGremlinTest {
     public void shouldAttachToGraph() {
         final Vertex toDetach = g.V(convertToVertexId("josh")).next();
         final DetachedVertex detachedVertex = DetachedFactory.detach(toDetach, true);
-        final Vertex attached = detachedVertex.attach(graph);
+        final Vertex attached = detachedVertex.attach(graph, Attachable.Method.GET);
 
         assertEquals(toDetach, attached);
         assertFalse(attached instanceof DetachedVertex);
@@ -147,7 +148,7 @@ public class DetachedVertexTest extends AbstractGremlinTest {
     public void shouldAttachToVertex() {
         final Vertex toDetach = g.V(convertToVertexId("josh")).next();
         final DetachedVertex detachedVertex = DetachedFactory.detach(toDetach, true);
-        final Vertex attached = detachedVertex.attach(toDetach);
+        final Vertex attached = detachedVertex.attach(toDetach, Attachable.Method.GET);
 
         assertEquals(toDetach, attached);
         assertFalse(attached instanceof DetachedVertex);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdgeTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdgeTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdgeTest.java
index 616d26e..20e4073 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdgeTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdgeTest.java
@@ -29,6 +29,7 @@ import org.apache.tinkerpop.gremlin.structure.Direction;
 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.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Test;
@@ -102,7 +103,7 @@ public class ReferenceEdgeTest extends AbstractGremlinTest {
     public void shouldAttachToGraph() {
         final Edge toReference = g.E(convertToEdgeId("josh", "created", "lop")).next();
         final ReferenceEdge referenceEdge = ReferenceFactory.detach(toReference);
-        final Edge referenced = referenceEdge.attach(graph);
+        final Edge referenced = referenceEdge.attach(graph, Attachable.Method.GET);
 
         assertEquals(toReference, referenced);
         assertFalse(referenced instanceof ReferenceEdge);
@@ -113,8 +114,8 @@ public class ReferenceEdgeTest extends AbstractGremlinTest {
     public void shouldAttachToVertex() {
         final Edge toReference = g.E(convertToEdgeId("josh", "created", "lop")).next();
         final Vertex outV = toReference.vertices(Direction.OUT).next();
-        final ReferenceEdge detachedEdge = ReferenceFactory.detach(toReference);
-        final Edge attached = detachedEdge.attach(outV);
+        final ReferenceEdge referenceEdge = ReferenceFactory.detach(toReference);
+        final Edge attached = referenceEdge.attach(outV, Attachable.Method.GET);
 
         assertEquals(toReference, attached);
         assertFalse(attached instanceof ReferenceEdge);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
index 95be726..4f6e17f 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
@@ -25,6 +25,7 @@ import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
 import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -80,7 +81,7 @@ public class ReferenceVertexPropertyTest extends AbstractGremlinTest {
         final Vertex v = graph.addVertex();
         final VertexProperty toReference = v.property(VertexProperty.Cardinality.single, "test", "this");
         final ReferenceVertexProperty rvp = ReferenceFactory.detach(toReference);
-        final VertexProperty referenced = rvp.attach(graph);
+        final VertexProperty referenced = rvp.attach(graph, Attachable.Method.GET);
 
         assertEquals(toReference, referenced);
         assertFalse(referenced instanceof ReferenceVertexProperty);
@@ -92,7 +93,7 @@ public class ReferenceVertexPropertyTest extends AbstractGremlinTest {
         final Vertex v = graph.addVertex();
         final VertexProperty toReference = v.property(VertexProperty.Cardinality.single, "test", "this");
         final ReferenceVertexProperty rvp = ReferenceFactory.detach(toReference);
-        final VertexProperty referenced = rvp.attach(v);
+        final VertexProperty referenced = rvp.attach(v, Attachable.Method.GET);
 
         assertEquals(toReference, referenced);
         assertEquals(toReference.getClass(), referenced.getClass());

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexTest.java
index a2fa663..41e9c67 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexTest.java
@@ -29,6 +29,7 @@ import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Test;
@@ -102,7 +103,7 @@ public class ReferenceVertexTest extends AbstractGremlinTest {
     public void shouldAttachToGraph() {
         final Vertex v = g.V(convertToVertexId("josh")).next();
         final ReferenceVertex referenceVertex = ReferenceFactory.detach(v);
-        final Vertex attachedV = referenceVertex.attach(graph);
+        final Vertex attachedV = referenceVertex.attach(graph, Attachable.Method.GET);
 
         assertEquals(v, attachedV);
         assertFalse(attachedV instanceof ReferenceVertex);
@@ -113,7 +114,7 @@ public class ReferenceVertexTest extends AbstractGremlinTest {
     public void shouldAttachToVertex() {
         final Vertex v = g.V(convertToVertexId("josh")).next();
         final ReferenceVertex referenceVertex = ReferenceFactory.detach(v);
-        final Vertex attachedV = referenceVertex.attach(v);
+        final Vertex attachedV = referenceVertex.attach(v, Attachable.Method.GET);
 
         assertEquals(v, attachedV);
         assertFalse(attachedV instanceof ReferenceVertex);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkExecutor.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkExecutor.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkExecutor.java
index 5203b21..af0a6a6 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkExecutor.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkExecutor.java
@@ -41,6 +41,8 @@ import org.apache.tinkerpop.gremlin.process.computer.Memory;
 import org.apache.tinkerpop.gremlin.process.computer.MessageCombiner;
 import org.apache.tinkerpop.gremlin.process.computer.VertexProgram;
 import org.apache.tinkerpop.gremlin.process.computer.util.ComputerGraph;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
@@ -83,10 +85,12 @@ public final class SparkExecutor {
                     workerVertexProgram.workerIterationStart(memory); // start the worker
                     return () -> IteratorUtils.map(partitionIterator, vertexViewIncoming -> {
                         final Vertex vertex = vertexViewIncoming._2()._1().get(); // get the vertex from the vertex writable
+                        // drop any compute properties that are in memory
+                        ((StarGraph.StarVertex)vertex).dropVertexProperties(elementComputeKeysArray);
                         final boolean hasViewAndMessages = vertexViewIncoming._2()._2().isPresent(); // if this is the first iteration, then there are no views or messages
                         final List<DetachedVertexProperty<Object>> previousView = hasViewAndMessages ? vertexViewIncoming._2()._2().get().getView() : Collections.emptyList();
                         final List<M> incomingMessages = hasViewAndMessages ? vertexViewIncoming._2()._2().get().getIncomingMessages() : Collections.emptyList();
-                        previousView.forEach(property -> DetachedVertexProperty.addTo(vertex, property));  // attach the view to the vertex
+                        previousView.forEach(property -> property.attach(vertex, Attachable.Method.CREATE));  // attach the view to the vertex
                         ///
                         messenger.setVertexAndIncomingMessages(vertex, incomingMessages); // set the messenger with the incoming messages
                         workerVertexProgram.execute(ComputerGraph.of(vertex, elementComputeKeys), messenger, memory); // execute the vertex program on this vertex for this iteration
@@ -137,18 +141,20 @@ public final class SparkExecutor {
     // MAP REDUCE //
     ////////////////
 
-    public static <M> JavaPairRDD<Object, VertexWritable> prepareGraphRDDForMapReduce(final JavaPairRDD<Object, VertexWritable> graphRDD, final JavaPairRDD<Object, ViewIncomingPayload<M>> viewIncomingRDD) {
+    public static <M> JavaPairRDD<Object, VertexWritable> prepareGraphRDDForMapReduce(final JavaPairRDD<Object, VertexWritable> graphRDD, final JavaPairRDD<Object, ViewIncomingPayload<M>> viewIncomingRDD, final String[] elementComputeKeys) {
         return (null == viewIncomingRDD) ?
                 graphRDD.mapValues(vertexWritable -> {
                     ((StarGraph.StarVertex)vertexWritable.get()).dropEdges();
+                    ((StarGraph.StarVertex)vertexWritable.get()).dropVertexProperties(elementComputeKeys);
                     return vertexWritable;
                 }) :
                 graphRDD.leftOuterJoin(viewIncomingRDD)
                         .mapValues(tuple -> {
                             final Vertex vertex = tuple._1().get();
                             ((StarGraph.StarVertex)vertex).dropEdges();
+                            ((StarGraph.StarVertex)vertex).dropVertexProperties(elementComputeKeys);
                             final List<DetachedVertexProperty<Object>> view = tuple._2().isPresent() ? tuple._2().get().getView() : Collections.emptyList();
-                            view.forEach(property -> DetachedVertexProperty.addTo(vertex, property));
+                            view.forEach(property -> property.attach(vertex, Attachable.Method.CREATE));
                             return tuple._1();
                         });
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3545da8d/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkGraphComputer.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkGraphComputer.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkGraphComputer.java
index 1b51690..d40b932 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkGraphComputer.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkGraphComputer.java
@@ -67,7 +67,7 @@ public final class SparkGraphComputer implements GraphComputer {
     protected final HadoopGraph hadoopGraph;
     private boolean executed = false;
     private final Set<MapReduce> mapReducers = new HashSet<>();
-    private VertexProgram vertexProgram;
+    private VertexProgram<Object> vertexProgram;
 
     private Optional<ResultGraph> resultGraph = Optional.empty();
     private Optional<Persist> persist = Optional.empty();
@@ -214,7 +214,8 @@ public final class SparkGraphComputer implements GraphComputer {
                         //////////////////////////////
                         if (!this.mapReducers.isEmpty()) {
                             // drop all edges and messages in the graphRDD as they are no longer needed for the map reduce jobs
-                            final JavaPairRDD<Object, VertexWritable> mapReduceGraphRDD = SparkExecutor.prepareGraphRDDForMapReduce(graphRDD, viewIncomingRDD).setName("mapReduceGraphRDD").cache();
+                            final String[] elementComputeKeys = this.vertexProgram == null ? new String[0] : this.vertexProgram.getElementComputeKeys().toArray(new String[this.vertexProgram.getElementComputeKeys().size()]);
+                            final JavaPairRDD<Object, VertexWritable> mapReduceGraphRDD = SparkExecutor.prepareGraphRDDForMapReduce(graphRDD, viewIncomingRDD, elementComputeKeys).setName("mapReduceGraphRDD").cache();
                             for (final MapReduce mapReduce : this.mapReducers) {
                                 // execute the map reduce job
                                 final HadoopConfiguration newApacheConfiguration = new HadoopConfiguration(apacheConfiguration);


[5/5] incubator-tinkerpop git commit: updated CHANGELOG with Attachable updates.

Posted by ok...@apache.org.
updated CHANGELOG with Attachable updates.


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

Branch: refs/heads/master
Commit: 037428f25ae1c99799dfaf49824b5c2ae520c7f9
Parents: e623693
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Apr 21 14:48:29 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Apr 21 14:48:29 2015 -0600

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


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/037428f2/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 282f561..6f5bfb5 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -25,6 +25,7 @@ image::http://www.tinkerpop.com/docs/current/images/gremlin-hindu.png[width=225]
 TinkerPop 3.0.0.M9 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* `Attachable.attach()` now takes a `Method` to determine whether to attach via `GET`, `CREATE`, or `GET_OR_CREATE`.
 * Decreased size of Gremlin Server `RequestMessage` and `ResponseMessage` serialization payloads and reduced object creation.
 * `Graph.empty()` no longer required with the introduction of `ShellGraph` which is a placeholder for a graph class and computer.
 * `VertexProperty.Cardinality` default is now vendor chosen. If the vendor has not preference, they should use `Cardinality.single`.


[4/5] incubator-tinkerpop git commit: removed StarGraph.addTo(). Added VertexWritableTest to make sure serialization of the writable preserves form. Added some JavaDoc here and there.

Posted by ok...@apache.org.
removed StarGraph.addTo(). Added VertexWritableTest to make sure serialization of the writable preserves form. Added some JavaDoc here and there.


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

Branch: refs/heads/master
Commit: e6236935dd8714686016a5492697bf710fa97400
Parents: a3381b3
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Apr 21 14:11:09 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Apr 21 14:11:09 2015 -0600

----------------------------------------------------------------------
 .../gremlin/structure/util/Attachable.java      | 20 ++--
 .../gremlin/structure/util/star/StarGraph.java  | 52 +++++------
 .../hadoop/structure/io/VertexWritable.java     |  7 +-
 .../io/graphson/GraphSONRecordReader.java       |  7 +-
 .../structure/io/gryo/GryoRecordReader.java     |  7 +-
 .../hadoop/structure/io/VertexWritableTest.java | 96 ++++++++++++++++++++
 .../tinkergraph/structure/TinkerGraphTest.java  | 15 +--
 7 files changed, 145 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6236935/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
index 7ec5417..7c07687 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
@@ -26,19 +26,26 @@ import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
 
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Optional;
 import java.util.function.BiFunction;
 
 /**
  * An interface that provides methods for detached properties and elements to be re-attached to the {@link Graph}.
+ * There are two general ways in which they can be attached: {@link Method#GET} or {@link Method#CREATE}.
+ * A {@link Method#GET} will find the property/element at the host location and return it.
+ * A {@link Method#CREATE} will create the property/element at the host location and return it.
  *
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public interface Attachable<T> {
 
+    /**
+     * Get the raw object trying to be attached.
+     *
+     * @return the raw object to attach
+     */
     public T get();
 
     public default T attach(final Vertex hostVertex, final Method method) throws IllegalStateException {
@@ -269,14 +276,9 @@ public interface Attachable<T> {
 
         public static Vertex createVertex(final Attachable<Vertex> attachableVertex, final Graph hostGraph) {
             final Vertex baseVertex = attachableVertex.get();
-            final List<Object> keyValues = new ArrayList<>();
-            keyValues.add(org.apache.tinkerpop.gremlin.process.traversal.T.id);
-            keyValues.add(baseVertex.id());
-            keyValues.add(org.apache.tinkerpop.gremlin.process.traversal.T.label);
-            keyValues.add(baseVertex.label());
-            final Vertex vertex = hostGraph.addVertex(keyValues.toArray());
+            final Vertex vertex = hostGraph.addVertex(org.apache.tinkerpop.gremlin.process.traversal.T.id, baseVertex.id(), org.apache.tinkerpop.gremlin.process.traversal.T.label, baseVertex.label());
             baseVertex.properties().forEachRemaining(vp -> {
-                final VertexProperty vertexProperty = vertex.property(VertexProperty.Cardinality.list, vp.key(), vp.value());
+                final VertexProperty vertexProperty = vertex.property(VertexProperty.Cardinality.list, vp.key(), vp.value(), org.apache.tinkerpop.gremlin.process.traversal.T.id, vp.id());
                 vp.properties().forEachRemaining(p -> vertexProperty.property(p.key(), p.value()));
             });
             return vertex;

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6236935/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 57d5bb9..20141c2 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
@@ -36,9 +36,6 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
 import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
 import java.util.ArrayList;
@@ -67,15 +64,21 @@ public final class StarGraph implements Graph {
     private final Map<Object, Map<String, Object>> edgeProperties = new HashMap<>();
     private final Map<Object, Map<String, Object>> metaProperties = new HashMap<>();
 
+    private StarGraph() {
+    }
+
     public StarVertex getStarVertex() {
         return this.starVertex;
     }
 
     @Override
     public Vertex addVertex(final Object... keyValues) {
-        return null == this.starVertex ?
-                this.starVertex = new StarVertex(ElementHelper.getIdValue(keyValues).get(), ElementHelper.getLabelValue(keyValues).get()) :
-                new StarAdjacentVertex(ElementHelper.getIdValue(keyValues).get());
+        if (null == this.starVertex) {
+            this.starVertex = new StarVertex(ElementHelper.getIdValue(keyValues).get(), ElementHelper.getLabelValue(keyValues).get());
+            ElementHelper.attachProperties(this.starVertex, VertexProperty.Cardinality.list, keyValues); // TODO: is this smart? I say no... cause vertex property ids are not preserved.
+            return this.starVertex;
+        } else
+            return new StarAdjacentVertex(ElementHelper.getIdValue(keyValues).get());
     }
 
     @Override
@@ -165,28 +168,23 @@ public final class StarGraph implements Graph {
 
     public static StarGraph of(final Vertex vertex) {
         final StarGraph starGraph = new StarGraph();
-        StarGraph.addTo(starGraph, DetachedFactory.detach(vertex, true));
-        vertex.edges(Direction.BOTH).forEachRemaining(edge -> StarGraph.addTo(starGraph, DetachedFactory.detach(edge, true)));
-        return starGraph;
-    }
-
-    public static Vertex addTo(final StarGraph graph, final DetachedVertex detachedVertex) {
-        if (null != graph.starVertex)
-            return null;
-        graph.addVertex(T.id, detachedVertex.id(), T.label, detachedVertex.label());
-        detachedVertex.properties().forEachRemaining(detachedVertexProperty -> {
-            final VertexProperty<?> starVertexProperty = graph.starVertex.property(VertexProperty.Cardinality.list, detachedVertexProperty.key(), detachedVertexProperty.value(), T.id, detachedVertexProperty.id());
-            detachedVertexProperty.properties().forEachRemaining(detachedVertexPropertyProperty -> starVertexProperty.property(detachedVertexPropertyProperty.key(), detachedVertexPropertyProperty.value()));
+        final StarVertex starVertex = (StarVertex) starGraph.addVertex(T.id, vertex.id(), T.label, vertex.label());
+        vertex.properties().forEachRemaining(vp -> {
+            final VertexProperty<?> starVertexProperty = starVertex.property(VertexProperty.Cardinality.list, vp.key(), vp.value(), T.id, vp.id());
+            vp.properties().forEachRemaining(p -> starVertexProperty.property(p.key(), p.value()));
+        });
+        vertex.edges(Direction.IN).forEachRemaining(edge -> {
+            final Edge starEdge = starVertex.addInEdge(edge.label(), starGraph.addVertex(T.id, edge.outVertex().id()), T.id, edge.id());
+            edge.properties().forEachRemaining(p -> starEdge.property(p.key(), p.value()));
         });
-        return graph.starVertex;
-    }
 
-    public static Edge addTo(final StarGraph graph, final DetachedEdge edge) {
-        final Edge starEdge = !graph.starVertex.id().equals(edge.inVertex().id()) ?
-                graph.starVertex.addOutEdge(edge.label(), edge.inVertex(), T.id, edge.id()) :
-                graph.starVertex.addInEdge(edge.label(), edge.outVertex(), T.id, edge.id());
-        edge.properties().forEachRemaining(property -> starEdge.property(property.key(), property.value()));
-        return starEdge;
+        vertex.edges(Direction.OUT).forEachRemaining(edge -> {
+            if (!ElementHelper.areEqual(starVertex, edge.inVertex())) { // only do a self loop once
+                final Edge starEdge = starVertex.addOutEdge(edge.label(), starGraph.addVertex(T.id, edge.inVertex().id()), T.id, edge.id());
+                edge.properties().forEachRemaining(p -> starEdge.property(p.key(), p.value()));
+            }
+        });
+        return starGraph;
     }
 
     protected Long generateId() {
@@ -406,7 +404,7 @@ public final class StarGraph implements Graph {
 
         @Override
         public Vertex element() {
-            return starVertex;
+            return StarGraph.this.starVertex;
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6236935/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
index fad244b..40057aa 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
@@ -20,10 +20,11 @@ package org.apache.tinkerpop.gremlin.hadoop.structure.io;
 
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableUtils;
-import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
 import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
+import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -66,8 +67,8 @@ public final class VertexWritable implements Writable, Serializable {
                     final ByteArrayInputStream inputStream = new ByteArrayInputStream(WritableUtils.readCompressedByteArray(input));
                     final StarGraph starGraph = StarGraph.open();
                     return gryoReader.readVertex(inputStream, Direction.BOTH,
-                            detachedVertex -> StarGraph.addTo(starGraph, detachedVertex),
-                            detachedEdge -> StarGraph.addTo(starGraph, detachedEdge));
+                            detachedVertex -> detachedVertex.attach(starGraph, Attachable.Method.CREATE),
+                            detachedEdge -> detachedEdge.attach(starGraph, Attachable.Method.CREATE));
                 } catch (final IOException e) {
                     throw new IllegalStateException(e.getMessage(), e);
                 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6236935/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 87cfbb8..a46494d 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
@@ -25,13 +25,14 @@ import org.apache.hadoop.mapreduce.TaskAttemptContext;
 import org.apache.hadoop.mapreduce.lib.input.LineRecordReader;
 import org.apache.tinkerpop.gremlin.hadoop.Constants;
 import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
-import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
 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.io.graphson.GraphSONReader;
+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.gremlin.structure.util.star.StarGraph;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -64,8 +65,8 @@ public class GraphSONRecordReader extends RecordReader<NullWritable, VertexWrita
             return false;
 
         final StarGraph starGraph = StarGraph.open();
-        final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> StarGraph.addTo(starGraph, detachedVertex);
-        final Function<DetachedEdge, Edge> edgeMaker = detachedEdge -> StarGraph.addTo(starGraph, detachedEdge);
+        final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> detachedVertex.attach(starGraph, Attachable.Method.CREATE);
+        final Function<DetachedEdge, 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/e6236935/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 2eb94ea..5fff9c8 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
@@ -29,14 +29,15 @@ import org.apache.hadoop.mapreduce.TaskAttemptContext;
 import org.apache.hadoop.mapreduce.lib.input.FileSplit;
 import org.apache.tinkerpop.gremlin.hadoop.Constants;
 import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
-import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
 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.io.gryo.GryoMapper;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
+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.gremlin.structure.util.star.StarGraph;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -130,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 -> StarGraph.addTo(starGraph, detachedVertex);
-                final Function<DetachedEdge, Edge> edgeMaker = detachedEdge -> StarGraph.addTo(starGraph, detachedEdge);
+                final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> detachedVertex.attach(starGraph, Attachable.Method.CREATE);
+                final Function<DetachedEdge, 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) :

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6236935/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritableTest.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritableTest.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritableTest.java
new file mode 100644
index 0000000..532b750
--- /dev/null
+++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritableTest.java
@@ -0,0 +1,96 @@
+/*
+ *
+ *  * 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.hadoop.structure.io;
+
+import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
+import org.apache.tinkerpop.gremlin.process.traversal.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class VertexWritableTest {
+
+    private static VertexWritable byteClone(final VertexWritable vertexWritable) {
+        try {
+            final VertexWritable clone = new VertexWritable();
+            final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+            vertexWritable.write(new DataOutputStream(outputStream));
+            outputStream.flush();
+            clone.readFields(new DataInputStream(new ByteArrayInputStream(outputStream.toByteArray())));
+            return clone;
+        } catch (final Exception e) {
+            throw new IllegalStateException(e.getMessage(), e);
+        }
+    }
+
+    @Test
+    public void shouldHashAndEqualCorrectly() {
+        final StarGraph graph = StarGraph.open();
+        final Vertex v = graph.addVertex(T.id, 1, T.label, Vertex.DEFAULT_LABEL);
+        final Set<VertexWritable> set = new HashSet<>();
+        for (int i = 0; i < 100; i++) {
+            set.add(new VertexWritable(v));
+        }
+        assertEquals(1, set.size());
+    }
+
+    @Test
+    public void shouldHaveEqualVertexWritableAndInternalVertex() throws Exception {
+        final StarGraph graph = StarGraph.open();
+        final Vertex v = graph.addVertex(T.id, 1, T.label, Vertex.DEFAULT_LABEL);
+        final VertexWritable vw = new VertexWritable(v);
+        assertEquals(vw, vw);
+        assertEquals(vw, byteClone(vw));
+        assertEquals(v, byteClone(vw).get());
+    }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+    public void shouldConstructVertexWritableWithCorrectByteRepresentation() {
+        final StarGraph graph = StarGraph.open();
+        final Vertex v = graph.addVertex(T.id, 1, T.label, Vertex.DEFAULT_LABEL, "test", "123");
+        v.property(VertexProperty.Cardinality.list, "name", "marko", "acl", "private");
+        final VertexWritable vw = byteClone(new VertexWritable(v));
+
+        assertEquals(v.id(), vw.get().id());
+        assertEquals(v.label(), vw.get().label());
+        assertEquals("123", vw.get().value("test"));
+        assertEquals(2, IteratorUtils.count(vw.get().properties()));
+        assertEquals("marko", vw.get().value("name"));
+        assertEquals("private", vw.get().property("name").value("acl"));
+        // TODO: advance this
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6236935/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 f27787c..5c7838c 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
@@ -21,10 +21,8 @@ package org.apache.tinkerpop.gremlin.tinkergraph.structure;
 import org.apache.commons.io.FileUtils;
 import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
 import org.apache.tinkerpop.gremlin.TestHelper;
-import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo;
 import org.apache.tinkerpop.gremlin.algorithm.generator.DistributionGenerator;
 import org.apache.tinkerpop.gremlin.algorithm.generator.PowerLawDistribution;
-import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
 import org.apache.tinkerpop.gremlin.process.traversal.T;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
@@ -34,12 +32,12 @@ import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Operator;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo;
 import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
 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.detached.DetachedFactory;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -144,17 +142,6 @@ public class TinkerGraphTest {
 
     @Test
     @Ignore
-    public void testPlay3() throws Exception {
-        TinkerGraph tg = TinkerFactory.createModern();
-        StarGraph sg = StarGraph.open();
-        tg.vertices().forEachRemaining(v -> StarGraph.addTo(sg, DetachedFactory.detach(v,true)));
-        tg.vertices(1).next().edges(Direction.BOTH).forEachRemaining(e -> StarGraph.addTo(sg, DetachedFactory.detach(e, true)));
-        sg.vertices().forEachRemaining(System.out::println);
-        sg.edges().forEachRemaining(System.out::println);
-    }
-
-    @Test
-    @Ignore
     public void testPlay4() throws Exception {
         Graph graph = TinkerGraph.open();
         graph.io(GraphMLIo.build()).read("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");


[3/5] incubator-tinkerpop git commit: GET, CREATE, and GET_OR_CREATE working solid. All tests pass now.

Posted by ok...@apache.org.
GET, CREATE, and GET_OR_CREATE working solid. All tests pass now.


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

Branch: refs/heads/master
Commit: a3381b3dd32192cfa398d895da2ec6aa0a04d349
Parents: 3545da8
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Apr 21 12:57:40 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Apr 21 12:57:40 2015 -0600

----------------------------------------------------------------------
 .../traverser/util/AbstractPathTraverser.java   |  11 +-
 .../traverser/util/AbstractTraverser.java       |  11 +-
 .../traverser/util/EmptyTraverser.java          |   5 -
 .../gremlin/structure/util/Attachable.java      | 181 +++++++++++--------
 .../structure/util/detached/DetachedEdge.java   |  38 ----
 .../util/detached/DetachedElement.java          |   2 +-
 .../structure/util/detached/DetachedPath.java   |   2 +-
 .../util/detached/DetachedProperty.java         |  26 +--
 .../structure/util/detached/DetachedVertex.java |  34 ----
 .../util/detached/DetachedVertexProperty.java   |  23 +--
 .../structure/util/reference/ReferenceEdge.java |  19 --
 .../util/reference/ReferenceElement.java        |   2 +-
 .../structure/util/reference/ReferencePath.java |   2 +-
 .../util/reference/ReferenceProperty.java       |  25 +--
 .../util/reference/ReferenceVertex.java         |  19 --
 .../util/reference/ReferenceVertexProperty.java |  32 +---
 .../gremlin/structure/util/star/StarGraph.java  |   2 +-
 .../util/detached/DetachedPropertyTest.java     |   4 +-
 .../detached/DetachedVertexPropertyTest.java    |   4 +-
 .../reference/ReferenceVertexPropertyTest.java  |   4 +-
 20 files changed, 134 insertions(+), 312 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractPathTraverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractPathTraverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractPathTraverser.java
index 73a52de..060e912 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractPathTraverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractPathTraverser.java
@@ -147,16 +147,13 @@ public abstract class AbstractPathTraverser<T> implements Traverser<T>, Traverse
     }
 
     @Override
-    public T attach(final Vertex vertex, final Method method) {
-        if (this.t instanceof Attachable && !(((Attachable) this.t).getBase() instanceof Path))
-            this.t = ((Attachable<T>) this.t).attach(vertex, method);
+    public T attach(final Vertex hostVertex, final Method method) {
+        // you do not want to attach a path because it will reference graph objects not at the current vertex
+        if (this.t instanceof Attachable && !(((Attachable) this.t).get() instanceof Path))
+            this.t = ((Attachable<T>) this.t).attach(hostVertex, method);
         return this.t;
     }
 
-    public T getBase() {
-        return this.get();
-    }
-
     /////////////////
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
index 1420905..de94701 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/AbstractTraverser.java
@@ -26,9 +26,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyPath;
 import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversalSideEffects;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.util.Attachable;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceElement;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -110,9 +108,9 @@ public abstract class AbstractTraverser<T> implements Traverser<T>, Traverser.Ad
 
     @Override
     public T attach(final Vertex hostVertex, final Method method) {
-        if(this.t instanceof Attachable && !(((Attachable) this.t).getBase() instanceof Path))
-            this.t = (T) method.apply((Attachable)this.t,hostVertex);
         // you do not want to attach a path because it will reference graph objects not at the current vertex
+        if (this.t instanceof Attachable && !(((Attachable) this.t).get() instanceof Path))
+            this.t = ((Attachable<T>) this.t).attach(hostVertex, method);
         return this.t;
     }
 
@@ -133,11 +131,6 @@ public abstract class AbstractTraverser<T> implements Traverser<T>, Traverser.Ad
     }
 
     @Override
-    public T getBase() {
-        return this.t;
-    }
-
-    @Override
     public <S> S sack() {
         throw new UnsupportedOperationException("This traverser does not support sacks: " + this.getClass().getCanonicalName());
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
index 7d843fd..0256956 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/util/EmptyTraverser.java
@@ -101,11 +101,6 @@ public final class EmptyTraverser<T> implements Traverser<T>, Traverser.Admin<T>
     }
 
     @Override
-    public T getBase() {
-        return null;
-    }
-
-    @Override
     public <S> S sack() {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
index 65bd610..7ec5417 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
@@ -38,42 +38,60 @@ import java.util.function.BiFunction;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public interface Attachable<T> {
+
+    public T get();
+
+    public default T attach(final Vertex hostVertex, final Method method) throws IllegalStateException {
+        return (T) method.apply(this, hostVertex);
+    }
+
+    public default T attach(final Graph hostGraph, final Method method) throws IllegalStateException {
+        return (T) method.apply(this, hostGraph);
+    }
+
     public enum Method implements BiFunction<Attachable, Object, Object> {
 
         GET {
             @Override
             public Object apply(final Attachable attachable, final Object hostVertexOrGraph) {
-                final Object base = attachable.getBase();
+                final Object base = attachable.get();
                 if (base instanceof Vertex) {
                     final Optional<Vertex> optional = hostVertexOrGraph instanceof Graph ?
                             Method.getVertex(attachable, (Graph) hostVertexOrGraph) :
                             Method.getVertex(attachable, (Vertex) hostVertexOrGraph);
-                    return optional.orElseThrow(() -> new IllegalStateException("Can not get the following attachable from " + hostVertexOrGraph + ": " + attachable));
+                    return optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
+                            Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
+                            Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
                 } else if (base instanceof Edge) {
                     final Optional<Edge> optional = hostVertexOrGraph instanceof Graph ?
                             Method.getEdge(attachable, (Graph) hostVertexOrGraph) :
                             Method.getEdge(attachable, (Vertex) hostVertexOrGraph);
-                    return optional.orElseThrow(() -> new IllegalStateException("Can not get the following attachable from " + hostVertexOrGraph + ": " + attachable));
+                    return optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
+                            Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
+                            Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
                 } else if (base instanceof VertexProperty) {
                     final Optional<VertexProperty> optional = hostVertexOrGraph instanceof Graph ?
                             Method.getVertexProperty(attachable, (Graph) hostVertexOrGraph) :
                             Method.getVertexProperty(attachable, (Vertex) hostVertexOrGraph);
-                    return optional.orElseThrow(() -> new IllegalStateException("Can not get the following attachable from " + hostVertexOrGraph + ": " + attachable));
+                    return optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
+                            Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
+                            Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
                 } else if (base instanceof Property) {
                     final Optional<Property> optional = hostVertexOrGraph instanceof Graph ?
                             Method.getProperty(attachable, (Graph) hostVertexOrGraph) :
                             Method.getProperty(attachable, (Vertex) hostVertexOrGraph);
-                    return optional.orElseThrow(() -> new IllegalStateException("Can not get the following attachable from " + hostVertexOrGraph + ": " + attachable));
-                } else {
-                    throw new IllegalArgumentException("The attachable must contain an graph object");
-                }
+                    return optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
+                            Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
+                            Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
+                } else
+                    throw Attachable.Exceptions.providedAttachableMustContainAGraphObject(attachable);
             }
         },
 
         CREATE {
             @Override
             public Object apply(final Attachable attachable, final Object hostVertexOrGraph) {
-                final Object base = attachable.getBase();
+                final Object base = attachable.get();
                 if (base instanceof Vertex) {
                     return hostVertexOrGraph instanceof Graph ?
                             Method.createVertex(attachable, (Graph) hostVertexOrGraph) :
@@ -90,30 +108,68 @@ public interface Attachable<T> {
                     return hostVertexOrGraph instanceof Graph ?
                             Method.createProperty(attachable, (Graph) hostVertexOrGraph) :
                             Method.createProperty(attachable, (Vertex) hostVertexOrGraph);
-                } else {
-                    throw new IllegalArgumentException("The attachable must contain an graph object");
-                }
+                } else
+                    throw Attachable.Exceptions.providedAttachableMustContainAGraphObject(attachable);
+            }
+        },
+
+        GET_OR_CREATE {
+            @Override
+            public Object apply(final Attachable attachable, final Object hostVertexOrGraph) {
+                final Object base = attachable.get();
+                if (base instanceof Vertex) {
+                    return (hostVertexOrGraph instanceof Graph ?
+                            Method.getVertex(attachable, (Graph) hostVertexOrGraph) :
+                            Method.getVertex(attachable, (Vertex) hostVertexOrGraph))
+                            .orElse(hostVertexOrGraph instanceof Graph ?
+                                    Method.createVertex(attachable, (Graph) hostVertexOrGraph) :
+                                    Method.createVertex(attachable, (Vertex) hostVertexOrGraph));
+                } else if (base instanceof Edge) {
+                    return (hostVertexOrGraph instanceof Graph ?
+                            Method.getEdge(attachable, (Graph) hostVertexOrGraph) :
+                            Method.getEdge(attachable, (Vertex) hostVertexOrGraph))
+                            .orElse(hostVertexOrGraph instanceof Graph ?
+                                    Method.createEdge(attachable, (Graph) hostVertexOrGraph) :
+                                    Method.createEdge(attachable, (Vertex) hostVertexOrGraph));
+                } else if (base instanceof VertexProperty) {
+                    return (hostVertexOrGraph instanceof Graph ?
+                            Method.getVertexProperty(attachable, (Graph) hostVertexOrGraph) :
+                            Method.getVertexProperty(attachable, (Vertex) hostVertexOrGraph))
+                            .orElse(hostVertexOrGraph instanceof Graph ?
+                                    Method.createVertexProperty(attachable, (Graph) hostVertexOrGraph) :
+                                    Method.createVertexProperty(attachable, (Vertex) hostVertexOrGraph));
+                } else if (base instanceof Property) {
+                    return (hostVertexOrGraph instanceof Graph ?
+                            Method.getProperty(attachable, (Graph) hostVertexOrGraph) :
+                            Method.getProperty(attachable, (Vertex) hostVertexOrGraph))
+                            .orElse(hostVertexOrGraph instanceof Graph ?
+                                    Method.createProperty(attachable, (Graph) hostVertexOrGraph) :
+                                    Method.createProperty(attachable, (Vertex) hostVertexOrGraph));
+                } else
+                    throw Attachable.Exceptions.providedAttachableMustContainAGraphObject(attachable);
             }
         };
 
         ///////////////////
 
+        ///// GET HELPER METHODS
+
         public static Optional<Vertex> getVertex(final Attachable<Vertex> attachableVertex, final Graph hostGraph) {
-            final Iterator<Vertex> vertexIterator = hostGraph.vertices(attachableVertex.getBase().id());
+            final Iterator<Vertex> vertexIterator = hostGraph.vertices(attachableVertex.get().id());
             return vertexIterator.hasNext() ? Optional.of(vertexIterator.next()) : Optional.empty();
         }
 
         public static Optional<Vertex> getVertex(final Attachable<Vertex> attachableVertex, final Vertex hostVertex) {
-            return ElementHelper.areEqual(attachableVertex.getBase(), hostVertex) ? Optional.of(hostVertex) : Optional.empty();
+            return ElementHelper.areEqual(attachableVertex.get(), hostVertex) ? Optional.of(hostVertex) : Optional.empty();
         }
 
         public static Optional<Edge> getEdge(final Attachable<Edge> attachableEdge, final Graph hostGraph) {
-            final Iterator<Edge> edgeIterator = hostGraph.edges(attachableEdge.getBase().id());
+            final Iterator<Edge> edgeIterator = hostGraph.edges(attachableEdge.get().id());
             return edgeIterator.hasNext() ? Optional.of(edgeIterator.next()) : Optional.empty();
         }
 
         public static Optional<Edge> getEdge(final Attachable<Edge> attachableEdge, final Vertex hostVertex) {
-            final Object baseId = attachableEdge.getBase().id();
+            final Object baseId = attachableEdge.get().id();
             final Iterator<Edge> edgeIterator = hostVertex.edges(Direction.OUT);
             while (edgeIterator.hasNext()) {
                 final Edge edge = edgeIterator.next();
@@ -124,7 +180,7 @@ public interface Attachable<T> {
         }
 
         public static Optional<VertexProperty> getVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Graph hostGraph) {
-            final VertexProperty baseVertexProperty = attachableVertexProperty.getBase();
+            final VertexProperty baseVertexProperty = attachableVertexProperty.get();
             final Iterator<Vertex> vertexIterator = hostGraph.vertices(baseVertexProperty.element().id());
             if (vertexIterator.hasNext()) {
                 final Iterator<VertexProperty<Object>> vertexPropertyIterator = vertexIterator.next().properties(baseVertexProperty.key());
@@ -138,7 +194,7 @@ public interface Attachable<T> {
         }
 
         public static Optional<VertexProperty> getVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Vertex hostVertex) {
-            final VertexProperty baseVertexProperty = attachableVertexProperty.getBase();
+            final VertexProperty baseVertexProperty = attachableVertexProperty.get();
             final Iterator<VertexProperty<Object>> vertexPropertyIterator = hostVertex.properties(baseVertexProperty.key());
             while (vertexPropertyIterator.hasNext()) {
                 final VertexProperty vertexProperty = vertexPropertyIterator.next();
@@ -149,17 +205,19 @@ public interface Attachable<T> {
         }
 
         public static Optional<Property> getProperty(final Attachable<Property> attachableProperty, final Graph hostGraph) {
-            final Property baseProperty = attachableProperty.getBase();
-            final Element propertyElement = attachableProperty.getBase().element();
-            if (propertyElement instanceof Edge) {
+            final Property baseProperty = attachableProperty.get();
+            final Element propertyElement = attachableProperty.get().element();
+            if (propertyElement instanceof Vertex) {
+                return (Optional) Method.getVertexProperty((Attachable) attachableProperty, hostGraph);
+            } else if (propertyElement instanceof Edge) {
                 final Iterator<Edge> edgeIterator = hostGraph.edges(propertyElement.id());
-                if (edgeIterator.hasNext()) {
+                while (edgeIterator.hasNext()) {
                     final Property property = edgeIterator.next().property(baseProperty.key());
                     if (property.isPresent() && property.value().equals(baseProperty.value()))
                         return Optional.of(property);
                 }
                 return Optional.empty();
-            } else {
+            } else { // vertex property
                 final Iterator<Vertex> vertexIterator = hostGraph.vertices(((VertexProperty) propertyElement).element().id());
                 if (vertexIterator.hasNext()) {
                     final Iterator<VertexProperty<Object>> vertexPropertyIterator = vertexIterator.next().properties();
@@ -179,17 +237,19 @@ public interface Attachable<T> {
         }
 
         public static Optional<Property> getProperty(final Attachable<Property> attachableProperty, final Vertex hostVertex) {
-            final Property baseProperty = attachableProperty.getBase();
-            final Element propertyElement = attachableProperty.getBase().element();
-            if (propertyElement instanceof Edge) {
+            final Property baseProperty = attachableProperty.get();
+            final Element propertyElement = attachableProperty.get().element();
+            if (propertyElement instanceof Vertex) {
+                return (Optional) Method.getVertexProperty((Attachable) attachableProperty, hostVertex);
+            } else if (propertyElement instanceof Edge) {
                 final Iterator<Edge> edgeIterator = hostVertex.edges(Direction.OUT);
-                if (edgeIterator.hasNext()) {
+                while (edgeIterator.hasNext()) {
                     final Property property = edgeIterator.next().property(baseProperty.key());
                     if (property.isPresent() && property.value().equals(baseProperty.value()))
                         return Optional.of(property);
                 }
                 return Optional.empty();
-            } else {
+            } else { // vertex property
                 final Iterator<VertexProperty<Object>> vertexPropertyIterator = hostVertex.properties();
                 while (vertexPropertyIterator.hasNext()) {
                     final VertexProperty vertexProperty = vertexPropertyIterator.next();
@@ -205,10 +265,10 @@ public interface Attachable<T> {
             }
         }
 
-        /////
+        ///// CREATE HELPER METHODS
 
         public static Vertex createVertex(final Attachable<Vertex> attachableVertex, final Graph hostGraph) {
-            final Vertex baseVertex = attachableVertex.getBase();
+            final Vertex baseVertex = attachableVertex.get();
             final List<Object> keyValues = new ArrayList<>();
             keyValues.add(org.apache.tinkerpop.gremlin.process.traversal.T.id);
             keyValues.add(baseVertex.id());
@@ -227,7 +287,7 @@ public interface Attachable<T> {
         }
 
         public static Edge createEdge(final Attachable<Edge> attachableEdge, final Graph hostGraph) {
-            final Edge baseEdge = attachableEdge.getBase();
+            final Edge baseEdge = attachableEdge.get();
             Iterator<Vertex> vertices = hostGraph.vertices(baseEdge.outVertex().id());
             final Vertex outV = vertices.hasNext() ? vertices.next() : hostGraph.addVertex(org.apache.tinkerpop.gremlin.process.traversal.T.id, baseEdge.outVertex().id());
             vertices = hostGraph.vertices(baseEdge.inVertex().id());
@@ -246,11 +306,11 @@ public interface Attachable<T> {
         }
 
         public static Edge createEdge(final Attachable<Edge> attachableEdge, final Vertex hostVertex) {
-            return Method.createEdge(attachableEdge, hostVertex.graph());
+            return Method.createEdge(attachableEdge, hostVertex.graph()); // TODO (make local to vertex)
         }
 
         public static VertexProperty createVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Graph hostGraph) {
-            final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.getBase();
+            final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.get();
             final Iterator<Vertex> vertexIterator = hostGraph.vertices(baseVertexProperty.element().id());
             if (vertexIterator.hasNext()) {
                 final VertexProperty vertexProperty = vertexIterator.next().property(VertexProperty.Cardinality.list, baseVertexProperty.key(), baseVertexProperty.value(), org.apache.tinkerpop.gremlin.process.traversal.T.id, baseVertexProperty.id());
@@ -261,75 +321,38 @@ public interface Attachable<T> {
         }
 
         public static VertexProperty createVertexProperty(final Attachable<VertexProperty> attachableVertexProperty, final Vertex hostVertex) {
-            final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.getBase();
+            final VertexProperty<Object> baseVertexProperty = attachableVertexProperty.get();
             final VertexProperty vertexProperty = hostVertex.property(VertexProperty.Cardinality.list, baseVertexProperty.key(), baseVertexProperty.value(), org.apache.tinkerpop.gremlin.process.traversal.T.id, baseVertexProperty.id());
             baseVertexProperty.properties().forEachRemaining(p -> vertexProperty.property(p.key(), p.value()));
             return vertexProperty;
         }
 
         public static Property createProperty(final Attachable<Property> attachableProperty, final Graph hostGraph) {
-            return null;
+            return null;   // TODO: :)
 
         }
 
         public static Property createProperty(final Attachable<Property> attachableProperty, final Vertex hostVertex) {
-            return null;
+            return null; // TODO: :)
         }
 
     }
 
-    public T getBase();
-
-    public T attach(final Vertex hostVertex, final Method method) throws IllegalStateException;
-
-    public T attach(final Graph hostGraph, final Method method) throws IllegalStateException;
-
-
     public static class Exceptions {
 
         private Exceptions() {
         }
 
-        public static IllegalStateException canNotAttachVertexToHostVertex(final Attachable<Vertex> vertex, final Vertex hostVertex) {
-            return new IllegalStateException("The provided vertex is not the host vertex: " + vertex + " does not equal " + hostVertex);
-        }
-
-        public static IllegalStateException canNotAttachVertexToHostGraph(final Attachable<Vertex> vertex, final Graph hostGraph) {
-            return new IllegalStateException("The provided vertex could not be found in the host graph: " + vertex + " not in " + hostGraph);
-        }
-
-        public static IllegalStateException canNotAttachEdgeToHostVertex(final Attachable<Edge> edge, final Vertex hostVertex) {
-            return new IllegalStateException("The provided edge is not incident to the host vertex: " + edge + " not incident to " + hostVertex);
-        }
-
-        public static IllegalStateException canNotAttachEdgeToHostGraph(final Attachable<Edge> edge, final Graph hostGraph) {
-            return new IllegalStateException("The provided edge could not be found in the host graph: " + edge + " not in " + hostGraph);
-        }
-
-        public static IllegalStateException canNotAttachVertexPropertyToHostVertex(final Attachable<VertexProperty> vertexProperty, final Vertex hostVertex) {
-            return new IllegalStateException("The provided vertex property is not a property of the host vertex: " + vertexProperty + " not a property of " + hostVertex);
-        }
-
-        public static IllegalStateException canNotAttachVertexPropertyToHostGraph(final Attachable<VertexProperty> vertexProperty, final Graph hostGraph) {
-            return new IllegalStateException("The provided vertex property could not be found in the host graph: " + vertexProperty + " not in " + hostGraph);
+        public static IllegalStateException canNotGetAttachableFromHostVertex(final Attachable<?> attachable, final Vertex hostVertex) {
+            return new IllegalStateException("Can not get the attachable from the host vertex: " + attachable + "-/->" + hostVertex);
         }
 
-        public static IllegalStateException canNotAttachPropertyToHostVertex(final Attachable<Property> property, final Vertex hostVertex) {
-            return new IllegalStateException("The provided property could not be attached the host vertex: " + property + " not a property in the star of " + hostVertex);
-        }
-
-        public static IllegalStateException canNotAttachPropertyToHostGraph(final Attachable<Property> property, final Graph hostGraph) {
-            return new IllegalStateException("The provided property could not be attached the host graph: " + property + " not in " + hostGraph);
-        }
-
-        ////
-
-        public static IllegalArgumentException illegalMethodOnHostVertex(final Attachable attachable, final Method method, final Vertex hostVertex) {
-            return new IllegalArgumentException("The following method on the host vertex is not legal: " + hostVertex + "." + method + "(" + attachable + ")");
+        public static IllegalStateException canNotGetAttachableFromHostGraph(final Attachable<?> attachable, final Graph hostGraph) {
+            return new IllegalStateException("Can not get the attachable from the host vertex: " + attachable + "-/->" + hostGraph);
         }
 
-        public static IllegalArgumentException illegalMethodOnHostGraph(final Attachable attachable, final Method method, final Graph hostGraph) {
-            return new IllegalArgumentException("The following method on the host graph is not legal: " + hostGraph + "." + method + "(" + attachable + ")");
+        public static IllegalArgumentException providedAttachableMustContainAGraphObject(final Attachable<?> attachable) {
+            return new IllegalArgumentException("The provided attachable must contain a graph object: " + attachable);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdge.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdge.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdge.java
index cffa268..02c2fd0 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdge.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedEdge.java
@@ -85,50 +85,12 @@ public class DetachedEdge extends DetachedElement<Edge> implements Edge {
         }
     }
 
-
     @Override
     public String toString() {
         return StringFactory.edgeString(this);
     }
 
     @Override
-    public Edge attach(final Vertex hostVertex, final Method method) {
-        return (Edge) method.apply(this, hostVertex);
-        /*final Iterator<Edge> edges = IteratorUtils.filter(hostVertex.edges(Direction.OUT, this.label), edge -> edge.equals(this));
-        if (!edges.hasNext())
-            throw Attachable.Exceptions.canNotAttachEdgeToHostVertex(this, hostVertex);
-        return edges.next();*/
-    }
-
-    @Override
-    public Edge attach(final Graph hostGraph, final Method method) {
-        return (Edge) method.apply(this, hostGraph);
-        /*final Iterator<Edge> edges = hostGraph.edges(this.id);
-        if (!edges.hasNext())
-            throw Attachable.Exceptions.canNotAttachEdgeToHostGraph(this, hostGraph);
-        return edges.next();*/
-    }
-
-    /*public static Edge addTo(final Graph graph, final DetachedEdge detachedEdge) {
-        Iterator<Vertex> vertices = graph.vertices(detachedEdge.outVertex.id());
-        final Vertex outV = vertices.hasNext() ? vertices.next() : graph.addVertex(T.id, detachedEdge.outVertex.id());
-        vertices = graph.vertices(detachedEdge.inVertex.id());
-        final Vertex inV = vertices.hasNext() ? vertices.next() : graph.addVertex(T.id, detachedEdge.inVertex.id());
-        if (ElementHelper.areEqual(outV, inV)) {
-            final Iterator<Edge> itty = outV.edges(Direction.OUT, detachedEdge.label());
-            while (itty.hasNext()) {
-                final Edge e = itty.next();
-                if (ElementHelper.areEqual(detachedEdge, e))
-                    return e;
-            }
-        }
-        final Edge e = outV.addEdge(detachedEdge.label(), inV, T.id, detachedEdge.id());
-        if (null != detachedEdge.properties)
-            detachedEdge.properties.entrySet().forEach(kv -> kv.getValue().forEach(p -> e.<Object>property(kv.getKey(), p.value())));
-        return e;
-    }*/
-
-    @Override
     public Vertex inVertex() {
         return this.inVertex;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
index 1da69f3..b748633 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedElement.java
@@ -97,7 +97,7 @@ public abstract class DetachedElement<E> implements Element, Serializable, Attac
                 (Iterator) this.properties.entrySet().stream().filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys)).flatMap(entry -> entry.getValue().stream()).iterator();
     }
 
-    public E getBase() {
+    public E get() {
         return (E) this;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
index 9d971d9..8610922 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPath.java
@@ -35,7 +35,7 @@ public class DetachedPath extends MutablePath implements Attachable<Path> {
 
     }
 
-    public Path getBase() {
+    public Path get() {
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
index a4d4a0c..6da0e4a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedProperty.java
@@ -32,7 +32,7 @@ import java.io.Serializable;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public class DetachedProperty<V> implements Property, Serializable, Attachable<Property> {
+public class DetachedProperty<V> implements Property<V>, Serializable, Attachable<Property<V>> {
 
     private String key;
     private V value;
@@ -53,7 +53,7 @@ public class DetachedProperty<V> implements Property, Serializable, Attachable<P
         this.element = DetachedFactory.detach(element, false);
     }
 
-    public Property getBase() {
+    public Property<V> get() {
         return this;
     }
 
@@ -97,26 +97,4 @@ public class DetachedProperty<V> implements Property, Serializable, Attachable<P
     public int hashCode() {
         return ElementHelper.hashCode(this);
     }
-
-    @Override
-    public Property<V> attach(final Vertex hostVertex, final Method method) {
-        return (Property<V>) method.apply(this, hostVertex);
-        /*final Element element = (Element) this.element.attach(hostVertex);
-        final Property<V> property = element.property(this.key);
-        if (property.isPresent() && property.value().equals(this.value))
-            return property;
-        else
-            throw Attachable.Exceptions.canNotAttachPropertyToHostVertex(this, hostVertex);*/
-    }
-
-    @Override
-    public Property<V> attach(final Graph hostGraph, final Method method) {
-        return (Property<V>) method.apply(this, method);
-        /*final Element hostElement = (Element) this.element.attach(hostGraph);
-        final Property<V> property = hostElement.property(this.key);
-        if (property.isPresent() && property.value().equals(this.value))
-            return property;
-        else
-            throw Attachable.Exceptions.canNotAttachPropertyToHostGraph(this, hostGraph); */
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertex.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertex.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertex.java
index f0b9b75..3a13d70 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertex.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertex.java
@@ -125,40 +125,6 @@ public class DetachedVertex extends DetachedElement<Vertex> implements Vertex {
     }
 
     @Override
-    public Vertex attach(final Vertex hostVertex, final Method method) {
-        return (Vertex) method.apply(this, hostVertex);
-    }
-
-    @Override
-    public Vertex attach(final Graph hostGraph, final Method method) {
-        return (Vertex) method.apply(this, hostGraph);
-    }
-
-    /*public static Vertex addTo(final Graph graph, final DetachedVertex detachedVertex) {
-        final Vertex vertex = graph.addVertex(T.id, detachedVertex.id(), T.label, detachedVertex.label());
-        if (null != detachedVertex.properties) {
-            detachedVertex.properties.values().forEach(list -> {
-                list.forEach(dVertexProperty -> {
-                    final DetachedVertexProperty<?> detachedVertexProperty = (DetachedVertexProperty) dVertexProperty;
-                    if (null != detachedVertexProperty.properties) {
-                        final List<Object> metaProperties = new ArrayList<>();
-                        detachedVertexProperty.properties().forEachRemaining(detachedMetaProperty -> {
-                            metaProperties.add(detachedMetaProperty.key());
-                            metaProperties.add(detachedMetaProperty.value());
-                        });
-                        metaProperties.add(T.id);
-                        metaProperties.add(detachedVertexProperty.id());
-                        vertex.property(VertexProperty.Cardinality.list, detachedVertexProperty.key(), detachedVertexProperty.value(), metaProperties.toArray());
-                    } else {
-                        vertex.property(VertexProperty.Cardinality.list, detachedVertexProperty.key(), detachedVertexProperty.value(), T.id, detachedVertexProperty.id());
-                    }
-                });
-            });
-        }
-        return vertex;
-    } */
-
-    @Override
     public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
         return (Iterator) super.properties(propertyKeys);
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
index 700f0d5..f76cfd8 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexProperty.java
@@ -34,7 +34,7 @@ import java.util.Map;
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
-public class DetachedVertexProperty<V> extends DetachedElement<Property<V>> implements VertexProperty<V> {
+public class DetachedVertexProperty<V> extends DetachedElement<VertexProperty<V>> implements VertexProperty<V> {
 
     protected V value;
     protected transient DetachedVertex vertex;
@@ -109,28 +109,7 @@ public class DetachedVertexProperty<V> extends DetachedElement<Property<V>> impl
     }
 
     @Override
-    public VertexProperty<V> attach(final Vertex hostVertex, final Method method) {
-        return (VertexProperty<V>) method.apply(this, hostVertex);
-        /*final Iterator<VertexProperty<V>> vertexPropertyIterator = IteratorUtils.filter(hostVertex.<V>properties(this.label), vp -> ElementHelper.areEqual(this, vp));
-        if (!vertexPropertyIterator.hasNext())
-            throw Attachable.Exceptions.canNotAttachVertexPropertyToHostVertex((Attachable) this, hostVertex);
-        return vertexPropertyIterator.next(); */
-    }
-
-    @Override
-    public VertexProperty<V> attach(final Graph hostGraph, final Method method) {
-        return (VertexProperty<V>) method.apply(this, hostGraph);
-        //return this.attach(this.vertex.attach(hostGraph));
-    }
-
-    @Override
     public <U> Iterator<Property<U>> properties(final String... propertyKeys) {
         return (Iterator) super.properties(propertyKeys);
     }
-
-    /*public static <V> VertexProperty<V> addTo(final Vertex vertex, final DetachedVertexProperty<V> detachedVertexProperty) {
-        final VertexProperty<V> vertexProperty = vertex.property(VertexProperty.Cardinality.single, detachedVertexProperty.key(), detachedVertexProperty.value()); // TODO: this isn't right, is it? (need to remove views from Spark/Giraph)
-        detachedVertexProperty.properties().forEachRemaining(property -> vertexProperty.property(property.key(), property.value()));
-        return vertexProperty;
-    }*/
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java
index 2788d3a..80f3bb3 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceEdge.java
@@ -24,7 +24,6 @@ package org.apache.tinkerpop.gremlin.structure.util.reference;
 import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 
@@ -45,24 +44,6 @@ public class ReferenceEdge extends ReferenceElement<Edge> implements Edge {
     }
 
     @Override
-    public Edge attach(final Vertex hostVertex, final Method method) {
-        return (Edge) method.apply(this, hostVertex);
-       /* final Iterator<Edge> edges = IteratorUtils.filter(hostVertex.edges(Direction.OUT), edge -> edge.id().equals(this.id));
-        if (!edges.hasNext())
-            throw Attachable.Exceptions.canNotAttachEdgeToHostVertex(this, hostVertex);
-        return edges.next();  */
-    }
-
-    @Override
-    public Edge attach(final Graph hostGraph, final Method method) {
-        return (Edge) method.apply(this, hostGraph);
-        /*final Iterator<Edge> edges = hostGraph.edges(this.id);
-        if (!edges.hasNext())
-            throw Attachable.Exceptions.canNotAttachEdgeToHostGraph(this, hostGraph);
-        return edges.next(); */
-    }
-
-    @Override
     public <V> Property<V> property(final String key, final V value) {
         throw Element.Exceptions.propertyAdditionNotSupported();
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
index 0bcf37c..c7b68b7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceElement.java
@@ -72,7 +72,7 @@ public abstract class ReferenceElement<E extends Element> implements Element, Se
         return ElementHelper.areEqual(this, other);
     }
 
-    public E getBase() {
+    public E get() {
         return (E) this;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
index b52b93d..7b85c17 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferencePath.java
@@ -38,7 +38,7 @@ public class ReferencePath extends MutablePath implements Attachable<Path> {
 
     }
 
-    public Path getBase() {
+    public Path get() {
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
index c034629..d1e8326 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceProperty.java
@@ -35,7 +35,7 @@ import java.util.NoSuchElementException;
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public class ReferenceProperty<V> implements Attachable<Property>, Serializable, Property<V> {
+public class ReferenceProperty<V> implements Attachable<Property<V>>, Serializable, Property<V> {
 
     private ReferenceElement<?> element;
     private String key;
@@ -45,7 +45,7 @@ public class ReferenceProperty<V> implements Attachable<Property>, Serializable,
 
     }
 
-    public Property getBase() {
+    public Property<V> get() {
         return this;
     }
 
@@ -56,27 +56,6 @@ public class ReferenceProperty<V> implements Attachable<Property>, Serializable,
     }
 
     @Override
-    public Property<V> attach(final Vertex hostVertex, final Method method) throws IllegalStateException {
-        return (Property<V>) method.apply(this,hostVertex);
-        /*final Property<V> property = this.element.attach(hostVertex).property(this.key);
-        if (property.isPresent() && property.value().equals(this.value))
-            return property;
-        else
-            throw Attachable.Exceptions.canNotAttachPropertyToHostVertex(this, hostVertex); */
-    }
-
-    @Override
-    public Property<V> attach(final Graph hostGraph, final Method method) throws IllegalStateException {
-        return (Property<V>) method.apply(this,hostGraph);
-
-        /*final Property<V> property = this.element.attach(hostGraph).property(this.key);
-        if (property.isPresent() && property.value().equals(this.value))
-            return property;
-        else
-            throw Attachable.Exceptions.canNotAttachPropertyToHostGraph(this, hostGraph);*/
-    }
-
-    @Override
     public int hashCode() {
         return ElementHelper.hashCode(this);
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java
index 775305d..af9dce1 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertex.java
@@ -46,25 +46,6 @@ public class ReferenceVertex extends ReferenceElement<Vertex> implements Vertex
     }
 
     @Override
-    public Vertex attach(final Vertex hostVertex, final Method method) {
-        return (Vertex) method.apply(this, hostVertex);
-        /*if (ElementHelper.areEqual(this,hostVertex))
-            return hostVertex;
-        else
-            throw Attachable.Exceptions.canNotAttachVertexToHostVertex(this, hostVertex);  */
-    }
-
-    @Override
-    public Vertex attach(final Graph hostGraph, final Method method) {
-        return (Vertex) method.apply(this, hostGraph);
-        /*final Iterator<Vertex> iterator = hostGraph.vertices(this.id);
-        if (iterator.hasNext())
-            return iterator.next();
-        else
-            throw Attachable.Exceptions.canNotAttachVertexToHostGraph(this, hostGraph);   */
-    }
-
-    @Override
     public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
         throw Vertex.Exceptions.edgeAdditionsNotSupported();
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java
index 8898e75..326708c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexProperty.java
@@ -26,6 +26,7 @@ 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.util.StringFactory;
 
 import java.util.Collections;
 import java.util.Iterator;
@@ -34,49 +35,36 @@ import java.util.NoSuchElementException;
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public class ReferenceVertexProperty<V> extends ReferenceElement<VertexProperty> implements VertexProperty<V> {
+public class ReferenceVertexProperty<V> extends ReferenceElement<VertexProperty<V>> implements VertexProperty<V> {
 
     private ReferenceVertex vertex;
+    private String key;
+    private V value;
 
     private ReferenceVertexProperty() {
 
     }
 
-    public ReferenceVertexProperty(final VertexProperty vertexProperty) {
+    public ReferenceVertexProperty(final VertexProperty<V> vertexProperty) {
         super(vertexProperty);
         this.vertex = ReferenceFactory.detach(vertexProperty.element());
-    }
-
-    @Override
-    public VertexProperty<V> attach(final Vertex hostVertex, final Method method) {
-        return (VertexProperty<V>) method.apply(this, hostVertex);
-        /*if (!hostVertex.equals(this.vertex))
-            throw Attachable.Exceptions.canNotAttachVertexPropertyToHostVertex(this, hostVertex);
-        final Iterator<VertexProperty<V>> vertexPropertyIterator = IteratorUtils.filter(hostVertex.<V>properties(), vp -> vp.id().equals(this.id));
-        if (!vertexPropertyIterator.hasNext())
-            throw Attachable.Exceptions.canNotAttachVertexPropertyToHostVertex(this, hostVertex);
-        return vertexPropertyIterator.next();*/
-    }
-
-    @Override
-    public VertexProperty<V> attach(final Graph hostGraph, final Method method) {
-        return (VertexProperty<V>) method.apply(this, hostGraph);
-        // return this.attach(this.vertex.attach(hostGraph));
+        this.key = vertexProperty.key();
+        this.value = vertexProperty.value();
     }
 
     @Override
     public String toString() {
-        return "vp[" + this.id + "]";
+        return StringFactory.propertyString(this);
     }
 
     @Override
     public String key() {
-        return EMPTY_STRING;
+        return this.key;
     }
 
     @Override
     public V value() throws NoSuchElementException {
-        return null;
+        return this.value;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/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 ccfe7d9..57d5bb9 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
@@ -247,7 +247,7 @@ public final class StarGraph implements Graph {
             super(id, label);
         }
 
-        public Vertex getBase() {
+        public Vertex get() {
             return this;
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
index 674bafc..2fbb5e6 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedPropertyTest.java
@@ -72,7 +72,7 @@ public class DetachedPropertyTest extends AbstractGremlinTest {
     public void shouldAttachToGraph() {
         final Edge e = g.E(convertToEdgeId("josh", "created", "lop")).next();
         final Property toDetach = e.properties("weight").next();
-        final DetachedProperty detachedProperty = DetachedFactory.detach(toDetach);
+        final DetachedProperty<?> detachedProperty = DetachedFactory.detach(toDetach);
         final Property attached = detachedProperty.attach(graph, Attachable.Method.GET);
 
         assertEquals(toDetach, attached);
@@ -84,7 +84,7 @@ public class DetachedPropertyTest extends AbstractGremlinTest {
     public void shouldAttachToVertex() {
         final Edge e = g.E(convertToEdgeId("josh", "created", "lop")).next();
         final Property toDetach = e.property("weight");
-        final DetachedProperty detachedProperty = DetachedFactory.detach(toDetach);
+        final DetachedProperty<?> detachedProperty = DetachedFactory.detach(toDetach);
         final Property attached = detachedProperty.attach(e.outVertex(), Attachable.Method.GET);
 
         assertEquals(toDetach, attached);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
index a363373..78d1a6b 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/detached/DetachedVertexPropertyTest.java
@@ -127,7 +127,7 @@ public class DetachedVertexPropertyTest extends AbstractGremlinTest {
     public void shouldAttachToGraph() {
         final Vertex v = graph.addVertex();
         final VertexProperty toDetach = v.property(VertexProperty.Cardinality.single, "test", "this");
-        final DetachedVertexProperty detached = DetachedFactory.detach(toDetach, true);
+        final DetachedVertexProperty<?> detached = DetachedFactory.detach(toDetach, true);
         final VertexProperty attached = detached.attach(graph, Attachable.Method.GET);
 
         assertEquals(toDetach, attached);
@@ -139,7 +139,7 @@ public class DetachedVertexPropertyTest extends AbstractGremlinTest {
     public void shouldAttachToVertex() {
         final Vertex v = graph.addVertex();
         final VertexProperty toDetach = v.property(VertexProperty.Cardinality.single, "test", "this");
-        final DetachedVertexProperty detached = DetachedFactory.detach(toDetach, true);
+        final DetachedVertexProperty<?> detached = DetachedFactory.detach(toDetach, true);
         final VertexProperty attached = detached.attach(v, Attachable.Method.GET);
 
         assertEquals(toDetach, attached);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3381b3d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
index 4f6e17f..d8d0086 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/reference/ReferenceVertexPropertyTest.java
@@ -80,7 +80,7 @@ public class ReferenceVertexPropertyTest extends AbstractGremlinTest {
     public void shouldAttachToGraph() {
         final Vertex v = graph.addVertex();
         final VertexProperty toReference = v.property(VertexProperty.Cardinality.single, "test", "this");
-        final ReferenceVertexProperty rvp = ReferenceFactory.detach(toReference);
+        final ReferenceVertexProperty<?> rvp = ReferenceFactory.detach(toReference);
         final VertexProperty referenced = rvp.attach(graph, Attachable.Method.GET);
 
         assertEquals(toReference, referenced);
@@ -92,7 +92,7 @@ public class ReferenceVertexPropertyTest extends AbstractGremlinTest {
     public void shouldAttachToVertex() {
         final Vertex v = graph.addVertex();
         final VertexProperty toReference = v.property(VertexProperty.Cardinality.single, "test", "this");
-        final ReferenceVertexProperty rvp = ReferenceFactory.detach(toReference);
+        final ReferenceVertexProperty<?> rvp = ReferenceFactory.detach(toReference);
         final VertexProperty referenced = rvp.attach(v, Attachable.Method.GET);
 
         assertEquals(toReference, referenced);