You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2016/01/05 18:14:33 UTC

[4/4] incubator-tinkerpop git commit: first EdgeCopyVertexProgram prototype (not yet working)

first EdgeCopyVertexProgram prototype (not yet working)


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

Branch: refs/heads/TINKERPOP3-432
Commit: 201b05af3e250c294716c70a31e592d9ba0f670c
Parents: eb50570
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Tue Jan 5 18:10:19 2016 +0100
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Tue Jan 5 18:10:19 2016 +0100

----------------------------------------------------------------------
 .../edgecopy/EdgeCopyVertexProgram.java         |  29 +++--
 .../structure/io/script/ScriptRecordReader.java |   2 +-
 .../structure/io/script/ScriptRecordWriter.java |   6 +-
 .../edgecopy/EdgeCopyVertexProgramTest.java     | 124 +++++++++++++++++++
 .../computer/edgecopy/hadoop-script.properties  |  32 +++++
 .../computer/edgecopy/script-input.groovy       |  49 ++++++++
 .../computer/edgecopy/script-output.groovy      |  34 +++++
 .../computer/edgecopy/tinkerpop-classic.txt     |   6 +
 8 files changed, 268 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/201b05af/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/edgecopy/EdgeCopyVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/edgecopy/EdgeCopyVertexProgram.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/edgecopy/EdgeCopyVertexProgram.java
index 9d72997..01a6d05 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/edgecopy/EdgeCopyVertexProgram.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/edgecopy/EdgeCopyVertexProgram.java
@@ -52,8 +52,9 @@ public class EdgeCopyVertexProgram extends StaticVertexProgram<Edge> {
     private static final Logger LOGGER = LoggerFactory.getLogger(EdgeCopyVertexProgram.class);
 
     public static final String EDGE_COPY_VERTEX_PROGRAM_CFG_PREFIX = "gremlin.edgeCopyVertexProgram";
+    public static final String DIRECTION_CFG_KEY = String.join(".", EDGE_COPY_VERTEX_PROGRAM_CFG_PREFIX, "direction");
 
-    private final Direction direction;
+    private Direction direction;
     private Configuration configuration;
 
     private EdgeCopyVertexProgram() {
@@ -70,6 +71,9 @@ public class EdgeCopyVertexProgram extends StaticVertexProgram<Edge> {
         if (config != null) {
             ConfigurationUtils.copy(config, configuration);
         }
+        if (configuration.containsKey(DIRECTION_CFG_KEY)) {
+            direction = Direction.valueOf(configuration.getString(DIRECTION_CFG_KEY));
+        }
     }
 
     @Override
@@ -85,7 +89,9 @@ public class EdgeCopyVertexProgram extends StaticVertexProgram<Edge> {
             sourceVertex.edges(direction).forEachRemaining(edge -> {
                 final Object inVId = edge.inVertex().id();
                 LOGGER.info("send edge from " + sourceVertex.id() + " to " + edge.inVertex().id());
-                MessageScope messageScope = MessageScope.Local.of(() -> __.<Vertex>start().outE().filter(__.inV().hasId(inVId)));
+                MessageScope messageScope = Direction.OUT.equals(direction)
+                        ? MessageScope.Local.of(() -> __.<Vertex>start().outE().filter(__.inV().hasId(inVId)))
+                        : MessageScope.Local.of(() -> __.<Vertex>start().inE().filter(__.outV().hasId(inVId)));
                 messenger.sendMessage(messageScope, DetachedFactory.detach(edge, true));
             });
         } else if (memory.getIteration() == 1) {
@@ -95,14 +101,12 @@ public class EdgeCopyVertexProgram extends StaticVertexProgram<Edge> {
             final Graph sg = inV.graph();
             while (ei.hasNext()) {
                 final Edge edge = ei.next();
-                if (sourceVertex.id().equals(edge.inVertex().id())) {
-                    LOGGER.info("create edge from " + edge.outVertex().id() + " to " + sourceVertex.id());
-                    final Object outVId = edge.outVertex().id();
-                    final Iterator<Vertex> vi = sg.vertices(outVId);
-                    final Vertex outV = vi.hasNext() ? vi.next() : sg.addVertex(T.id, outVId);
-                    final Edge clonedEdge = outV.addEdge(edge.label(), inV);
-                    edge.properties().forEachRemaining(p -> clonedEdge.property(p.key(), p.value()));
-                }
+                LOGGER.info("create edge from " + edge.outVertex().id() + " to " + sourceVertex.id());
+                final Object outVId = edge.outVertex().id();
+                final Iterator<Vertex> vi = sg.vertices(outVId);
+                final Vertex outV = vi.hasNext() ? vi.next() : sg.addVertex(T.id, outVId);
+                final Edge clonedEdge = outV.addEdge(edge.label(), inV);
+                edge.properties().forEachRemaining(p -> clonedEdge.property(p.key(), p.value()));
             }
         }
     }
@@ -154,6 +158,11 @@ public class EdgeCopyVertexProgram extends StaticVertexProgram<Edge> {
             ConfigurationUtils.append(graph.configuration().subset(EDGE_COPY_VERTEX_PROGRAM_CFG_PREFIX), configuration);
             return (EdgeCopyVertexProgram) VertexProgram.createVertexProgram(graph, configuration);
         }
+
+        public Builder direction(final Direction direction) {
+            configuration.setProperty(DIRECTION_CFG_KEY, direction);
+            return this;
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/201b05af/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
index 4cc1602..257f4d9 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
@@ -48,7 +48,7 @@ import java.util.Iterator;
  */
 public final class ScriptRecordReader extends RecordReader<NullWritable, VertexWritable> {
 
-    protected final static String SCRIPT_FILE = "gremlin.hadoop.scriptInputFormat.script";
+    public final static String SCRIPT_FILE = "gremlin.hadoop.scriptInputFormat.script";
     //protected final static String SCRIPT_ENGINE = "gremlin.hadoop.scriptInputFormat.scriptEngine";
     private final static String LINE = "line";
     private final static String FACTORY = "factory";

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/201b05af/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordWriter.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordWriter.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordWriter.java
index d445fcd..afa815f 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordWriter.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordWriter.java
@@ -42,8 +42,8 @@ import java.io.UnsupportedEncodingException;
  */
 public final class ScriptRecordWriter extends RecordWriter<NullWritable, VertexWritable> {
 
-    protected final static String SCRIPT_FILE = "gremlin.hadoop.scriptOutputFormat.script";
-    protected final static String SCRIPT_ENGINE = "gremlin.hadoop.scriptOutputFormat.scriptEngine";
+    public final static String SCRIPT_FILE = "gremlin.hadoop.scriptOutputFormat.script";
+    //protected final static String SCRIPT_ENGINE = "gremlin.hadoop.scriptOutputFormat.scriptEngine";
     private final static String VERTEX = "vertex";
     private final static String WRITE_CALL = "stringify(" + VERTEX + ")";
     private final static String UTF8 = "UTF-8";
@@ -68,7 +68,7 @@ public final class ScriptRecordWriter extends RecordWriter<NullWritable, VertexW
         try {
             this.engine.eval(new InputStreamReader(fs.open(new Path(configuration.get(SCRIPT_FILE)))));
         } catch (final ScriptException e) {
-            throw new IOException(e.getMessage(),e);
+            throw new IOException(e.getMessage(), e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/201b05af/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/EdgeCopyVertexProgramTest.java
----------------------------------------------------------------------
diff --git a/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/EdgeCopyVertexProgramTest.java b/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/EdgeCopyVertexProgramTest.java
new file mode 100644
index 0000000..e41b7d8
--- /dev/null
+++ b/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/EdgeCopyVertexProgramTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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.spark.process.computer.edgecopy;
+
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.ConfigurationUtils;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptRecordReader;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptRecordWriter;
+import org.apache.tinkerpop.gremlin.process.computer.edgecopy.EdgeCopyVertexProgram;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.spark.process.computer.SparkGraphComputer;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import static org.apache.tinkerpop.gremlin.hadoop.Constants.GREMLIN_HADOOP_INPUT_LOCATION;
+import static org.apache.tinkerpop.gremlin.hadoop.Constants.GREMLIN_HADOOP_OUTPUT_LOCATION;
+import static org.apache.tinkerpop.gremlin.hadoop.Constants.HIDDEN_G;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Daniel Kuppitz (http://gremlin.guru)
+ */
+public class EdgeCopyVertexProgramTest {
+
+    private Configuration configuration;
+
+    private static Configuration getNextConfiguration(final Configuration configuration) {
+        final Configuration next = new BaseConfiguration();
+        ConfigurationUtils.copy(configuration, next);
+        next.setProperty(GREMLIN_HADOOP_INPUT_LOCATION, configuration.getString(GREMLIN_HADOOP_OUTPUT_LOCATION) + HIDDEN_G);
+        next.setProperty(GREMLIN_HADOOP_OUTPUT_LOCATION, configuration.getString(GREMLIN_HADOOP_OUTPUT_LOCATION).replaceAll("/$", "_/"));
+        return next;
+    }
+
+    @Before
+    public void initialize() throws IOException, ConfigurationException {
+        final File readGraphConfigurationFile = TestHelper.generateTempFileFromResource(
+                EdgeCopyVertexProgramTest.class, "hadoop-script.properties", "");
+        final File inputFile = TestHelper.generateTempFileFromResource(
+                EdgeCopyVertexProgramTest.class, "tinkerpop-classic.txt", "");
+        final File scriptInputFile = TestHelper.generateTempFileFromResource(
+                EdgeCopyVertexProgramTest.class, "script-input.groovy", "");
+        final File scriptOutputFile = TestHelper.generateTempFileFromResource(
+                EdgeCopyVertexProgramTest.class, "script-output.groovy", "");
+        configuration = new PropertiesConfiguration(readGraphConfigurationFile.getAbsolutePath());
+        configuration.setProperty(GREMLIN_HADOOP_INPUT_LOCATION, inputFile.getAbsolutePath());
+        configuration.setProperty(ScriptRecordReader.SCRIPT_FILE, scriptInputFile.getAbsolutePath());
+        configuration.setProperty(ScriptRecordWriter.SCRIPT_FILE, scriptOutputFile.getAbsolutePath());
+        configuration.setProperty(GREMLIN_HADOOP_OUTPUT_LOCATION, TestHelper.makeTestDataDirectory(
+                EdgeCopyVertexProgramTest.class, "output"));
+        configuration.setProperty("gremlin.hadoop.graphOutputFormat", "org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONOutputFormat");
+    }
+
+    @Test
+    @Ignore
+    public void shouldCopyOutEdges() throws ExecutionException, InterruptedException {
+
+        final Graph readGraph = GraphFactory.open(configuration);
+        final GraphTraversalSource g1 = readGraph.traversal();
+        final Map<Object, Long> o1 = g1.V().map(__.outE().count()).groupCount().next();
+        final Map<Object, Long> i1 = g1.V().map(__.inE().count()).groupCount().next();
+        assertEquals(4, o1.size());
+        assertEquals(1, i1.size());
+
+        final EdgeCopyVertexProgram ecvp = EdgeCopyVertexProgram.build().create(readGraph);
+        readGraph.compute(SparkGraphComputer.class).workers(1).program(ecvp).submit().get();
+
+        final Graph nextGraph = GraphFactory.open(getNextConfiguration(configuration));
+        final GraphTraversalSource g2 = nextGraph.traversal();
+        final Map<Object, Long> o2 = g2.V().map(__.outE().count()).groupCount().next();
+        final Map<Object, Long> i2 = g2.V().map(__.inE().count()).groupCount().next();
+        assertEquals(4, o2.size());
+        assertEquals(3, i2.size());
+    }
+
+    @Test
+    public void shouldCopyOutEdgesGraphSON() throws ExecutionException, InterruptedException {
+
+        final Graph readGraph = GraphFactory.open(configuration);
+        final GraphTraversalSource g1 = readGraph.traversal();
+        final Map<Object, Long> o1 = g1.V().map(__.outE().count()).groupCount().next();
+        final Map<Object, Long> i1 = g1.V().map(__.inE().count()).groupCount().next();
+        assertEquals(4, o1.size());
+        assertEquals(1, i1.size());
+
+        final EdgeCopyVertexProgram ecvp = EdgeCopyVertexProgram.build().create(readGraph);
+        final Graph nextGraph = readGraph.compute(SparkGraphComputer.class).workers(1).program(ecvp).submit().get().graph();
+
+        final GraphTraversalSource g2 = nextGraph.traversal();
+        final Map<Object, Long> o2 = g2.V().map(__.outE().count()).groupCount().next();
+        final Map<Object, Long> i2 = g2.V().map(__.inE().count()).groupCount().next();
+        assertEquals(4, o2.size());
+        assertEquals(3, i2.size());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/201b05af/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/hadoop-script.properties
----------------------------------------------------------------------
diff --git a/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/hadoop-script.properties b/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/hadoop-script.properties
new file mode 100644
index 0000000..1c5a501
--- /dev/null
+++ b/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/hadoop-script.properties
@@ -0,0 +1,32 @@
+# 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.
+gremlin.graph=org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph
+gremlin.hadoop.graphInputFormat=org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptInputFormat
+gremlin.hadoop.graphOutputFormat=org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptOutputFormat
+gremlin.hadoop.jarsInDistributedCache=true
+
+gremlin.hadoop.inputLocation=
+gremlin.hadoop.scriptInputFormat.script=
+gremlin.hadoop.scriptOutputFormat.script=
+gremlin.hadoop.outputLocation=
+
+####################################
+# SparkGraphComputer Configuration #
+####################################
+spark.master=local[4]
+spark.executor.memory=1g
+spark.serializer=org.apache.tinkerpop.gremlin.spark.structure.io.gryo.GryoSerializer

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/201b05af/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/script-input.groovy
----------------------------------------------------------------------
diff --git a/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/script-input.groovy b/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/script-input.groovy
new file mode 100644
index 0000000..adb32b7
--- /dev/null
+++ b/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/script-input.groovy
@@ -0,0 +1,49 @@
+import org.apache.tinkerpop.gremlin.structure.VertexProperty
+
+/*
+ * 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.
+ */
+def parse(line, factory) {
+    def parts = line.split(/\t/)
+    def (id, label, name, x) = parts[0].split(/:/).toList()
+    def v1 = factory.vertex(id, label)
+    if (name != null) v1.property(VertexProperty.Cardinality.single, "name", name)
+    if (x != null) {
+        if (label.equals("project")) v1.property(VertexProperty.Cardinality.single, "lang", x)
+        else v1.property(VertexProperty.Cardinality.single, "age", Integer.valueOf(x))
+    }
+    // process out-edges
+    if (parts.length >= 2) {
+        parts[1].split(/,/).grep { !it.isEmpty() }.each {
+            def (eLabel, refId, weight) = it.split(/:/).toList()
+            def v2 = factory.vertex(refId)
+            def edge = factory.edge(v1, v2, eLabel)
+            edge.property("weight", Double.valueOf(weight))
+        }
+    }
+    // process in-edges
+    if (parts.length == 3) {
+        parts[2].split(/,/).grep { !it.isEmpty() }.each {
+            def (eLabel, refId, weight) = it.split(/:/).toList()
+            def v2 = factory.vertex(refId)
+            def edge = factory.edge(v2, v1, eLabel)
+            edge.property("weight", Double.valueOf(weight))
+        }
+    }
+    return v1
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/201b05af/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/script-output.groovy
----------------------------------------------------------------------
diff --git a/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/script-output.groovy b/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/script-output.groovy
new file mode 100644
index 0000000..47e985d
--- /dev/null
+++ b/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/script-output.groovy
@@ -0,0 +1,34 @@
+import org.apache.tinkerpop.gremlin.structure.Direction
+
+/*
+ * 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.
+ */
+def stringify(vertex) {
+    def edgeMap = { vdir ->
+        return {
+            def e = it.get()
+            def g = e.graph().traversal(standard())
+            g.E(e).values("weight").inject(e.label(), g.E(e).toV(Direction.valueOf(vdir.toUpperCase())).next().id()).join(":")
+        }
+    }
+    def g = vertex.graph().traversal(standard())
+    def v = g.V(vertex).values("name", "age", "lang").inject(vertex.id(), vertex.label()).join(":")
+    def outE = g.V(vertex).outE().map(edgeMap("in")).join(",")
+    def inE = g.V(vertex).inE().map(edgeMap("out")).join(",")
+    return [v, outE, inE].join("\t")
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/201b05af/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/tinkerpop-classic.txt
----------------------------------------------------------------------
diff --git a/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/tinkerpop-classic.txt b/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/tinkerpop-classic.txt
new file mode 100644
index 0000000..519763f
--- /dev/null
+++ b/spark-gremlin/src/test/resources/org/apache/tinkerpop/gremlin/spark/process/computer/edgecopy/tinkerpop-classic.txt
@@ -0,0 +1,6 @@
+1:person:marko:29	knows:2:0.5,knows:4:1.0,created:3:0.4
+2:person:vadas:27
+3:project:lop:java
+4:person:josh:32	created:3:0.4,created:5:1.0
+5:project:ripple:java
+6:person:peter:35	created:3:0.2