You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/07/31 12:17:18 UTC

[01/38] tinkerpop git commit: TINKERPOP-1996 Added with() options for io()

Repository: tinkerpop
Updated Branches:
  refs/heads/master 7d21ee0b8 -> edd823468


TINKERPOP-1996 Added with() options for io()

Included GraphReader and GraphWriter detection and added tests


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

Branch: refs/heads/master
Commit: 13e552b289b5266fcb418baaf2ae90626f6055c4
Parents: d181563
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jul 11 15:40:39 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:39:29 2018 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/process/traversal/IO.java |  54 ++++++
 .../process/traversal/step/map/IoStep.java      | 132 ++++++++++++--
 .../traversal/dsl/graph/GraphTraversalTest.java |   5 +-
 .../decoration/VertexProgramStrategyTest.java   |   7 +-
 .../Process/Traversal/GraphTraversal.cs         |  18 ++
 .../Process/Traversal/GraphTraversalSource.cs   |  17 +-
 .../groovy/jsr223/GroovyTranslatorProvider.java |   6 +
 .../lib/process/graph-traversal.js              |  36 ++--
 .../gremlin_python/process/graph_traversal.py   |  17 +-
 .../gremlin/process/ProcessStandardSuite.java   |   2 +
 .../process/traversal/step/map/ReadTest.java    | 114 ++++++++++--
 .../process/traversal/step/map/WriteTest.java   | 175 +++++++++++++++++++
 .../ElementIdStrategyProcessTest.java           |   1 -
 .../gremlin/hadoop/structure/HadoopGraph.java   |  10 ++
 .../structure/TinkerGraphPlayTest.java          |  12 +-
 ...ctTinkerGraphGraphSONTranslatorProvider.java |   5 +
 .../gryo/TinkerGraphGryoTranslatorProvider.java |   7 +-
 17 files changed, 542 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java
new file mode 100644
index 0000000..f76c2bc
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java
@@ -0,0 +1,54 @@
+/*
+ * 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.process.traversal;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
+
+/**
+ * Fields that can be provided to the {@link GraphTraversalSource#io(String)} using the
+ * {@link GraphTraversal#with(String,Object)} step modulator to provide additional configurations.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class IO {
+
+    private IO() {}
+
+    public static final String graphson = "graphson";
+    public static final String gryo = "gryo";
+    public static final String graphml = "graphml";
+
+    /**
+     * The specific {@link GraphReader} instance to use or the name of the fully qualified classname of such an
+     * instance. If this value is not specified then {@link GraphTraversalSource#io(String)} will attempt to construct
+     * a default {@link GraphReader} based on the file extension provided to it.
+     */
+    public static final String reader = Graph.Hidden.hide("tinkerpop.io.reader");
+
+    /**
+     * The specific {@link GraphWriter} instance to use or the name of the fully qualified classname of such an
+     * instance. If this value is not specified then {@link GraphTraversalSource#io(String)} will attempt to construct
+     * a default {@link GraphWriter} based on the file extension provided to it.
+     */
+    public static final String writer = Graph.Hidden.hide("tinkerpop.io.writer");
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
index b633360..668b3dc 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.step.map;
 
+import org.apache.tinkerpop.gremlin.process.traversal.IO;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
@@ -26,6 +27,12 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.EmptyTraverser;
 import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
 import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
+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.StringFactory;
@@ -36,6 +43,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.reflect.Method;
 
 /**
  * Handles read and write operations into the {@link Graph}.
@@ -43,6 +51,13 @@ import java.io.OutputStream;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class IoStep<S> extends AbstractStep<S,S> implements ReadWriting {
+
+    private enum Format {
+        GRYO,
+        GRAPHSON,
+        GRAPHML
+    }
+
     private Parameters parameters = new Parameters();
     private boolean first = true;
     private String file;
@@ -92,29 +107,118 @@ public class IoStep<S> extends AbstractStep<S,S> implements ReadWriting {
 
         if (mode == Mode.READING) {
             if (!file.exists()) throw new IllegalStateException(this.file + " does not exist");
+            return read(file);
+        } else if (mode == Mode.WRITING) {
+            return write(file);
+        } else {
+            throw new IllegalStateException("Invalid ReadWriting.Mode configured in IoStep: " + mode.name());
+        }
+    }
+
+    private Traverser.Admin<S> write(final File file) {
+        try (final OutputStream stream = new FileOutputStream(file)) {
+            final Graph graph = (Graph) this.traversal.getGraph().get();
+            constructWriter().writeGraph(stream, graph);
+
+            return EmptyTraverser.instance();
+        } catch (IOException ioe) {
+            throw new IllegalStateException(String.format("Could not write file %s from graph", this.file), ioe);
+        }
+    }
 
-            try (final InputStream stream = new FileInputStream(file)) {
-                final Graph graph = (Graph) this.traversal.getGraph().get();
-                GryoReader.build().create().readGraph(stream, graph);
+    private Traverser.Admin<S> read(final File file) {
+        try (final InputStream stream = new FileInputStream(file)) {
+            final Graph graph = (Graph) this.traversal.getGraph().get();
+            constructReader().readGraph(stream, graph);
 
-                return EmptyTraverser.instance();
-            } catch (IOException ioe) {
-                throw new IllegalStateException(String.format("Could not read file %s into graph", this.file), ioe);
+            return EmptyTraverser.instance();
+        } catch (IOException ioe) {
+            throw new IllegalStateException(String.format("Could not read file %s into graph", this.file), ioe);
+        }
+    }
+
+    /**
+     * Builds a {@link GraphReader} instance to use. Attempts to detect the file format to be read using the file
+     * extension or simply uses configurations provided by the user on the parameters given to the step.
+     */
+    private GraphReader constructReader() {
+        final Object objectOrClass = parameters.get(IO.reader, this::detectReader).get(0);
+        if (objectOrClass instanceof GraphReader)
+            return (GraphReader) objectOrClass;
+        else if (objectOrClass instanceof String) {
+            if (objectOrClass.equals(IO.graphson))
+                return GraphSONReader.build().create();
+            else if (objectOrClass.equals(IO.gryo))
+                return GryoReader.build().create();
+            else if (objectOrClass.equals(IO.graphml))
+                return GraphMLReader.build().create();
+            else {
+                try {
+                    final Class<?> graphReaderClazz = Class.forName((String) objectOrClass);
+                    final Method build = graphReaderClazz.getMethod("build");
+                    final GraphReader.ReaderBuilder builder = (GraphReader.ReaderBuilder) build.invoke(null);
+                    return builder.create();
+                } catch (Exception ex) {
+                    throw new IllegalStateException(String.format("Could not construct the specified GraphReader of %s", objectOrClass), ex);
+                }
             }
-        } else if (mode == Mode.WRITING) {
-            try (final OutputStream stream = new FileOutputStream(file)) {
-                final Graph graph = (Graph) this.traversal.getGraph().get();
-                GryoWriter.build().create().writeGraph(stream, graph);
+        } else {
+            throw new IllegalStateException("GraphReader could not be determined");
+        }
+    }
+
+    private GraphReader detectReader() {
+        if (file.endsWith(".kryo"))
+            return GryoReader.build().create();
+        else if (file.endsWith(".json"))
+            return GraphSONReader.build().create();
+        else if (file.endsWith(".xml"))
+            return GraphMLReader.build().create();
+        else
+            throw new IllegalStateException("Could not detect the file format - specify the reader explicitly or rename file with a standard extension");
+    }
 
-                return EmptyTraverser.instance();
-            } catch (IOException ioe) {
-                throw new IllegalStateException(String.format("Could not write file %s from graph", this.file), ioe);
+    /**
+     * Builds a {@link GraphWriter} instance to use. Attempts to detect the file format to be write using the file
+     * extension or simply uses configurations provided by the user on the parameters given to the step.
+     */
+    private GraphWriter constructWriter() {
+        final Object objectOrClass = parameters.get(IO.writer, this::detectWriter).get(0);
+        if (objectOrClass instanceof GraphWriter)
+            return (GraphWriter) objectOrClass;
+        else if (objectOrClass instanceof String) {
+            if (objectOrClass.equals(IO.graphson))
+                return GraphSONWriter.build().create();
+            else if (objectOrClass.equals(IO.gryo))
+                return GryoWriter.build().create();
+            else if (objectOrClass.equals(IO.graphml))
+                return GraphMLWriter.build().create();
+            else {
+                try {
+                    final Class<?> graphWriterClazz = Class.forName((String) objectOrClass);
+                    final Method build = graphWriterClazz.getMethod("build");
+                    final GraphWriter.WriterBuilder builder = (GraphWriter.WriterBuilder) build.invoke(null);
+                    return builder.create();
+                } catch (Exception ex) {
+                    throw new IllegalStateException(String.format("Could not construct the specified GraphReader of %s", objectOrClass), ex);
+                }
             }
         } else {
-            throw new IllegalStateException("Invalid ReadWriting.Mode configured in IoStep: " + mode.name());
+            throw new IllegalStateException("GraphReader could not be determined");
         }
     }
 
+    private GraphWriter detectWriter() {
+        if (file.endsWith(".kryo"))
+            return GryoWriter.build().create();
+        else if (file.endsWith(".json"))
+            return GraphSONWriter.build().create();
+        else if (file.endsWith(".xml"))
+            return GraphMLWriter.build().create();
+        else
+            throw new IllegalStateException("Could not detect the file format - specify the writer explicitly or rename file with a standard extension");
+    }
+
     @Override
     public int hashCode() {
         final int hash = super.hashCode() ^ this.parameters.hashCode();

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java
index 9009d0b..3d9a549 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalTest.java
@@ -38,13 +38,14 @@ import static org.junit.Assert.assertEquals;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class GraphTraversalTest {
     private static final Logger logger = LoggerFactory.getLogger(GraphTraversalTest.class);
 
-    private static Set<String> NO_GRAPH = new HashSet<>(Arrays.asList("asAdmin", "by", "with", "option", "iterate", "to", "from", "profile", "pageRank", "peerPressure", "program", "none"));
+    private static Set<String> NO_GRAPH = new HashSet<>(Arrays.asList("asAdmin", "by", "read", "write", "with", "option", "iterate", "to", "from", "profile", "pageRank", "peerPressure", "program", "none"));
     private static Set<String> NO_ANONYMOUS = new HashSet<>(Arrays.asList("start", "__"));
-    private static Set<String> IGNORES_BYTECODE = new HashSet<>(Arrays.asList("asAdmin", "iterate", "mapValues", "mapKeys"));
+    private static Set<String> IGNORES_BYTECODE = new HashSet<>(Arrays.asList("asAdmin", "read", "write", "iterate", "mapValues", "mapKeys"));
 
     @Test
     public void shouldHaveMethodsOfGraphTraversalOnAnonymousGraphTraversal() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
index 972db9a..d3bb6ef 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
@@ -43,6 +43,7 @@ import static org.junit.Assert.assertEquals;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 @RunWith(Parameterized.class)
 public class VertexProgramStrategyTest {
@@ -68,9 +69,11 @@ public class VertexProgramStrategyTest {
 
         final ComputerResultStep computerResultStep = new ComputerResultStep(EmptyTraversal.instance());
 
+        // The tests for io() need to verify that there is no change i.e. we don't want the step getting wrapped up in
+        // traversalvertexprogramstep stuff or else it won't execute properly in OLAP
         return Arrays.asList(new Traversal[][]{
-                { EmptyGraph.instance().traversal().io("blah.json").read(), EmptyGraph.instance().traversal().io("blah.json").read()},
-                { EmptyGraph.instance().traversal().io("blah.json").write(), EmptyGraph.instance().traversal().io("blah.json").write()},
+                { EmptyGraph.instance().traversal().io("blah.json"), EmptyGraph.instance().traversal().io("blah.json")},
+                { EmptyGraph.instance().traversal().io("blah.json"), EmptyGraph.instance().traversal().io("blah.json")},
                 {__.V().out().count(), start().addStep(traversal(__.V().out().count())).addStep(computerResultStep)},
                 {__.V().pageRank().out().count(), start().pageRank().asAdmin().addStep(traversal(__.V().out().count())).addStep(computerResultStep)},
                 {__.V().out().pageRank(), start().addStep(traversal(__.V().out())).pageRank().asAdmin().addStep(traversal(__.identity())).addStep(computerResultStep)},

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index 990bc14..82d72c0 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -1265,6 +1265,15 @@ namespace Gremlin.Net.Process.Traversal
         }
 
         /// <summary>
+        ///     Adds the read step to this <see cref="GraphTraversal{SType, EType}" />.
+        /// </summary>
+        public GraphTraversal<S, E> Read ()
+        {
+            Bytecode.AddStep("read");
+            return Wrap<S, E>(this);
+        }
+
+        /// <summary>
         ///     Adds the repeat step to this <see cref="GraphTraversal{SType, EType}" />.
         /// </summary>
         public GraphTraversal<S, E> Repeat (ITraversal repeatTraversal)
@@ -1712,5 +1721,14 @@ namespace Gremlin.Net.Process.Traversal
             return Wrap<S, E>(this);
         }
 
+        /// <summary>
+        ///     Adds the write step to this <see cref="GraphTraversal{SType, EType}" />.
+        /// </summary>
+        public GraphTraversal<S, E> Write ()
+        {
+            Bytecode.AddStep("write");
+            return Wrap<S, E>(this);
+        }
+
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
index 4292850..00a3623 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
@@ -334,24 +334,13 @@ namespace Gremlin.Net.Process.Traversal
         }
 
         /// <summary>
-        ///     Spawns a <see cref="GraphTraversal{SType, EType}" /> off this graph traversal source and adds the read step to that
+        ///     Spawns a <see cref="GraphTraversal{SType, EType}" /> off this graph traversal source and adds the io step to that
         ///     traversal.
         /// </summary>
-        public GraphTraversal<S, S> Read<S>(string file)
+        public GraphTraversal<S, S> Io<S>(string file)
         {
             var traversal = new GraphTraversal<S, S>(TraversalStrategies, new Bytecode(Bytecode));
-                traversal.Bytecode.AddStep("read", file);
-            return traversal;
-        }
-
-        /// <summary>
-        ///     Spawns a <see cref="GraphTraversal{SType, EType}" /> off this graph traversal source and adds the write step to that
-        ///     traversal.
-        /// </summary>
-        public GraphTraversal<S, S> Write<S>(string file)
-        {
-            var traversal = new GraphTraversal<S, S>(TraversalStrategies, new Bytecode(Bytecode));
-                traversal.Bytecode.AddStep("write", file);
+                traversal.Bytecode.AddStep("io", file);
             return traversal;
         }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProvider.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProvider.java
index c56e7069..d83b1f7 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProvider.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProvider.java
@@ -24,6 +24,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionCompu
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategy;
@@ -43,6 +45,10 @@ public class GroovyTranslatorProvider extends TinkerGraphProvider {
     private static Set<String> SKIP_TESTS = new HashSet<>(Arrays.asList(
             "testProfileStrategyCallback",
             "testProfileStrategyCallbackSideEffect",
+            // TODO: read and write tests don't translate locally well because of calling iterate() inside read()/write() add a none() - fix????
+            ReadTest.Traversals.class.getCanonicalName(),
+            WriteTest.Traversals.class.getCanonicalName(),
+            //
             GraphComputerTest.class.getCanonicalName(),
             ProgramTest.Traversals.class.getCanonicalName(),
             TraversalInterruptionTest.class.getCanonicalName(),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
index 8fa51de..4f39fa5 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
@@ -173,22 +173,12 @@ class GraphTraversalSource {
   }
   
   /**
-   * read GraphTraversalSource step method.
+   * io GraphTraversalSource step method.
    * @param {...Object} args
    * @returns {GraphTraversal}
    */
-  read(...args) {
-    const b = new Bytecode(this.bytecode).addStep('read', args);
-    return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-  }
-  
-  /**
-   * write GraphTraversalSource step method.
-   * @param {...Object} args
-   * @returns {GraphTraversal}
-   */
-  write(...args) {
-    const b = new Bytecode(this.bytecode).addStep('write', args);
+  io(...args) {
+    const b = new Bytecode(this.bytecode).addStep('io', args);
     return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
   }
   
@@ -913,6 +903,16 @@ class GraphTraversal extends Traversal {
   }
   
   /**
+   * Graph traversal read method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  read(...args) {
+    this.bytecode.addStep('read', args);
+    return this;
+  }
+  
+  /**
    * Graph traversal repeat method.
    * @param {...Object} args
    * @returns {GraphTraversal}
@@ -1162,6 +1162,16 @@ class GraphTraversal extends Traversal {
     return this;
   }
   
+  /**
+   * Graph traversal write method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  write(...args) {
+    this.bytecode.addStep('write', args);
+    return this;
+  }
+  
 }
 
 function callOnEmptyTraversal(fnName, args) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
index e559613..6d56c5c 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
@@ -106,14 +106,9 @@ class GraphTraversalSource(object):
         traversal.bytecode.add_step("inject", *args)
         return traversal
 
-    def read(self, *args):
-        traversal = self.get_graph_traversal()
-        traversal.bytecode.add_step("read", *args)
-        return traversal
-
-    def write(self, *args):
+    def io(self, *args):
         traversal = self.get_graph_traversal()
-        traversal.bytecode.add_step("write", *args)
+        traversal.bytecode.add_step("io", *args)
         return traversal
 
 
@@ -419,6 +414,10 @@ class GraphTraversal(Traversal):
         self.bytecode.add_step("range", *args)
         return self
 
+    def read(self, *args):
+        self.bytecode.add_step("read", *args)
+        return self
+
     def repeat(self, *args):
         self.bytecode.add_step("repeat", *args)
         return self
@@ -519,6 +518,10 @@ class GraphTraversal(Traversal):
         self.bytecode.add_step("with", *args)
         return self
 
+    def write(self, *args):
+        self.bytecode.add_step("write", *args)
+        return self
+
 
 class __(object):
     graph_traversal = GraphTraversal

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java
index 43da8b7..f3eb669 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java
@@ -69,6 +69,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.SumTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.UnfoldTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ValueMapTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ExplainTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest;
@@ -159,6 +160,7 @@ public class ProcessStandardSuite extends AbstractGremlinSuite {
             VertexTest.Traversals.class,
             UnfoldTest.Traversals.class,
             ValueMapTest.Traversals.class,
+            WriteTest.Traversals.class,
 
             // sideEffect
             AggregateTest.Traversals.class,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
index 6b7b67e..9e53169 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
@@ -18,24 +18,22 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.step.map;
 
-import org.apache.tinkerpop.gremlin.LoadGraphWith;
+import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
 import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
-import org.apache.tinkerpop.gremlin.process.IgnoreEngine;
+import org.apache.tinkerpop.gremlin.process.traversal.IO;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.io.IoTest;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLResourceAccess;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONResourceAccess;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoResourceAccess;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import java.io.File;
 import java.io.IOException;
-import java.util.Map;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
@@ -43,22 +41,112 @@ import static org.junit.Assert.assertTrue;
 @RunWith(GremlinProcessRunner.class)
 public abstract class ReadTest extends AbstractGremlinProcessTest {
 
-    public abstract Traversal<Object,Object> get_g_io_read()  throws IOException;
+    public abstract Traversal<Object,Object> get_g_io_readXkryoX(final String fileToRead)  throws IOException;
+
+    public abstract Traversal<Object,Object> get_g_io_read_withXreader_gryoX(final String fileToRead)  throws IOException;
+
+    public abstract Traversal<Object,Object> get_g_io_readXjsonX(final String fileToRead)  throws IOException;
+
+    public abstract Traversal<Object,Object> get_g_io_read_withXreader_graphsonX(final String fileToRead)  throws IOException;
+
+    public abstract Traversal<Object,Object> get_g_io_readXxmlX(final String fileToRead)  throws IOException;
+
+    public abstract Traversal<Object,Object> get_g_io_read_withXreader_graphmlX(final String fileToRead)  throws IOException;
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+    public void g_readXkryoX() throws IOException {
+        final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GryoResourceAccess.class, "tinkerpop-modern-v3d0.kryo", "").getAbsolutePath().replace('\\', '/');
+        final Traversal<Object,Object> traversal = get_g_io_readXkryoX(fileToRead);
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+
+        IoTest.assertModernGraph(graph, false, true);
+    }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+    public void g_io_read_withXreader_gryoX() throws IOException {
+        final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GryoResourceAccess.class, "tinkerpop-modern-v3d0.kryo", "").getAbsolutePath().replace('\\', '/');
+        final Traversal<Object,Object> traversal = get_g_io_read_withXreader_gryoX(fileToRead);
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+
+        IoTest.assertModernGraph(graph, false, true);
+    }
 
     @Test
-    public void g_read() throws IOException {
-        final Traversal<Object,Object> traversal = get_g_io_read();
+    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+    public void g_readXjsonX() throws IOException {
+        final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphSONResourceAccess.class, "tinkerpop-modern-v3d0.json", "").getAbsolutePath().replace('\\', '/');
+        final Traversal<Object,Object> traversal = get_g_io_readXjsonX(fileToRead);
         printTraversalForm(traversal);
-        assertTrue(traversal.hasNext());
+        assertFalse(traversal.hasNext());
+
+        IoTest.assertModernGraph(graph, false, true);
+    }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+    public void g_io_read_withXreader_graphsonX() throws IOException {
+        final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphSONResourceAccess.class, "tinkerpop-modern-v3d0.json", "").getAbsolutePath().replace('\\', '/');
+        final Traversal<Object,Object> traversal = get_g_io_read_withXreader_graphsonX(fileToRead);
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+
+        IoTest.assertModernGraph(graph, false, true);
+    }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+    public void g_readXxmlX() throws IOException {
+        final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphMLResourceAccess.class, "tinkerpop-modern.xml", "").getAbsolutePath().replace('\\', '/');
+        final Traversal<Object,Object> traversal = get_g_io_readXxmlX(fileToRead);
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+
+        IoTest.assertModernGraph(graph, false, true);
+    }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+    public void g_io_read_withXreader_graphmlX() throws IOException {
+        final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphMLResourceAccess.class, "tinkerpop-modern.xml", "").getAbsolutePath().replace('\\', '/');
+        final Traversal<Object,Object> traversal = get_g_io_read_withXreader_graphmlX(fileToRead);
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
 
         IoTest.assertModernGraph(graph, false, true);
     }
 
     public static class Traversals extends ReadTest {
         @Override
-        public Traversal<Object,Object> get_g_io_read() throws IOException {
-            final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GryoResourceAccess.class, "tinkerpop-modern-v3d0.kryo", "").getAbsolutePath().replace('\\', '/');
+        public Traversal<Object,Object> get_g_io_readXkryoX(final String fileToRead) throws IOException {
             return g.io(fileToRead).read();
         }
+
+        @Override
+        public Traversal<Object,Object> get_g_io_read_withXreader_gryoX(final String fileToRead) throws IOException {
+            return g.io(fileToRead).with(IO.reader, IO.gryo).read();
+        }
+
+        @Override
+        public Traversal<Object,Object> get_g_io_readXjsonX(final String fileToRead) throws IOException {
+            return g.io(fileToRead).read();
+        }
+
+        @Override
+        public Traversal<Object,Object> get_g_io_read_withXreader_graphsonX(final String fileToRead) throws IOException {
+            return g.io(fileToRead).with(IO.reader, IO.graphson).read();
+        }
+        @Override
+        public Traversal<Object,Object> get_g_io_readXxmlX(final String fileToRead) throws IOException {
+            return g.io(fileToRead).read();
+        }
+
+        @Override
+        public Traversal<Object,Object> get_g_io_read_withXreader_graphmlX(final String fileToRead) throws IOException {
+            return g.io(fileToRead).with(IO.reader, IO.graphml).read();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java
new file mode 100644
index 0000000..e739c0a
--- /dev/null
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java
@@ -0,0 +1,175 @@
+/*
+ * 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.process.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.LoadGraphWith;
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
+import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
+import org.apache.tinkerpop.gremlin.process.traversal.IO;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@RunWith(GremlinProcessRunner.class)
+public abstract class WriteTest extends AbstractGremlinProcessTest {
+
+    public abstract Traversal<Object,Object> get_g_io_writeXkryoX(final String fileToWrite)  throws IOException;
+
+    public abstract Traversal<Object,Object> get_g_io_write_withXwriter_gryoX(final String fileToWrite)  throws IOException;
+
+    public abstract Traversal<Object,Object> get_g_io_writeXjsonX(final String fileToWrite)  throws IOException;
+
+    public abstract Traversal<Object,Object> get_g_io_write_withXwriter_graphsonX(final String fileToWrite)  throws IOException;
+
+    public abstract Traversal<Object,Object> get_g_io_writeXxmlX(final String fileToWrite)  throws IOException;
+
+    public abstract Traversal<Object,Object> get_g_io_write_withXwriter_graphmlX(final String fileToWrite)  throws IOException;
+
+    @Test
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    public void g_writeXkryoX() throws IOException {
+        final String fileToWrite = TestHelper.generateTempFile(WriteTest.class, "tinkerpop-modern-v3d0", ".kryo").getAbsolutePath().replace('\\', '/');
+
+        final File f = new File(fileToWrite);
+        assertThat(f.length() == 0, is(true));
+
+        final Traversal<Object,Object> traversal = get_g_io_writeXkryoX(fileToWrite);
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+
+        assertThat(f.length() > 0, is(true));
+    }
+
+    @Test
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    public void g_io_write_withXwrite_gryoX() throws IOException {
+        final String fileToWrite = TestHelper.generateTempFile(WriteTest.class, "tinkerpop-modern-v3d0", ".kryo").getAbsolutePath().replace('\\', '/');
+
+        final File f = new File(fileToWrite);
+        assertThat(f.length() == 0, is(true));
+
+        final Traversal<Object,Object> traversal = get_g_io_write_withXwriter_gryoX(fileToWrite);
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+
+        assertThat(f.length() > 0, is(true));
+    }
+
+    @Test
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    public void g_writeXjsonX() throws IOException {
+        final String fileToWrite = TestHelper.generateTempFile(WriteTest.class,"tinkerpop-modern-v3d0", ".json").getAbsolutePath().replace('\\', '/');
+
+        final File f = new File(fileToWrite);
+        assertThat(f.length() == 0, is(true));
+
+        final Traversal<Object,Object> traversal = get_g_io_writeXjsonX(fileToWrite);
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+
+        assertThat(f.length() > 0, is(true));
+    }
+
+    @Test
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    public void g_io_write_withXwriter_graphsonX() throws IOException {
+        final String fileToWrite = TestHelper.generateTempFile(WriteTest.class,"tinkerpop-modern-v3d0", ".json").getAbsolutePath().replace('\\', '/');
+
+        final File f = new File(fileToWrite);
+        assertThat(f.length() == 0, is(true));
+
+        final Traversal<Object,Object> traversal = get_g_io_write_withXwriter_graphsonX(fileToWrite);
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+
+        assertThat(f.length() > 0, is(true));
+    }
+
+    @Test
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    public void g_writeXxmlX() throws IOException {
+        final String fileToWrite = TestHelper.generateTempFile(WriteTest.class,"tinkerpop-modern", ".xml").getAbsolutePath().replace('\\', '/');
+
+        final File f = new File(fileToWrite);
+        assertThat(f.length() == 0, is(true));
+
+        final Traversal<Object,Object> traversal = get_g_io_writeXxmlX(fileToWrite);
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+
+        assertThat(f.length() > 0, is(true));
+    }
+
+    @Test
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    public void g_io_write_withXwriter_graphmlX() throws IOException {
+        final String fileToWrite = TestHelper.generateTempFile(WriteTest.class,"tinkerpop-modern", ".xml").getAbsolutePath().replace('\\', '/');
+
+        final File f = new File(fileToWrite);
+        assertThat(f.length() == 0, is(true));
+
+        final Traversal<Object,Object> traversal = get_g_io_write_withXwriter_graphmlX(fileToWrite);
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+
+        assertThat(f.length() > 0, is(true));
+    }
+
+    public static class Traversals extends WriteTest {
+        @Override
+        public Traversal<Object,Object> get_g_io_writeXkryoX(final String fileToWrite) throws IOException {
+            return g.io(fileToWrite).write();
+        }
+
+        @Override
+        public Traversal<Object,Object> get_g_io_write_withXwriter_gryoX(final String fileToWrite) throws IOException {
+            return g.io(fileToWrite).with(IO.writer, IO.gryo).write();
+        }
+
+        @Override
+        public Traversal<Object,Object> get_g_io_writeXjsonX(final String fileToWrite) throws IOException {
+            return g.io(fileToWrite).write();
+        }
+
+        @Override
+        public Traversal<Object,Object> get_g_io_write_withXwriter_graphsonX(final String fileToWrite) throws IOException {
+            return g.io(fileToWrite).with(IO.writer, IO.graphson).write();
+        }
+        @Override
+        public Traversal<Object,Object> get_g_io_writeXxmlX(final String fileToWrite) throws IOException {
+            return g.io(fileToWrite).write();
+        }
+
+        @Override
+        public Traversal<Object,Object> get_g_io_write_withXwriter_graphmlX(final String fileToWrite) throws IOException {
+            return g.io(fileToWrite).with(IO.writer, IO.graphml).write();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ElementIdStrategyProcessTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ElementIdStrategyProcessTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ElementIdStrategyProcessTest.java
index 9acaa3f..69fa5cf 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ElementIdStrategyProcessTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ElementIdStrategyProcessTest.java
@@ -22,7 +22,6 @@ import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.structure.Vertex;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
index 14c5360..5935ebf 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
@@ -142,6 +142,16 @@ import java.util.stream.Stream;
         method = "g_V_matchXa_followedBy_count_isXgtX10XX_b__a_0followedBy_count_isXgtX10XX_bX_count",
         reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
         computers = {"ALL"})
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest$Traversals",
+        method = "*",
+        reason = "This body of tests is not configured to properly suit OLAP based testing and HadoopGraph is not designed to handle single-threaded OLTP reads/writes.",
+        computers = {"ALL"})
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest$Traversals",
+        method = "*",
+        reason = "This body of tests is not configured to properly suit OLAP based testing and HadoopGraph is not designed to handle single-threaded OLTP reads/writes.",
+        computers = {"ALL"})
 public final class HadoopGraph implements Graph {
 
     public static final Logger LOGGER = LoggerFactory.getLogger(HadoopGraph.class);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
index 598e434..a590835 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
@@ -19,6 +19,7 @@
 package org.apache.tinkerpop.gremlin.tinkergraph.structure;
 
 import org.apache.tinkerpop.gremlin.process.computer.Computer;
+import org.apache.tinkerpop.gremlin.process.traversal.IO;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
@@ -28,6 +29,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.Path
 import org.apache.tinkerpop.gremlin.structure.*;
 import org.apache.tinkerpop.gremlin.structure.io.IoTest;
 import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
 import org.apache.tinkerpop.gremlin.util.TimeUtil;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -333,13 +336,4 @@ public class TinkerGraphPlayTest {
         System.out.println(g.V().as("a").both().as("b").dedup("a", "b").by(T.label).select("a", "b").toList());
 
     }
-
-    @Test
-    public void testBlah() {
-        TinkerGraph graph = TinkerGraph.open();
-        GraphTraversalSource g = graph.traversal();
-        g.io("../data/tinkerpop-modern.kryo").read();
-
-        IoTest.assertModernGraph(graph, true, false);
-    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/AbstractTinkerGraphGraphSONTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/AbstractTinkerGraphGraphSONTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/AbstractTinkerGraphGraphSONTranslatorProvider.java
index c20ed11..8462781 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/AbstractTinkerGraphGraphSONTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/AbstractTinkerGraphGraphSONTranslatorProvider.java
@@ -29,6 +29,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.PageRankTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategyProcessTest;
@@ -52,6 +54,9 @@ public abstract class AbstractTinkerGraphGraphSONTranslatorProvider extends Tink
     private static Set<String> SKIP_TESTS = new HashSet<>(Arrays.asList(
             "testProfileStrategyCallback",
             "testProfileStrategyCallbackSideEffect",
+            // TODO: read and write tests don't translate locally well because of calling iterate() inside read()/write() add a none() - fix????
+            ReadTest.Traversals.class.getCanonicalName(),
+            WriteTest.Traversals.class.getCanonicalName(),
             //
             ProgramTest.Traversals.class.getCanonicalName(),
             TraversalInterruptionTest.class.getCanonicalName(),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13e552b2/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/gryo/TinkerGraphGryoTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/gryo/TinkerGraphGryoTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/gryo/TinkerGraphGryoTranslatorProvider.java
index 91e0385..e09508f 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/gryo/TinkerGraphGryoTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/gryo/TinkerGraphGryoTranslatorProvider.java
@@ -25,6 +25,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionCompu
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategy;
@@ -45,6 +47,10 @@ public class TinkerGraphGryoTranslatorProvider extends TinkerGraphProvider {
             "testProfileStrategyCallback",
             "testProfileStrategyCallbackSideEffect",
             //
+            // TODO: read and write tests don't translate locally well because of calling iterate() inside read()/write() add a none() - fix????
+            ReadTest.Traversals.class.getCanonicalName(),
+            WriteTest.Traversals.class.getCanonicalName(),
+            //
             ProgramTest.Traversals.class.getCanonicalName(),
             TraversalInterruptionTest.class.getCanonicalName(),
             EventStrategyProcessTest.class.getCanonicalName(),
@@ -65,7 +71,6 @@ public class TinkerGraphGryoTranslatorProvider extends TinkerGraphProvider {
     public GraphTraversalSource traversal(final Graph graph) {
         if ((Boolean) graph.configuration().getProperty("skipTest"))
             return graph.traversal();
-            //throw new VerificationException("This test current does not work with Gremlin-Python", EmptyTraversal.instance());
         else {
             final GraphTraversalSource g = graph.traversal();
             return g.withStrategies(new TranslationStrategy(g, new GryoTranslator<>(JavaTranslator.of(g))));


[13/38] tinkerpop git commit: TINKERPOP-1996 Removed use of graph.io() in docs

Posted by sp...@apache.org.
TINKERPOP-1996 Removed use of graph.io() in docs


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

Branch: refs/heads/master
Commit: 5bf19e2d35aa2f050ecca0a7b2190553b0422720
Parents: 6d05805
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 16 09:29:01 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:40:10 2018 -0400

----------------------------------------------------------------------
 docs/src/recipes/centrality.asciidoc                   |  2 +-
 docs/src/reference/implementations-neo4j.asciidoc      |  5 +++--
 .../src/reference/implementations-tinkergraph.asciidoc |  8 ++++----
 docs/src/reference/the-traversal.asciidoc              | 13 +++++++------
 4 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5bf19e2d/docs/src/recipes/centrality.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/recipes/centrality.asciidoc b/docs/src/recipes/centrality.asciidoc
index 8504589..0c1d4bc 100644
--- a/docs/src/recipes/centrality.asciidoc
+++ b/docs/src/recipes/centrality.asciidoc
@@ -156,7 +156,7 @@ give it the highest rank. Consider the following example using the Grateful Dead
 
 [gremlin-groovy]
 ----
-graph.io(graphml()).readGraph('data/grateful-dead.xml')
+g.io('data/grateful-dead.xml').read()
 g.V().repeat(groupCount('m').by('name').out()).times(5).cap('m').                <1>
   order(local).by(values, desc).limit(local, 10).next()                          <2>
 g.V().repeat(groupCount('m').by('name').out().timeLimit(100)).times(5).cap('m'). <3>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5bf19e2d/docs/src/reference/implementations-neo4j.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/implementations-neo4j.asciidoc b/docs/src/reference/implementations-neo4j.asciidoc
index 7e05221..1760bd6 100644
--- a/docs/src/reference/implementations-neo4j.asciidoc
+++ b/docs/src/reference/implementations-neo4j.asciidoc
@@ -93,8 +93,8 @@ labels), a linear scan of the vertex-label partition is still faster than a line
 [gremlin-groovy]
 ----
 graph = Neo4jGraph.open('/tmp/neo4j')
-graph.io(graphml()).readGraph('data/grateful-dead.xml')
 g = graph.traversal()
+g.io('data/grateful-dead.xml').read()
 g.tx().commit()
 clock(1000) {g.V().hasLabel('artist').has('name','Garcia').iterate()}  <1>
 graph.cypher("CREATE INDEX ON :artist(name)") <2>
@@ -161,7 +161,8 @@ It is possible to leverage Cypher from within Gremlin by using the `Neo4jGraph.c
 [gremlin-groovy]
 ----
 graph = Neo4jGraph.open('/tmp/neo4j')
-graph.io(gryo()).readGraph('data/tinkerpop-modern.kryo')
+g = graph.traversal()
+g.io('data/tinkerpop-modern.kryo').read()
 graph.cypher('MATCH (a {name:"marko"}) RETURN a')
 graph.cypher('MATCH (a {name:"marko"}) RETURN a').select('a').out('knows').values('name')
 graph.close()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5bf19e2d/docs/src/reference/implementations-tinkergraph.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/implementations-tinkergraph.asciidoc b/docs/src/reference/implementations-tinkergraph.asciidoc
index 5b04126..acd37dd 100644
--- a/docs/src/reference/implementations-tinkergraph.asciidoc
+++ b/docs/src/reference/implementations-tinkergraph.asciidoc
@@ -90,12 +90,12 @@ TinkerGraph over the Grateful Dead graph.
 ----
 graph = TinkerGraph.open()
 g = graph.traversal()
-graph.io(graphml()).readGraph('data/grateful-dead.xml')
+g.io('data/grateful-dead.xml').read()
 clock(1000) {g.V().has('name','Garcia').iterate()} <1>
 graph = TinkerGraph.open()
 g = graph.traversal()
 graph.createIndex('name',Vertex.class)
-graph.io(graphml()).readGraph('data/grateful-dead.xml')
+g.io('data/grateful-dead.xml').read()
 clock(1000){g.V().has('name','Garcia').iterate()} <2>
 ----
 
@@ -158,13 +158,13 @@ cardinality to `list` or else the data will import as `single`.  Consider the fo
 [gremlin-groovy]
 ----
 graph = TinkerGraph.open()
-graph.io(gryo()).readGraph("data/tinkerpop-crew.kryo")
 g = graph.traversal()
+g.io("data/tinkerpop-crew.kryo").read()
 g.V().properties()
 conf = new BaseConfiguration()
 conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality","list")
 graph = TinkerGraph.open(conf)
-graph.io(gryo()).readGraph("data/tinkerpop-crew.kryo")
 g = graph.traversal()
+g.io("data/tinkerpop-crew.kryo").read()
 g.V().properties()
 ----

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5bf19e2d/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index 34f6b27..cca71f6 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -400,7 +400,8 @@ made more salient on a larger graph. Therefore, the example below leverages the
 [gremlin-groovy]
 ----
 graph = TinkerGraph.open()
-graph.io(graphml()).readGraph('data/grateful-dead.xml')
+g = graph.traversal()
+g.io('data/grateful-dead.xml').read()
 g = graph.traversal().withoutStrategies(LazyBarrierStrategy) <1>
 clockWithResult(1){g.V().both().both().both().count().next()} <2>
 clockWithResult(1){g.V().repeat(both()).times(3).count().next()} <3>
@@ -422,8 +423,8 @@ optimization scenario with the added benefit of reducing the risk of an out-of-m
 [gremlin-groovy]
 ----
 graph = TinkerGraph.open()
-graph.io(graphml()).readGraph('data/grateful-dead.xml')
-g = graph.traversal() <1>
+g = graph.traversal()  <1>
+g.io('data/grateful-dead.xml').read()
 clockWithResult(1){g.V().both().both().both().count().next()}
 g.V().both().both().both().count().iterate().toString()  <2>
 ----
@@ -1401,8 +1402,8 @@ songs which Jerry Garcia has both sung and written (using the Grateful Dead grap
 
 [gremlin-groovy]
 ----
-graph.io(graphml()).readGraph('data/grateful-dead.xml')
 g = graph.traversal()
+g.io('data/grateful-dead.xml').read()
 g.V().match(
         __.as('a').has('name', 'Garcia'),
         __.as('a').in('writtenBy').as('b'),
@@ -2493,8 +2494,8 @@ ranking.
 
 [gremlin-groovy]
 ----
-graph.io(graphml()).readGraph('data/grateful-dead.xml')
 g = graph.traversal()
+g.io('data/grateful-dead.xml').read()
 g.V().hasLabel('song').out('followedBy').groupCount().by('name').
       order(local).by(values,desc).limit(local, 5)
 g.V().hasLabel('song').out('followedBy').groupCount().by('name').
@@ -2507,8 +2508,8 @@ Similarly, for extracting the values from a path or map.
 
 [gremlin-groovy]
 ----
-graph.io(graphml()).readGraph('data/grateful-dead.xml')
 g = graph.traversal()
+g.io('data/grateful-dead.xml').read()
 g.V().hasLabel('song').out('sungBy').groupCount().by('name') <1>
 g.V().hasLabel('song').out('sungBy').groupCount().by('name').select(values) <2>
 g.V().hasLabel('song').out('sungBy').groupCount().by('name').select(values).unfold().


[14/38] tinkerpop git commit: TINKERPOP-1996 Added docs for io()

Posted by sp...@apache.org.
TINKERPOP-1996 Added docs for io()

Killed all the old IO documentation that utilized the GraphReader/Writer classes directly as well as the Graph.io() method that is now deprecated.


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

Branch: refs/heads/master
Commit: 62175c228b77bdbda96c11015f2974828df8f3aa
Parents: 576649f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 13 17:31:46 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:40:10 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/the-graph.asciidoc     | 370 -------------------------
 docs/src/reference/the-traversal.asciidoc | 140 ++++++++++
 2 files changed, 140 insertions(+), 370 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/62175c22/docs/src/reference/the-graph.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-graph.asciidoc b/docs/src/reference/the-graph.asciidoc
index 1bcc96f..e9305b2 100644
--- a/docs/src/reference/the-graph.asciidoc
+++ b/docs/src/reference/the-graph.asciidoc
@@ -345,376 +345,6 @@ In the above case, the call to `graph.tx().createThreadedTx()` creates a new `Gr
 `ThreadLocal` transaction, thus allowing each thread to operate on it in the same context.  In this case, there would
 be three separate vertices persisted to the `Graph`.
 
-== Gremlin I/O
-
-image:gremlin-io.png[width=250,float=right] The task of getting data in and out of `Graph` instances is the job of
-the Gremlin I/O packages.  Gremlin I/O provides two interfaces for reading and writing `Graph` instances: `GraphReader`
-and `GraphWriter`.  These interfaces expose methods that support:
-
-* Reading and writing an entire `Graph`
-* Reading and writing a `Traversal<Vertex>` as adjacency list format
-* Reading and writing a single `Vertex` (with and without associated `Edge` objects)
-* Reading and writing a single `Edge`
-* Reading and writing a single `VertexProperty`
-* Reading and writing a single `Property`
-* Reading and writing an arbitrary `Object`
-
-In all cases, these methods operate in the currency of `InputStream` and `OutputStream` objects, allowing graphs and
-their related elements to be written to and read from files, byte arrays, etc.  The `Graph` interface offers the `io`
-method, which provides access to "reader/writer builder" objects that are pre-configured with serializers provided by
-the `Graph`, as well as helper methods for the various I/O capabilities. Unless there are very advanced requirements
-for the serialization process, it is always best to utilize the methods on the `Io` interface to construct
-`GraphReader` and `GraphWriter` instances, as the implementation may provide some custom settings that would otherwise
-have to be configured manually by the user to do the serialization.
-
-It is up to the implementations of the `GraphReader` and `GraphWriter` interfaces to choose the methods they
-implement and the manner in which they work together.  The only characteristic enforced and expected is that the write
-methods should produce output that is compatible with the corresponding read method.  For example, the output of
-`writeVertices` should be readable as input to `readVertices` and the output of `writeProperty` should be readable as
-input to `readProperty`.
-
-NOTE: Additional documentation for TinkerPop IO formats can be found in the link:http://tinkerpop.apache.org/docs/x.y.z/dev/io/[IO Reference].
-
-=== GraphML Reader/Writer
-
-image:gremlin-graphml.png[width=350,float=left] The link:http://graphml.graphdrawing.org/[GraphML] file format is a
-common XML-based representation of a graph. It is widely supported by graph-related tools and libraries making it a
-solid interchange format for TinkerPop. In other words, if the intent is to work with graph data in conjunction with
-applications outside of TinkerPop, GraphML may be the best choice to do that. Common use cases might be:
-
-* Generate a graph using link:https://networkx.github.io/[NetworkX], export it with GraphML and import it to TinkerPop.
-* Produce a subgraph and export it to GraphML to be consumed by and visualized in link:https://gephi.org/[Gephi].
-* Migrate the data of an entire graph to a different graph database not supported by TinkerPop.
-
-As GraphML is a specification for the serialization of an entire graph and not the individual elements of a graph,
-methods that support input and output of single vertices, edges, etc. are not supported.
-
-WARNING: GraphML is a "lossy" format in that it only supports primitive values for properties and does not have
-support for `Graph` variables.  It will use `toString` to serialize property values outside of those primitives.
-
-WARNING: GraphML as a specification allows for `<edge>` and `<node>` elements to appear in any order.  Most software
-that writes GraphML (including as TinkerPop's `GraphMLWriter`) write `<node>` elements before `<edge>` elements.  However it
-is important to note that `GraphMLReader` will read this data in order and order can matter.  This is because TinkerPop
-does not allow the vertex label to be changed after the vertex has been created.  Therefore, if an `<edge>` element
-comes before the `<node>`, the label on the vertex will be ignored.  It is thus better to order `<node>` elements in the
-GraphML to appear before all `<edge>` elements if vertex labels are important to the graph.
-
-The following code shows how to write a `Graph` instance to file called `tinkerpop-modern.xml` and then how to read
-that file back into a different instance:
-
-[source,java]
-----
-Graph graph = TinkerFactory.createModern();
-graph.io(IoCore.graphml()).writeGraph("tinkerpop-modern.xml");
-Graph newGraph = TinkerGraph.open();
-newGraph.io(IoCore.graphml()).readGraph("tinkerpop-modern.xml");
-----
-
-If a custom configuration is required, then have the `Graph` generate a `GraphReader` or `GraphWriter` "builder" instance:
-
-[source,java]
-----
-Graph graph = TinkerFactory.createModern();
-try (OutputStream os = new FileOutputStream("tinkerpop-modern.xml")) {
-    graph.io(IoCore.graphml()).writer().normalize(true).create().writeGraph(os, graph);
-}
-
-Graph newGraph = TinkerGraph.open();
-try (InputStream stream = new FileInputStream("tinkerpop-modern.xml")) {
-    newGraph.io(IoCore.graphml()).reader().create().readGraph(stream, newGraph);
-}
-----
-
-NOTE: If using GraphML generated from TinkerPop 2.x,  you can read more about its incompatibilities in the
-link:http://tinkerpop.apache.org/docs/x.y.z/upgrade/#graphml-format[Upgrade Documentation].
-
-[[graphson-reader-writer]]
-=== GraphSON Reader/Writer
-
-image:gremlin-graphson.png[width=350,float=left] GraphSON is a link:http://json.org/[JSON]-based format extended
-from earlier versions of TinkerPop. It is important to note that TinkerPop's GraphSON is not backwards compatible
-with prior TinkerPop GraphSON versions. GraphSON has some support from graph-related application outside of TinkerPop,
-but it is generally best used in two cases:
-
-* A text format of the graph or its elements is desired (e.g. debugging, usage in source control, etc.)
-* The graph or its elements need to be consumed by code that is not JVM-based (e.g. JavaScript, Python, .NET, etc.)
-
-GraphSON supports all of the `GraphReader` and `GraphWriter` interface methods and can therefore read or write an
-entire `Graph`, vertices, arbitrary objects, etc.  The following code shows how to write a `Graph` instance to file
-called `tinkerpop-modern.json` and then how to read that file back into a different instance:
-
-[source,java]
-----
-Graph graph = TinkerFactory.createModern();
-graph.io(graphson()).writeGraph("tinkerpop-modern.json");
-
-Graph newGraph = TinkerGraph.open();
-newGraph.io(graphson()).readGraph("tinkerpop-modern.json");
-----
-
-NOTE: Using `graphson()`, which is a static helper method of `IoCore`, will default to the most current version of GraphSON which is 3.0.
-
-If a custom configuration is required, then have the `Graph` generate a `GraphReader` or `GraphWriter` "builder" instance:
-
-[source,java]
-----
-Graph graph = TinkerFactory.createModern();
-try (OutputStream os = new FileOutputStream("tinkerpop-modern.json")) {
-    GraphSONMapper mapper = graph.io(IoCore.graphson()).mapper().normalize(true).create()
-    graph.io(graphson()).writer().mapper(mapper).create().writeGraph(os, graph)
-}
-
-Graph newGraph = TinkerGraph.open();
-try (InputStream stream = new FileInputStream("tinkerpop-modern.json")) {
-    newGraph.io(graphson()).reader().create().readGraph(stream, newGraph);
-}
-----
-
-The following example shows how a single `Vertex` is written to GraphSON using the Gremlin Console:
-
-[gremlin-groovy]
-----
-graph = TinkerFactory.createModern()
-g = graph.traversal()
-f = new ByteArrayOutputStream()
-graph.io(graphson()).writer().create().writeVertex(f, g.V(1).next(), BOTH)
-f.close()
-----
-
-The following GraphSON example shows the output of `GraphSONWriter.writeVertex()` with associated edges:
-
-[source,json]
-----
-{
-	"id": {
-		"@type": "g:Int32",
-		"@value": 1
-	},
-	"label": "person",
-	"outE": {
-		"created": [{
-			"id": {
-				"@type": "g:Int32",
-				"@value": 9
-			},
-			"inV": {
-				"@type": "g:Int32",
-				"@value": 3
-			},
-			"properties": {
-				"weight": {
-					"@type": "g:Double",
-					"@value": 0.4
-				}
-			}
-		}],
-		"knows": [{
-			"id": {
-				"@type": "g:Int32",
-				"@value": 7
-			},
-			"inV": {
-				"@type": "g:Int32",
-				"@value": 2
-			},
-			"properties": {
-				"weight": {
-					"@type": "g:Double",
-					"@value": 0.5
-				}
-			}
-		}, {
-			"id": {
-				"@type": "g:Int32",
-				"@value": 8
-			},
-			"inV": {
-				"@type": "g:Int32",
-				"@value": 4
-			},
-			"properties": {
-				"weight": {
-					"@type": "g:Double",
-					"@value": 1.0
-				}
-			}
-		}]
-	},
-	"properties": {
-		"name": [{
-			"id": {
-				"@type": "g:Int64",
-				"@value": 0
-			},
-			"value": "marko"
-		}],
-		"age": [{
-			"id": {
-				"@type": "g:Int64",
-				"@value": 1
-			},
-			"value": {
-				"@type": "g:Int32",
-				"@value": 29
-			}
-		}]
-	}
-}
-----
-
-GraphSON has several versions and each has differences that prevent complete compatibility with one another. While the
-default version provided by `IoCore.graphson()` is recommended, it is possible to make changes to revert to an earlier
-version. The following shows an example of how to use 1.0 (with type embedding):
-
-[gremlin-groovy]
-----
-graph = TinkerFactory.createModern()
-g = graph.traversal()
-f = new ByteArrayOutputStream()
-mapper = graph.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().typeInfo(TypeInfo.PARTIAL_TYPES).create()
-graph.io(GraphSONIo.build(GraphSONVersion.V1_0)).writer().mapper(mapper).create().writeVertex(f, g.V(1).next(), BOTH)
-f.close()
-----
-
-NOTE: Additional documentation for GraphSON can be found in the link:http://tinkerpop.apache.org/docs/x.y.z/dev/io/#graphson[IO Reference].
-
-IMPORTANT: When using the extended type system in Gremlin Server, support for these types when used in the context of
-Gremlin Language Variants is dependent on the programming language, the driver and its serializers. These
-implementations are only required to support the core types and not the extended ones.
-
-Here's the same previous example of GraphSON 1.0, but with GraphSON 2.0:
-
-[gremlin-groovy]
-----
-graph = TinkerFactory.createModern()
-g = graph.traversal()
-f = new ByteArrayOutputStream()
-mapper = graph.io(graphson()).mapper().version(GraphSONVersion.V2_0).create()
-graph.io(graphson()).writer().mapper(mapper).create().writeVertex(f, g.V(1).next(), BOTH)
-f.close()
-----
-
-Creating a GraphSON 2.0 mapper is done by calling `.version(GraphSONVersion.V2_0)` on the mapper builder. Here's is the
-example output from the code above:
-
-[source,json]
-----
-{
-    "@type": "g:Vertex",
-    "@value": {
-        "id": {
-            "@type": "g:Int32",
-            "@value": 1
-        },
-        "label": "person",
-        "properties": {
-            "name": [{
-                "@type": "g:VertexProperty",
-                "@value": {
-                    "id": {
-                        "@type": "g:Int64",
-                        "@value": 0
-                    },
-                    "value": "marko",
-                    "label": "name"
-                }
-            }],
-            "uuid": [{
-                "@type": "g:VertexProperty",
-                "@value": {
-                    "id": {
-                        "@type": "g:Int64",
-                        "@value": 12
-                    },
-                    "value": {
-                        "@type": "g:UUID",
-                        "@value": "829c7ddb-3831-4687-a872-e25201230cd3"
-                    },
-                    "label": "uuid"
-                }
-            }],
-            "age": [{
-                "@type": "g:VertexProperty",
-                "@value": {
-                    "id": {
-                        "@type": "g:Int64",
-                        "@value": 1
-                    },
-                    "value": {
-                        "@type": "g:Int32",
-                        "@value": 29
-                    },
-                    "label": "age"
-                }
-            }]
-        }
-    }
-}
-----
-
-Types can be disabled when creating a GraphSON 2.0 `Mapper` with:
-
-[source,groovy]
-----
-graph.io(graphson()).mapper().
-      version(GraphSONVersion.V2_0).
-      typeInfo(GraphSONMapper.TypeInfo.NO_TYPES).create()
-----
-
-By disabling types, the JSON payload produced will lack the extra information that is written for types. Please note,
-disabling types can be unsafe with regards to the written data in that types can be lost.
-
-[[gryo-reader-writer]]
-=== Gryo Reader/Writer
-
-image:gremlin-kryo.png[width=400,float=left] link:https://github.com/EsotericSoftware/kryo[Kryo] is a popular
-serialization package for the JVM. Gremlin-Kryo is a binary `Graph` serialization format for use on the JVM by JVM
-languages. It is designed to be space efficient, non-lossy and is promoted as the standard format to use when working
-with graph data inside of the TinkerPop stack. A list of common use cases is presented below:
-
-* Migration from one Gremlin Structure implementation to another (e.g. `TinkerGraph` to `Neo4jGraph`)
-* Serialization of individual graph elements to be sent over the network to another JVM.
-* Backups of in-memory graphs or subgraphs.
-
-WARNING: When migrating between Gremlin Structure implementations, Kryo may not lose data, but it is important to
-consider the features of each `Graph` and whether or not the data types supported in one will be supported in the
-other.  Failure to do so, may result in errors.
-
-Kryo supports all of the `GraphReader` and `GraphWriter` interface methods and can therefore read or write an entire
-`Graph`, vertices, edges, etc.  The following code shows how to write a `Graph` instance to file called
-`tinkerpop-modern.kryo` and then how to read that file back into a different instance:
-
-[source,java]
-----
-Graph graph = TinkerFactory.createModern();
-graph.io(gryo()).writeGraph("tinkerpop-modern.kryo");
-
-Graph newGraph = TinkerGraph.open();
-newGraph.io(gryo()).readGraph("tinkerpop-modern.kryo");
-----
-
-NOTE: Using `gryo()`, which is a static helper method of `IoCore`, will default to the most current version of Gryo which is 3.0.
-
-If a custom configuration is required, then have the `Graph` generate a `GraphReader` or `GraphWriter` "builder" instance:
-
-[source,java]
-----
-Graph graph = TinkerFactory.createModern();
-try (OutputStream os = new FileOutputStream("tinkerpop-modern.kryo")) {
-    graph.io(GryoIo.build(GryoVersion.V1_0)).writer().create().writeGraph(os, graph);
-}
-
-Graph newGraph = TinkerGraph.open();
-try (InputStream stream = new FileInputStream("tinkerpop-modern.kryo")) {
-    newGraph.io(GryoIo.build(GryoVersion.V1_0)).reader().create().readGraph(stream, newGraph);
-}
-----
-
-NOTE: The preferred extension for files names produced by Gryo is `.kryo`.
-
-NOTE: Data migrations from TinkerPop 2.x are discussed in the Appendix of the
-link:http://tinkerpop.apache.org/docs/x.y.z/upgrade/#appendix[Upgrade Documentation].
-
 == Namespace Conventions
 
 End users, <<implementations,graph system providers>>, <<graphcomputer,`GraphComputer`>> algorithm designers,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/62175c22/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index 1fb8abd..34f6b27 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -1049,6 +1049,146 @@ inject(1,2).map {it.get() + 1}.map {g.V(it.get()).next()}.values('name')
 
 link:++http://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#inject-E...-++[`inject(Object)`]
 
+[[_gremlin_i_o]]
+[[io-step]]
+=== IO Step
+
+image:gremlin-io.png[width=250,float=left] The task of importing and exporting the data of `Graph` instances is the
+job of the `io()`-step. By default, TinkerPop supports three formats for importing and exporting graph data in
+<<graphml,GraphML>>, <<graphson,GraphSON>>, and <<gryo,Gryo>>.
+
+NOTE: Additional documentation for TinkerPop IO formats can be found in the link:http://tinkerpop.apache.org/docs/x.y.z/dev/io/[IO Reference].
+
+By itself the `io()` step merely configures the kind of importing and exporting that is going
+to occur and it is the follow-on call to the `read()` or `write()` step that determines which of those actions will
+execute. Therefore, a typical usage of the `io()` step would look like this:
+
+[source,java]
+----
+g.io(someInputFile).read()
+g.io(someOutputFile).write()
+----
+
+By default, the `io()` step will try to detect the right file format using the file name extension. To gain greater
+control of the format use the `with()` step modulator to provide further information to `io()`. For example:
+
+[source,java]
+----
+g.io(someInputFile).
+    with(IO.reader, IO.graphson).
+  read()
+g.io(someOutputFile).
+    with(IO.writer,IO.graphml).
+  write()
+----
+
+The `IO` class is a helper that for the `io()` step that provides expressions that can be used to help configure it
+and in this case it allows direct specification of the "reader" or "writer" to use. The "reader" actually refers to
+a `GraphReader` implementation and the `writer" refers to a `GraphWriter` implementation. The implementations of
+those interfaces provided by default are the standard TinkerPop implementations.
+
+That default is an important point to consider for users. The default TinkerPop implementations are not designed with
+massive, complex, parallel bulk loading in mind. They are designed to do single-threaded, OLTP-style loading of data
+in the most generic way possible so as to accommodate the greatest number of graph databases out there. As such, from
+a reading perspective, they work best for small datasets (or perhaps medium datasets where memory is plentiful and
+time is not critical) that are loading to an empty graph - incremental loading is not supported. The story from the
+writing perspective is not that different in there are no parallel operations in play, however streaming the output
+to disk requires a single pass of the data without high memory requirements for larger datasets.
+
+In general, TinkerPop recommends that users examine the native bulk import/export tools of the graph implementation
+that they choose. Those tools will often outperform the `io()` step and perhaps be easier to use with a greater
+feature set. That said, graph providers do have the option to optimize `io()` to back it with their own
+import/export utilities and therefore the default behavior provided by TinkerPop described above might be overridden
+by the graph.
+
+An excellent example of this lies in <<hadoop-gremlin,HadoopGraph>> with <<sparkgraphcomputer,SparkGraphComputer>>
+which replaces the default single-threaded implementation with a more advanced OLAP style bulk import/export
+functionality internally using <<clonevertexprogram,CloneVertexProgram>>. With this model, graphs of arbitrary size
+can be imported/exported assuming that there is a Hadoop `InputFormat` or `OutputFormat` to support it.
+
+IMPORTANT: Remote Gremlin Console users or Gremlin Language Variant (GLV) users (e.g. gremlin-python) who utilize
+the `io()` step should recall that their `read()` or `write()` operation will occur on the server and not locally
+and therefore the file specified for import/export must be something accessible by the server.
+
+[[_graphml_reader_writer]]
+[[graphml]]
+==== GraphML
+
+image:gremlin-graphml.png[width=350,float=left] The link:http://graphml.graphdrawing.org/[GraphML] file format is a
+common XML-based representation of a graph. It is widely supported by graph-related tools and libraries making it a
+solid interchange format for TinkerPop. In other words, if the intent is to work with graph data in conjunction with
+applications outside of TinkerPop, GraphML may be the best choice to do that. Common use cases might be:
+
+* Generate a graph using link:https://networkx.github.io/[NetworkX], export it with GraphML and import it to TinkerPop.
+* Produce a subgraph and export it to GraphML to be consumed by and visualized in link:https://gephi.org/[Gephi].
+* Migrate the data of an entire graph to a different graph database not supported by TinkerPop.
+
+WARNING: GraphML is a "lossy" format in that it only supports primitive values for properties and does not have
+support for `Graph` variables.  It will use `toString` to serialize property values outside of those primitives.
+
+WARNING: GraphML as a specification allows for `<edge>` and `<node>` elements to appear in any order.  Most software
+that writes GraphML (including as TinkerPop's `GraphMLWriter`) write `<node>` elements before `<edge>` elements.  However it
+is important to note that `GraphMLReader` will read this data in order and order can matter.  This is because TinkerPop
+does not allow the vertex label to be changed after the vertex has been created.  Therefore, if an `<edge>` element
+comes before the `<node>`, the label on the vertex will be ignored.  It is thus better to order `<node>` elements in the
+GraphML to appear before all `<edge>` elements if vertex labels are important to the graph.
+
+[source,java]
+----
+g.io("graph.xml").read()
+g.io("graph.xml").write()
+----
+
+NOTE: If using GraphML generated from TinkerPop 2.x, read more about its incompatibilities in the
+link:http://tinkerpop.apache.org/docs/x.y.z/upgrade/#graphml-format[Upgrade Documentation].
+
+[[graphson-reader-writer]]
+[[graphson]]
+==== GraphSON
+
+image:gremlin-graphson.png[width=350,float=left] GraphSON is a link:http://json.org/[JSON]-based format extended
+from earlier versions of TinkerPop. It is important to note that TinkerPop's GraphSON is not backwards compatible
+with prior TinkerPop GraphSON versions. GraphSON has some support from graph-related application outside of TinkerPop,
+but it is generally best used in two cases:
+
+* A text format of the graph or its elements is desired (e.g. debugging, usage in source control, etc.)
+* The graph or its elements need to be consumed by code that is not JVM-based (e.g. JavaScript, Python, .NET, etc.)
+
+[source,java]
+----
+g.io("graph.json").read()
+g.io("graph.json").write()
+----
+
+NOTE: Additional documentation for GraphSON can be found in the link:http://tinkerpop.apache.org/docs/x.y.z/dev/io/#graphson[IO Reference].
+
+[[gryo-reader-writer]]
+[[gryo]]
+==== Gryo
+
+image:gremlin-kryo.png[width=400,float=left] link:https://github.com/EsotericSoftware/kryo[Kryo] is a popular
+serialization package for the JVM. Gremlin-Kryo is a binary `Graph` serialization format for use on the JVM by JVM
+languages. It is designed to be space efficient, non-lossy and is promoted as the standard format to use when working
+with graph data inside of the TinkerPop stack. A list of common use cases is presented below:
+
+* Migration from one Gremlin Structure implementation to another (e.g. `TinkerGraph` to `Neo4jGraph`)
+* Serialization of individual graph elements to be sent over the network to another JVM.
+* Backups of in-memory graphs or subgraphs.
+
+WARNING: When migrating between Gremlin Structure implementations, Kryo may not lose data, but it is important to
+consider the features of each `Graph` and whether or not the data types supported in one will be supported in the
+other.  Failure to do so, may result in errors.
+
+[source,java]
+----
+g.io("graph.kryo").read()
+g.io("graph.kryo").write()
+----
+
+*Additional References*
+
+link:++http://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.html#io-String...-++[`io(String)`]
+
 [[is-step]]
 === Is Step
 


[09/38] tinkerpop git commit: TINKERPOP-1996 Added IO to imports and javadoc fixes

Posted by sp...@apache.org.
TINKERPOP-1996 Added IO to imports and javadoc fixes


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

Branch: refs/heads/master
Commit: 328737a371f8a2040d02f9c2dbb06d049ce3c881
Parents: be9db8d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jul 12 11:19:10 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:39:30 2018 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/jsr223/CoreImports.java   |  2 ++
 .../tinkerpop/gremlin/process/traversal/IO.java | 34 ++++++++++++++++----
 2 files changed, 30 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/328737a3/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java
index 9d7eb52..72ad47a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java
@@ -56,6 +56,7 @@ import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.optimiza
 import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
 import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
 import org.apache.tinkerpop.gremlin.process.traversal.Bindings;
+import org.apache.tinkerpop.gremlin.process.traversal.IO;
 import org.apache.tinkerpop.gremlin.process.traversal.Operator;
 import org.apache.tinkerpop.gremlin.process.traversal.Order;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
@@ -184,6 +185,7 @@ public final class CoreImports {
         CLASS_IMPORTS.add(GraphReader.class);
         CLASS_IMPORTS.add(GraphWriter.class);
         CLASS_IMPORTS.add(Io.class);
+        CLASS_IMPORTS.add(IO.class);
         CLASS_IMPORTS.add(IoCore.class);
         CLASS_IMPORTS.add(Storage.class);
         CLASS_IMPORTS.add(GraphMLIo.class);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/328737a3/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java
index f76c2bc..6668cf1 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java
@@ -23,6 +23,12 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
 import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
+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;
 
 /**
  * Fields that can be provided to the {@link GraphTraversalSource#io(String)} using the
@@ -34,21 +40,37 @@ public class IO {
 
     private IO() {}
 
+    /**
+     * A value to supply to {@link IO#reader} or {@link IO#writer} to indicate the format to use. Using this shorthand
+     * will configure a default {@link GraphSONReader} or {@link GraphSONWriter} respectively,
+     */
     public static final String graphson = "graphson";
+
+    /**
+     * A value to supply to {@link IO#reader} or {@link IO#writer} to indicate the format to use. Using this shorthand
+     * will configure a default {@link GryoReader} or {@link GryoWriter} respectively,
+     */
     public static final String gryo = "gryo";
+
+    /**
+     * A value to supply to {@link IO#reader} or {@link IO#writer} to indicate the format to use. Using this shorthand
+     * will configure a default {@link GraphMLReader} or {@link GraphMLWriter} respectively,
+     */
     public static final String graphml = "graphml";
 
     /**
-     * The specific {@link GraphReader} instance to use or the name of the fully qualified classname of such an
-     * instance. If this value is not specified then {@link GraphTraversalSource#io(String)} will attempt to construct
-     * a default {@link GraphReader} based on the file extension provided to it.
+     * The specific {@link GraphReader} instance to use, the name of the fully qualified classname of such an
+     * instance or one of {@link IO#graphson}, {@link IO#gryo} or {@link IO#graphml}. If this value is not specified
+     * then {@link GraphTraversalSource#io(String)} will attempt to construct a default {@link GraphReader} based on
+     * the file extension provided to it.
      */
     public static final String reader = Graph.Hidden.hide("tinkerpop.io.reader");
 
     /**
-     * The specific {@link GraphWriter} instance to use or the name of the fully qualified classname of such an
-     * instance. If this value is not specified then {@link GraphTraversalSource#io(String)} will attempt to construct
-     * a default {@link GraphWriter} based on the file extension provided to it.
+     * The specific {@link GraphWriter} instance to use, the name of the fully qualified classname of such an
+     * instance or one of {@link IO#graphson}, {@link IO#gryo} or {@link IO#graphml}. If this value is not specified
+     * then {@link GraphTraversalSource#io(String)} will attempt to construct a default {@link GraphWriter} based on
+     * the file extension provided to it.
      */
     public static final String writer = Graph.Hidden.hide("tinkerpop.io.writer");
 }


[33/38] tinkerpop git commit: TINKERPOP-1996 Fixed verification on io()

Posted by sp...@apache.org.
TINKERPOP-1996 Fixed verification on io()


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

Branch: refs/heads/master
Commit: 23c71b60cc34c14e9defc6a9a7ab6c57c090460b
Parents: ae3f685
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 13:22:47 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 13:22:47 2018 -0400

----------------------------------------------------------------------
 .../verification/StandardVerificationStrategy.java  |  6 ++++--
 .../StandardVerificationStrategyTest.java           | 16 +++++++++++-----
 2 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/23c71b60/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
index 258d345..7d88ed9 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
@@ -84,8 +84,10 @@ public final class StandardVerificationStrategy extends AbstractTraversalStrateg
             throw new VerificationException("The profile()-Step cannot be specified multiple times.", traversal);
         }
 
-        if (traversal.getStartStep() instanceof ReadWriting && traversal.getSteps().size() != 1) {
-            if (TraversalHelper.getStepsOfClass(NoneStep.class, traversal).size() != traversal.getSteps().size() - 1)
+        if (traversal.getStartStep() instanceof ReadWriting && !endStep.equals(traversal.getStartStep())) {
+            final int total = TraversalHelper.getStepsOfClass(NoneStep.class, traversal).size() +
+                    TraversalHelper.getStepsOfClass(RequirementsStep.class, traversal).size() + 1;
+            if (total != traversal.getSteps().size())
                 throw new VerificationException("The io() step must be the first and only step in the traversal - it cannot be used with other steps", traversal);
         }
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/23c71b60/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
index deec002..96a68b2 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.strategy.verification;
 
+import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
@@ -29,6 +30,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
+import java.io.File;
 import java.util.Arrays;
 
 import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out;
@@ -44,18 +46,22 @@ import static org.junit.Assert.fail;
 @RunWith(Parameterized.class)
 public class StandardVerificationStrategyTest {
 
+
     @Parameterized.Parameters(name = "{0}")
-    public static Iterable<Object[]> data() {
+    public static Iterable<Object[]> data() throws Exception {
+
+        final String file = TestHelper.generateTempFile(StandardVerificationStrategyTest.class, "shouldBeVerified", ".kryo").getAbsolutePath();
+
         return Arrays.asList(new Object[][]{
                 // traversals that should fail verification
                 {"__.repeat(out().fold().unfold()).times(2)", repeat(out().fold().unfold()).times(2), false},
                 {"__.repeat(sum()).times(2)", repeat(sum()).times(2), false},
                 {"__.repeat(out().count())", repeat(out().count()), false},
-                {"__.io().read().V()", EmptyGraph.instance().traversal().io("junk.kryo").read().V(), false},
-                {"__.io().write().V()", EmptyGraph.instance().traversal().io("junk.kryo").write().V(), false},
+                {"__.io().read().V()", EmptyGraph.instance().traversal().io(file).read().V(), false},
+                {"__.io().write().V()", EmptyGraph.instance().traversal().io(file).write().V(), false},
                 // traversals that should pass verification
-                {"__.io().read().V().none()", EmptyGraph.instance().traversal().io("junk.kryo").read().none(), true},
-                {"__.io().write().V().none()", EmptyGraph.instance().traversal().io("junk.kryo").write().none(), true},
+                {"__.io().read()", EmptyGraph.instance().traversal().io(file).read(), true},
+                {"__.io().write()", EmptyGraph.instance().traversal().io(file).write(), true},
                 {"__.V().profile()",
                         __.V().profile(), true},
                 {"__.V().profile('metrics').cap('metrics')",


[05/38] tinkerpop git commit: TINKERPOP-1996 Introduce read() and write() steps

Posted by sp...@apache.org.
TINKERPOP-1996 Introduce read() and write() steps


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

Branch: refs/heads/master
Commit: ec1d05f74fa875e4a07699dc89c3d1956aab586f
Parents: ce73ceb
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jun 29 15:04:17 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:39:29 2018 -0400

----------------------------------------------------------------------
 .../traversal/dsl/graph/GraphTraversal.java     |   2 +
 .../dsl/graph/GraphTraversalSource.java         |  17 +++
 .../process/traversal/step/map/ReadStep.java    | 112 +++++++++++++++++++
 .../process/traversal/step/map/WriteStep.java   | 111 ++++++++++++++++++
 .../strategy/verification/IoUsageStrategy.java  |  60 ++++++++++
 .../verification/IoUsageStrategyTest.java       |  93 +++++++++++++++
 .../glv/GraphTraversalSource.template           |   4 +-
 gremlin-dotnet/glv/generate.groovy              |   5 +-
 .../Process/Traversal/GraphTraversalSource.cs   |  22 ++++
 .../lib/process/graph-traversal.js              |  20 ++++
 .../gremlin_python/process/graph_traversal.py   |  10 ++
 11 files changed, 452 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec1d05f7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index 63aa65d..210367f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -2817,6 +2817,8 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
         public static final String skip = "skip";
         public static final String tail = "tail";
         public static final String coin = "coin";
+        public static final String read = "read";
+        public static final String write = "write";
 
         public static final String timeLimit = "timeLimit";
         public static final String simplePath = "simplePath";

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec1d05f7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
index bc3ef9e..9b82108 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
@@ -31,6 +31,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeStartStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexStartStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.RequirementsStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
@@ -40,6 +42,7 @@ import org.apache.tinkerpop.gremlin.structure.Transaction;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
+import java.util.Map;
 import java.util.Optional;
 import java.util.function.BinaryOperator;
 import java.util.function.Supplier;
@@ -390,6 +393,20 @@ public class GraphTraversalSource implements TraversalSource {
         return traversal.addStep(new GraphStep<>(traversal, Edge.class, true, edgesIds));
     }
 
+    public GraphTraversal<Map<String,Object>, Map<String,Object>> read(final String localFile) {
+        final GraphTraversalSource clone = this.clone();
+        clone.bytecode.addStep(GraphTraversal.Symbols.read, localFile);
+        final GraphTraversal.Admin<Map<String,Object>, Map<String,Object>> traversal = new DefaultGraphTraversal<>(clone);
+        return traversal.addStep(new ReadStep(traversal, localFile));
+    }
+
+    public GraphTraversal<Map<String,Object>, Map<String,Object>> write(final String localFile) {
+        final GraphTraversalSource clone = this.clone();
+        clone.bytecode.addStep(GraphTraversal.Symbols.write, localFile);
+        final GraphTraversal.Admin<Map<String,Object>, Map<String,Object>> traversal = new DefaultGraphTraversal<>(clone);
+        return traversal.addStep(new WriteStep(traversal, localFile));
+    }
+
     /**
      * Proxies calls through to the underlying {@link Graph#tx()}.
      */

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec1d05f7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
new file mode 100644
index 0000000..afc3e53
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
@@ -0,0 +1,112 @@
+/*
+ * 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.process.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Configuring;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
+import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Reads data from a file into a {@link Graph}. This step is meant to be used as the first and last step in a
+ * traversal.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class ReadStep extends AbstractStep<Map<String,Object>, Map<String,Object>> implements Configuring {
+
+    private Parameters parameters = new Parameters();
+    private boolean first = true;
+    private String localFile;
+
+    public ReadStep(final Traversal.Admin traversal, final String localFile) {
+        super(traversal);
+
+        if (null == localFile || localFile.isEmpty())
+            throw new IllegalArgumentException("localFile cannot be null or empty");
+        if (!new File(localFile).exists()) throw new IllegalStateException(localFile + " does not exist");
+
+        this.localFile = localFile;
+    }
+
+    @Override
+    public Parameters getParameters() {
+        return this.parameters;
+    }
+
+    @Override
+    public void configure(final Object... keyValues) {
+        this.parameters.set(null, keyValues);
+    }
+
+    @Override
+    protected Traverser.Admin<Map<String,Object>> processNextStart() {
+        if (!this.first) throw FastNoSuchElementException.instance();
+
+        this.first = false;
+        final TraverserGenerator generator = this.getTraversal().getTraverserGenerator();
+        final File file = new File(localFile);
+
+        try (final InputStream stream = new FileInputStream(file)) {
+            final Graph graph = (Graph) this.traversal.getGraph().get();
+            GryoReader.build().create().readGraph(stream, graph);
+
+            final Map<String,Object> stats = new LinkedHashMap<>();
+            stats.put("vertices", IteratorUtils.count(graph.vertices()));
+            stats.put("edges", IteratorUtils.count(graph.edges()));
+
+            return generator.generate(stats, this, 1L);
+        } catch (IOException ioe) {
+            throw new IllegalStateException(String.format("Could not read file %s into graph", localFile), ioe);
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        final int hash = super.hashCode() ^ this.parameters.hashCode();
+        return (null != this.localFile) ? (hash ^ localFile.hashCode()) : hash;
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this, localFile, this.parameters);
+    }
+
+    @Override
+    public ReadStep clone() {
+        final ReadStep clone = (ReadStep) super.clone();
+        clone.parameters = this.parameters.clone();
+        clone.localFile = this.localFile;
+        return clone;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec1d05f7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
new file mode 100644
index 0000000..e9346cf
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
@@ -0,0 +1,111 @@
+/*
+ * 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.process.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Configuring;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
+import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Writes data to a file from a {@link Graph}. This step is meant to be used as the first and last step in a
+ * traversal.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class WriteStep extends AbstractStep<Map<String,Object>, Map<String,Object>> implements Configuring {
+
+    private Parameters parameters = new Parameters();
+    private boolean first = true;
+    private String localFile;
+
+    public WriteStep(final Traversal.Admin traversal, final String localFile) {
+        super(traversal);
+
+        if (null == localFile || localFile.isEmpty())
+            throw new IllegalArgumentException("localFile cannot be null or empty");
+
+        this.localFile = localFile;
+    }
+
+    @Override
+    public Parameters getParameters() {
+        return this.parameters;
+    }
+
+    @Override
+    public void configure(final Object... keyValues) {
+        this.parameters.set(null, keyValues);
+    }
+
+    @Override
+    protected Traverser.Admin<Map<String,Object>> processNextStart() {
+        if (!this.first) throw FastNoSuchElementException.instance();
+
+        this.first = false;
+        final TraverserGenerator generator = this.getTraversal().getTraverserGenerator();
+
+        final File file = new File(localFile);
+        try (final OutputStream stream = new FileOutputStream(file)) {
+            final Graph graph = (Graph) this.traversal.getGraph().get();
+            GryoWriter.build().create().writeGraph(stream, graph);
+
+            final Map<String, Object> stats = new LinkedHashMap<>();
+            stats.put("vertices", IteratorUtils.count(graph.vertices()));
+            stats.put("edges", IteratorUtils.count(graph.edges()));
+
+            return generator.generate(stats, this, 1L);
+        } catch (IOException ioe) {
+            throw new IllegalStateException(String.format("Could not write file %s from graph", localFile), ioe);
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        final int hash = super.hashCode() ^ this.parameters.hashCode();
+        return (null != this.localFile) ? (hash ^ localFile.hashCode()) : hash;
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this, localFile, this.parameters);
+    }
+
+    @Override
+    public WriteStep clone() {
+        final WriteStep clone = (WriteStep) super.clone();
+        clone.parameters = this.parameters.clone();
+        clone.localFile = this.localFile;
+        return clone;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec1d05f7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
new file mode 100644
index 0000000..95761ff
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
@@ -0,0 +1,60 @@
+/*
+ * 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.process.traversal.strategy.verification;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteStep;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
+
+/**
+ * {@code IoUsageStrategy} prevents the {@link GraphTraversalSource#read(String)} and
+ * {@link GraphTraversalSource#write(String)} steps from being used outside of their intended scope, which is as the
+ * first and last step in a traversal. Therefore, it can only be used as {@code g.read('file.gryo')} and
+ * {@code g.write('file.gryo')}. As both of these steps take additional configuration, the use of the
+ * {@link GraphTraversal#with(String, Object)} is acceptable.
+ * <p/>
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @example <pre>
+ * g.read('file.kryo').V()            // throws VerificationException
+ * g.write('file.kryo').V()           // throws VerificationException
+ * </pre>
+ */
+public final class IoUsageStrategy extends AbstractTraversalStrategy<TraversalStrategy.VerificationStrategy> implements TraversalStrategy.VerificationStrategy {
+
+    private static final IoUsageStrategy INSTANCE = new IoUsageStrategy();
+
+    private IoUsageStrategy() {
+    }
+
+    @Override
+    public void apply(final Traversal.Admin<?, ?> traversal) {
+        if ((traversal.getStartStep() instanceof ReadStep || traversal.getStartStep() instanceof WriteStep) && traversal.getSteps().size() > 1) {
+            throw new VerificationException("The read() or write() steps must be the first and only step in the traversal - they cannot be used with other steps", traversal);
+        }
+    }
+
+    public static IoUsageStrategy instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec1d05f7/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategyTest.java
new file mode 100644
index 0000000..907e2b7
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategyTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.process.traversal.strategy.verification;
+
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
+import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@RunWith(Parameterized.class)
+public class IoUsageStrategyTest {
+
+    private static final GraphTraversalSource g = EmptyGraph.instance().traversal();
+
+    private static File junkFile;
+
+    static {
+        try {
+            junkFile = TestHelper.generateTempFile(IoUsageStrategyTest.class, "fake", "kryo");
+        } catch (IOException ioe) {
+            throw new RuntimeException(ioe);
+        }
+    }
+
+    @Parameterized.Parameters(name = "{0}")
+    public static Iterable<Object[]> data() {
+        return Arrays.asList(new Object[][]{
+                {"g.read('a.kryo')", g.read(junkFile.getAbsolutePath()), true},
+                {"g.write('a.kryo')", g.write(junkFile.getAbsolutePath()), true},
+                {"g.read('a.kryo').with(\"x\", \"y\")", g.read(junkFile.getAbsolutePath()).with("x", "y"), true},
+                {"g.write('a.kryo').with(\"x\", \"y\")", g.write(junkFile.getAbsolutePath()).with("x", "y"), true},
+                {"g.read('a.kryo').V()", g.read(junkFile.getAbsolutePath()).V(), false},
+                {"g.write('a.kryo').V()", g.write(junkFile.getAbsolutePath()).V(), false}
+        });
+    }
+
+    @Parameterized.Parameter(value = 0)
+    public String name;
+
+    @Parameterized.Parameter(value = 1)
+    public Traversal traversal;
+
+    @Parameterized.Parameter(value = 2)
+    public boolean allow;
+
+    @Test
+    public void shouldBeVerified() {
+        final TraversalStrategies strategies = new DefaultTraversalStrategies();
+        strategies.addStrategies(IoUsageStrategy.instance());
+        traversal.asAdmin().setStrategies(strategies);
+        if (allow) {
+            traversal.asAdmin().applyStrategies();
+        } else {
+            try {
+                traversal.asAdmin().applyStrategies();
+                fail("The strategy should not allow read()/write() to be used with other steps: " + this.traversal);
+            } catch (VerificationException ise) {
+                assertTrue(ise.getMessage().contains("read() or write() steps"));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec1d05f7/gremlin-dotnet/glv/GraphTraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/GraphTraversalSource.template b/gremlin-dotnet/glv/GraphTraversalSource.template
index afa4297..23d66e5 100644
--- a/gremlin-dotnet/glv/GraphTraversalSource.template
+++ b/gremlin-dotnet/glv/GraphTraversalSource.template
@@ -127,9 +127,9 @@ namespace Gremlin.Net.Process.Traversal
         ///     Spawns a <see cref="GraphTraversal{SType, EType}" /> off this graph traversal source and adds the <%= method.methodName %> step to that
         ///     traversal.
         /// </summary>
-        public GraphTraversal<$method.typeNameString> <%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %>(<%= method.parameters %>)
+        public GraphTraversal<$method.t1, $method.t2> <%= toCSharpMethodName.call(method.methodName) %><%= method.tParam %>(<%= method.parameters %>)
         {
-            var traversal = new GraphTraversal<$method.typeNameString>(TraversalStrategies, new Bytecode(Bytecode));
+            var traversal = new GraphTraversal<$method.t1, $method.t2>(TraversalStrategies, new Bytecode(Bytecode));
             <%  if (method.parameters.contains("params ")) {
           %>var args = new List<$method.argsListType>(<%= method.paramNames.init().size() %> + <%= method.paramNames.last() %>.Length) {<%= method.paramNames.init().join(", ") %>};
             args.AddRange(<%= method.paramNames.last() %>);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec1d05f7/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index e542471..bd2d9d7 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -38,6 +38,7 @@ def toCSharpTypeMap = ["Long": "long",
                        "Object[]": "object[]",
                        "Class": "Type",
                        "Class[]": "Type[]",
+                       "java.util.Map<java.lang.String, java.lang.Object>": "IDictionary<string, object>",
                        "java.util.Map<java.lang.String, E2>": "IDictionary<string, E2>",
                        "java.util.Map<java.lang.String, B>": "IDictionary<string, E2>",
                        "java.util.Map<java.lang.Object, E2>": "IDictionary<object, E2>",
@@ -251,13 +252,13 @@ def binding = ["pmethods": P.class.getMethods().
                         unique { a,b -> a.name <=> b.name ?: getCSharpParamTypeString(a) <=> getCSharpParamTypeString(b) }.
                         collect { javaMethod ->
                             def typeNames = getJavaGenericTypeParameterTypeNames(javaMethod)
-                            def typeNameString = typeNames.join(", ")
+                            def t1 = toCSharpType(typeNames[0])
                             def t2 = toCSharpType(typeNames[1])
                             def tParam = getCSharpGenericTypeParam(t2)
                             def parameters = getCSharpParamString(javaMethod, true)
                             def paramNames = getParamNames(javaMethod.parameters)
                             def argsListType = getArgsListType(parameters)
-                            return ["methodName": javaMethod.name, "typeNameString": typeNameString, "tParam":tParam, "parameters":parameters, "paramNames":paramNames, "argsListType":argsListType]
+                            return ["methodName": javaMethod.name, "t1":t1, "t2":t2, "tParam":tParam, "parameters":parameters, "paramNames":paramNames, "argsListType":argsListType]
                         },
                "graphStepMethods": GraphTraversal.getMethods().
                         findAll { GraphTraversal.class.equals(it.returnType) }.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec1d05f7/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
index 2816c05..630ac28 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
@@ -333,6 +333,28 @@ namespace Gremlin.Net.Process.Traversal
             return traversal;
         }
 
+        /// <summary>
+        ///     Spawns a <see cref="GraphTraversal{SType, EType}" /> off this graph traversal source and adds the read step to that
+        ///     traversal.
+        /// </summary>
+        public GraphTraversal<IDictionary<string, object>, IDictionary<string, object>> Read(string localFile)
+        {
+            var traversal = new GraphTraversal<IDictionary<string, object>, IDictionary<string, object>>(TraversalStrategies, new Bytecode(Bytecode));
+                traversal.Bytecode.AddStep("read", localFile);
+            return traversal;
+        }
+
+        /// <summary>
+        ///     Spawns a <see cref="GraphTraversal{SType, EType}" /> off this graph traversal source and adds the write step to that
+        ///     traversal.
+        /// </summary>
+        public GraphTraversal<IDictionary<string, object>, IDictionary<string, object>> Write(string localFile)
+        {
+            var traversal = new GraphTraversal<IDictionary<string, object>, IDictionary<string, object>>(TraversalStrategies, new Bytecode(Bytecode));
+                traversal.Bytecode.AddStep("write", localFile);
+            return traversal;
+        }
+
     }
     
 #pragma warning restore 1591

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec1d05f7/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
index f143542..8fa51de 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
@@ -172,6 +172,26 @@ class GraphTraversalSource {
     return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
   }
   
+  /**
+   * read GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  read(...args) {
+    const b = new Bytecode(this.bytecode).addStep('read', args);
+    return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
+  /**
+   * write GraphTraversalSource step method.
+   * @param {...Object} args
+   * @returns {GraphTraversal}
+   */
+  write(...args) {
+    const b = new Bytecode(this.bytecode).addStep('write', args);
+    return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+  }
+  
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec1d05f7/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
index bb81d87..e559613 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
@@ -106,6 +106,16 @@ class GraphTraversalSource(object):
         traversal.bytecode.add_step("inject", *args)
         return traversal
 
+    def read(self, *args):
+        traversal = self.get_graph_traversal()
+        traversal.bytecode.add_step("read", *args)
+        return traversal
+
+    def write(self, *args):
+        traversal = self.get_graph_traversal()
+        traversal.bytecode.add_step("write", *args)
+        return traversal
+
 
 class GraphTraversal(Traversal):
     def __init__(self, graph, traversal_strategies, bytecode):


[21/38] tinkerpop git commit: TINKERPOP-1996 Enabled feature coverage checks for GLV tests on read()/write()

Posted by sp...@apache.org.
TINKERPOP-1996 Enabled feature coverage checks for GLV tests on read()/write()


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

Branch: refs/heads/master
Commit: a580b6fda232ce6dd035e4c261a53d0f0dc69f83
Parents: 048ea21
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jul 19 14:08:25 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 14:08:25 2018 -0400

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/process/FeatureCoverageTest.java  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a580b6fd/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
index 503df77..5739629 100644
--- a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
+++ b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
@@ -56,11 +56,13 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.PathTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProjectTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.SumTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.UnfoldTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ValueMapTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest;
@@ -158,10 +160,12 @@ public class FeatureCoverageTest {
                 GroupCountTest.class,
                 GroupTest.class,
                 InjectTest.class,
+                ReadTest.class,
                 SackTest.class,
                 SideEffectCapTest.class,
                 //SideEffectTest.class,
-                StoreTest.class);
+                StoreTest.class,
+                WriteTest.class);
                 // SubgraphTest.class,
                 // TreeTest.class);
 


[30/38] tinkerpop git commit: TINKERPOP-1996 Verification strategy to prevent io() from misuse

Posted by sp...@apache.org.
TINKERPOP-1996 Verification strategy to prevent io() from misuse


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

Branch: refs/heads/master
Commit: e6e4413e46594ae8f6d408de4e3d3bd85c228f53
Parents: ded7c18
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 11:47:24 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 11:47:24 2018 -0400

----------------------------------------------------------------------
 .../strategy/verification/StandardVerificationStrategy.java   | 7 +++++++
 .../verification/StandardVerificationStrategyTest.java        | 5 +++++
 2 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e6e4413e/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
index 50faa25..258d345 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
@@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.finaliza
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep;
@@ -39,6 +40,7 @@ import java.util.Set;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public final class StandardVerificationStrategy extends AbstractTraversalStrategy<TraversalStrategy.VerificationStrategy> implements TraversalStrategy.VerificationStrategy {
 
@@ -81,6 +83,11 @@ public final class StandardVerificationStrategy extends AbstractTraversalStrateg
         if (TraversalHelper.getStepsOfClass(ProfileSideEffectStep.class, traversal).size() > 1) {
             throw new VerificationException("The profile()-Step cannot be specified multiple times.", traversal);
         }
+
+        if (traversal.getStartStep() instanceof ReadWriting && traversal.getSteps().size() != 1) {
+            if (TraversalHelper.getStepsOfClass(NoneStep.class, traversal).size() != traversal.getSteps().size() - 1)
+                throw new VerificationException("The io() step must be the first and only step in the traversal - it cannot be used with other steps", traversal);
+        }
     }
 
     public static StandardVerificationStrategy instance() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e6e4413e/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
index ee96266..deec002 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.RequirementsStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
 import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
+import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -50,7 +51,11 @@ public class StandardVerificationStrategyTest {
                 {"__.repeat(out().fold().unfold()).times(2)", repeat(out().fold().unfold()).times(2), false},
                 {"__.repeat(sum()).times(2)", repeat(sum()).times(2), false},
                 {"__.repeat(out().count())", repeat(out().count()), false},
+                {"__.io().read().V()", EmptyGraph.instance().traversal().io("junk.kryo").read().V(), false},
+                {"__.io().write().V()", EmptyGraph.instance().traversal().io("junk.kryo").write().V(), false},
                 // traversals that should pass verification
+                {"__.io().read().V().none()", EmptyGraph.instance().traversal().io("junk.kryo").read().none(), true},
+                {"__.io().write().V().none()", EmptyGraph.instance().traversal().io("junk.kryo").write().none(), true},
                 {"__.V().profile()",
                         __.V().profile(), true},
                 {"__.V().profile('metrics').cap('metrics')",


[24/38] tinkerpop git commit: TINKERPOP-1996 Fixed bad test assertions after last body of changes.

Posted by sp...@apache.org.
TINKERPOP-1996 Fixed bad test assertions after last body of changes.


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

Branch: refs/heads/master
Commit: 94233970f8dc7c5d7b8fdc4b9e7bdbf0ff905c25
Parents: ff71c6a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 06:31:42 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 06:31:42 2018 -0400

----------------------------------------------------------------------
 .../gremlin/process/traversal/step/map/WriteTest.java     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/94233970/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java
index 55e6f9c..9798095 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java
@@ -65,7 +65,7 @@ public abstract class WriteTest extends AbstractGremlinProcessTest {
 
         final Traversal<Object,Object> traversal = get_g_io_writeXkryoX(fileToWrite);
         printTraversalForm(traversal);
-        assertFalse(traversal.hasNext());
+        traversal.iterate();
 
         assertThat(f.length() > 0, is(true));
     }
@@ -81,7 +81,7 @@ public abstract class WriteTest extends AbstractGremlinProcessTest {
 
         final Traversal<Object,Object> traversal = get_g_io_write_withXwriter_gryoX(fileToWrite);
         printTraversalForm(traversal);
-        assertFalse(traversal.hasNext());
+        traversal.iterate();
 
         assertThat(f.length() > 0, is(true));
     }
@@ -97,7 +97,7 @@ public abstract class WriteTest extends AbstractGremlinProcessTest {
 
         final Traversal<Object,Object> traversal = get_g_io_writeXjsonX(fileToWrite);
         printTraversalForm(traversal);
-        assertFalse(traversal.hasNext());
+        traversal.iterate();
 
         assertThat(f.length() > 0, is(true));
     }
@@ -113,7 +113,7 @@ public abstract class WriteTest extends AbstractGremlinProcessTest {
 
         final Traversal<Object,Object> traversal = get_g_io_write_withXwriter_graphsonX(fileToWrite);
         printTraversalForm(traversal);
-        assertFalse(traversal.hasNext());
+        traversal.iterate();
 
         assertThat(f.length() > 0, is(true));
     }
@@ -129,7 +129,7 @@ public abstract class WriteTest extends AbstractGremlinProcessTest {
 
         final Traversal<Object,Object> traversal = get_g_io_writeXxmlX(fileToWrite);
         printTraversalForm(traversal);
-        assertFalse(traversal.hasNext());
+        traversal.iterate();
 
         assertThat(f.length() > 0, is(true));
     }


[16/38] tinkerpop git commit: TINKERPOP-1996 Got read/write() tests running for OLAP

Posted by sp...@apache.org.
TINKERPOP-1996 Got read/write() tests running for OLAP

Introduced new Graph.Features to provider better separation between graph mutation features and graph loading features - they are two different things as demonstrated by io(). Fixed HadoopIoStep/Strategy so that they properly handle the different input/output format types expected.


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

Branch: refs/heads/master
Commit: f148e9331a945e0f4f707ea937b610e5902701c7
Parents: bd275a7
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 13 15:17:17 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:40:10 2018 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/structure/Graph.java      | 27 +++++++++
 .../gremlin/AbstractGraphProvider.java          | 18 ++++--
 .../gremlin/process/ProcessComputerSuite.java   |  4 ++
 .../process/traversal/step/map/ReadTest.java    | 21 ++++---
 .../process/traversal/step/map/WriteTest.java   | 14 ++++-
 .../traversal/step/map/HadoopIoStep.java        | 60 +++++++++++++++++++-
 .../traversal/strategy/HadoopIoStrategy.java    |  2 +-
 .../gremlin/hadoop/structure/HadoopGraph.java   | 16 ++++++
 8 files changed, 142 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f148e933/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
index f1fc54a..f62b897 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
@@ -23,6 +23,8 @@ import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
 import org.apache.tinkerpop.gremlin.structure.io.Io;
 import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
 import org.apache.tinkerpop.gremlin.structure.util.FeatureDescriptor;
@@ -439,6 +441,8 @@ public interface Graph extends AutoCloseable, Host {
             public static final String FEATURE_PERSISTENCE = "Persistence";
             public static final String FEATURE_THREADED_TRANSACTIONS = "ThreadedTransactions";
             public static final String FEATURE_CONCURRENT_ACCESS = "ConcurrentAccess";
+            public static final String FEATURE_IO_READ = "IoRead";
+            public static final String FEATURE_IO_WRITE = "IoWrite";
 
             /**
              * Determines if the {@code Graph} implementation supports {@link GraphComputer} based processing.
@@ -489,6 +493,29 @@ public interface Graph extends AutoCloseable, Host {
             }
 
             /**
+             * Determines if the {@code Graph} implementations supports read operations as executed with the
+             * {@link GraphTraversalSource#io(String)} step. Graph implementations will generally support this by
+             * default as any graph that can support direct mutation through the Structure API will by default
+             * accept data from the standard TinkerPop {@link GraphReader} implementations. However, some graphs like
+             * {@code HadoopGraph} don't accept direct mutations but can still do reads from that {@code io()} step.
+             */
+            @FeatureDescriptor(name = FEATURE_IO_READ)
+            public default boolean supportsIoRead() {
+                return true;
+            }
+
+            /**
+             * Determines if the {@code Graph} implementations supports write operations as executed with the
+             * {@link GraphTraversalSource#io(String)} step. Graph implementations will generally support this by
+             * default given the standard TinkerPop {@link GraphWriter} implementations. However, some graphs like
+             * {@code HadoopGraph} will use a different approach to handle writes.
+             */
+            @FeatureDescriptor(name = FEATURE_IO_WRITE)
+            public default boolean supportsIoWrite() {
+                return true;
+            }
+
+            /**
              * Gets the features related to "graph sideEffects" operation.
              */
             public default VariableFeatures variables() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f148e933/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
index 95c6b57..75d033b 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin;
 
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
 import org.apache.commons.configuration.BaseConfiguration;
@@ -131,12 +132,19 @@ public abstract class AbstractGraphProvider implements GraphProvider {
         return methodName.replaceAll("[0-9, -]+$", String.valueOf(random));
     }
 
-    protected void readIntoGraph(final Graph g, final String path) throws IOException {
-        final GraphReader reader = GryoReader.build()
-                .mapper(g.io(GryoIo.build()).mapper().create())
-                .create();
+    /**
+     * Used by the default implementation of {@link AbstractGraphProvider#loadGraphData(Graph, LoadGraphWith, Class, String)}
+     * to read the graph from a Kryo file using the default {@link GryoReader} implementation. If the default
+     * implementation does not work (perhaps a graph implementation needs to register some special {@link IoRegistry}
+     * then this method or its caller should be overridden to suit the implementation.
+     *
+     * @param graph the graph to load to
+     * @param path the path to the file to load into the graph
+     */
+    protected void readIntoGraph(final Graph graph, final String path) throws IOException {
+        final GraphReader reader = GryoReader.build().create();
         try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream(path)) {
-            reader.readGraph(stream, g);
+            reader.readGraph(stream, graph);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f148e933/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessComputerSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessComputerSuite.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessComputerSuite.java
index b224c8b..eab562d 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessComputerSuite.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessComputerSuite.java
@@ -70,11 +70,13 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProjectTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.SumTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.UnfoldTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ValueMapTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ExplainTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest;
@@ -163,10 +165,12 @@ public class ProcessComputerSuite extends AbstractGremlinSuite {
             ProjectTest.Traversals.class,
             ProgramTest.Traversals.class,
             PropertiesTest.Traversals.class,
+            ReadTest.Traversals.class,
             SelectTest.Traversals.class,
             UnfoldTest.Traversals.class,
             ValueMapTest.Traversals.class,
             VertexTest.Traversals.class,
+            WriteTest.Traversals.class,
 
             // sideEffect
             AddEdgeTest.Traversals.class,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f148e933/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
index 9e53169..ab59194 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
@@ -18,12 +18,14 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.step.map;
 
+import org.apache.tinkerpop.gremlin.FeatureRequirement;
 import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
 import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
 import org.apache.tinkerpop.gremlin.process.traversal.IO;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.IoTest;
 import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLResourceAccess;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONResourceAccess;
@@ -33,6 +35,7 @@ import org.junit.runner.RunWith;
 
 import java.io.IOException;
 
+import static org.apache.tinkerpop.gremlin.structure.Graph.Features.GraphFeatures.FEATURE_IO_READ;
 import static org.junit.Assert.assertFalse;
 
 /**
@@ -54,8 +57,8 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
     public abstract Traversal<Object,Object> get_g_io_read_withXreader_graphmlX(final String fileToRead)  throws IOException;
 
     @Test
-    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
-    public void g_readXkryoX() throws IOException {
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_READ)
+    public void g_io_readXkryoX() throws IOException {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GryoResourceAccess.class, "tinkerpop-modern-v3d0.kryo", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_readXkryoX(fileToRead);
         printTraversalForm(traversal);
@@ -65,7 +68,7 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
     }
 
     @Test
-    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_READ)
     public void g_io_read_withXreader_gryoX() throws IOException {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GryoResourceAccess.class, "tinkerpop-modern-v3d0.kryo", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_read_withXreader_gryoX(fileToRead);
@@ -76,8 +79,8 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
     }
 
     @Test
-    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
-    public void g_readXjsonX() throws IOException {
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_READ)
+    public void g_io_readXjsonX() throws IOException {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphSONResourceAccess.class, "tinkerpop-modern-v3d0.json", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_readXjsonX(fileToRead);
         printTraversalForm(traversal);
@@ -87,7 +90,7 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
     }
 
     @Test
-    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_READ)
     public void g_io_read_withXreader_graphsonX() throws IOException {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphSONResourceAccess.class, "tinkerpop-modern-v3d0.json", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_read_withXreader_graphsonX(fileToRead);
@@ -98,8 +101,8 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
     }
 
     @Test
-    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
-    public void g_readXxmlX() throws IOException {
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_READ)
+    public void g_io_readXxmlX() throws IOException {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphMLResourceAccess.class, "tinkerpop-modern.xml", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_readXxmlX(fileToRead);
         printTraversalForm(traversal);
@@ -109,7 +112,7 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
     }
 
     @Test
-    @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_READ)
     public void g_io_read_withXreader_graphmlX() throws IOException {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphMLResourceAccess.class, "tinkerpop-modern.xml", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_read_withXreader_graphmlX(fileToRead);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f148e933/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java
index e739c0a..55e6f9c 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteTest.java
@@ -18,12 +18,14 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.step.map;
 
+import org.apache.tinkerpop.gremlin.FeatureRequirement;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
 import org.apache.tinkerpop.gremlin.process.traversal.IO;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -54,7 +56,8 @@ public abstract class WriteTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
-    public void g_writeXkryoX() throws IOException {
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_WRITE)
+    public void g_io_writeXkryoX() throws IOException {
         final String fileToWrite = TestHelper.generateTempFile(WriteTest.class, "tinkerpop-modern-v3d0", ".kryo").getAbsolutePath().replace('\\', '/');
 
         final File f = new File(fileToWrite);
@@ -69,6 +72,7 @@ public abstract class WriteTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_WRITE)
     public void g_io_write_withXwrite_gryoX() throws IOException {
         final String fileToWrite = TestHelper.generateTempFile(WriteTest.class, "tinkerpop-modern-v3d0", ".kryo").getAbsolutePath().replace('\\', '/');
 
@@ -84,7 +88,8 @@ public abstract class WriteTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
-    public void g_writeXjsonX() throws IOException {
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_WRITE)
+    public void g_io_writeXjsonX() throws IOException {
         final String fileToWrite = TestHelper.generateTempFile(WriteTest.class,"tinkerpop-modern-v3d0", ".json").getAbsolutePath().replace('\\', '/');
 
         final File f = new File(fileToWrite);
@@ -99,6 +104,7 @@ public abstract class WriteTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_WRITE)
     public void g_io_write_withXwriter_graphsonX() throws IOException {
         final String fileToWrite = TestHelper.generateTempFile(WriteTest.class,"tinkerpop-modern-v3d0", ".json").getAbsolutePath().replace('\\', '/');
 
@@ -114,7 +120,8 @@ public abstract class WriteTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
-    public void g_writeXxmlX() throws IOException {
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_WRITE)
+    public void g_io_writeXxmlX() throws IOException {
         final String fileToWrite = TestHelper.generateTempFile(WriteTest.class,"tinkerpop-modern", ".xml").getAbsolutePath().replace('\\', '/');
 
         final File f = new File(fileToWrite);
@@ -129,6 +136,7 @@ public abstract class WriteTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_WRITE)
     public void g_io_write_withXwriter_graphmlX() throws IOException {
         final String fileToWrite = TestHelper.generateTempFile(WriteTest.class,"tinkerpop-modern", ".xml").getAbsolutePath().replace('\\', '/');
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f148e933/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
index 62937da..97fdea4 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
@@ -18,18 +18,30 @@
  */
 package org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.step.map;
 
+import org.apache.hadoop.mapred.InputFormat;
 import org.apache.tinkerpop.gremlin.hadoop.Constants;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONInputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONOutputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoOutputFormat;
 import org.apache.tinkerpop.gremlin.process.computer.GraphFilter;
 import org.apache.tinkerpop.gremlin.process.computer.Memory;
 import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
+import org.apache.tinkerpop.gremlin.process.traversal.IO;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
 import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
+import java.lang.reflect.Method;
+
 /**
  * An OLAP oriented step for doing IO operations with {@link GraphTraversalSource#io(String)} which uses the
  * {@link CloneVertexProgram} for its implementation.
@@ -103,12 +115,56 @@ public class HadoopIoStep extends VertexProgramStep implements ReadWriting {
     }
 
     private void configureForRead(final Graph graph) {
-        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, "org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat");
+        final String inputFormatClassNameOrKeyword = parameters.get(IO.reader, this::detectReader).get(0);
+        String inputFormatClassName;
+        if (inputFormatClassNameOrKeyword.equals(IO.graphson))
+            inputFormatClassName = GraphSONInputFormat.class.getName();
+        else if (inputFormatClassNameOrKeyword.equals(IO.gryo))
+            inputFormatClassName = GryoInputFormat.class.getName();
+        else if (inputFormatClassNameOrKeyword.equals(IO.graphml))
+            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
+        else
+            inputFormatClassName = inputFormatClassNameOrKeyword;
+
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, inputFormatClassName);
         graph.configuration().setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, file);
     }
 
     private void configureForWrite(final Graph graph) {
-        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, "org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoOutputFormat");
+        final String outputFormatClassNameOrKeyword = parameters.get(IO.writer, this::detectWriter).get(0);
+        String outputFormatClassName;
+        if (outputFormatClassNameOrKeyword.equals(IO.graphson))
+            outputFormatClassName = GraphSONOutputFormat.class.getName();
+        else if (outputFormatClassNameOrKeyword.equals(IO.gryo))
+            outputFormatClassName = GryoOutputFormat.class.getName();
+        else if (outputFormatClassNameOrKeyword.equals(IO.graphml))
+            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
+        else
+            outputFormatClassName = outputFormatClassNameOrKeyword;
+        
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, outputFormatClassName);
         graph.configuration().setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, file);
     }
+
+    private String detectReader() {
+        if (file.endsWith(".kryo"))
+            return GryoInputFormat.class.getName();
+        else if (file.endsWith(".json"))
+            return GraphSONInputFormat.class.getName();
+        else if (file.endsWith(".xml"))
+            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
+        else
+            throw new IllegalStateException("Could not detect the file format - specify the reader explicitly or rename file with a standard extension");
+    }
+
+    private String detectWriter() {
+        if (file.endsWith(".kryo"))
+            return GryoOutputFormat.class.getName();
+        else if (file.endsWith(".json"))
+            return GraphSONOutputFormat.class.getName();
+        else if (file.endsWith(".xml"))
+            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
+        else
+            throw new IllegalStateException("Could not detect the file format - specify the reader explicitly or rename file with a standard extension");
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f148e933/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
index 6d3899e..cbc9b07 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
@@ -55,7 +55,7 @@ public final class HadoopIoStrategy extends AbstractTraversalStrategy<TraversalS
             final HadoopIoStep hadoopIoStep = new HadoopIoStep(traversal, readWriting.getFile());
             hadoopIoStep.setMode(readWriting.getMode());
             readWriting.getParameters().getRaw().entrySet().forEach(kv ->
-                    hadoopIoStep.configure(kv.getKey(), kv.getValue())
+                    hadoopIoStep.configure(kv.getKey(), kv.getValue().get(0))
             );
 
             TraversalHelper.replaceStep((Step) readWriting, hadoopIoStep, traversal);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f148e933/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
index 14c5360..9ec0cfd 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
@@ -142,6 +142,22 @@ import java.util.stream.Stream;
         method = "g_V_matchXa_followedBy_count_isXgtX10XX_b__a_0followedBy_count_isXgtX10XX_bX_count",
         reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
         computers = {"ALL"})
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest$Traversals",
+        method = "g_io_readXxmlX",
+        reason = "Hadoop-Gremlin does not support reads/writes with GraphML.")
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest$Traversals",
+        method = "g_io_read_withXreader_graphmlX",
+        reason = "Hadoop-Gremlin does not support reads/writes with GraphML.")
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest$Traversals",
+        method = "g_io_writeXxmlX",
+        reason = "Hadoop-Gremlin does not support reads/writes with GraphML.")
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest$Traversals",
+        method = "g_io_write_withXwriter_graphmlX",
+        reason = "Hadoop-Gremlin does not support reads/writes with GraphML.")
 public final class HadoopGraph implements Graph {
 
     public static final Logger LOGGER = LoggerFactory.getLogger(HadoopGraph.class);


[28/38] tinkerpop git commit: TINKERPOP-1996 Undeprecated some Io related classes

Posted by sp...@apache.org.
TINKERPOP-1996 Undeprecated some Io related classes

These classes still have use as part of IoRegistry which is still in use and I don't see a clear way to get rid of that easily. We'd have to change the whole system for serialization configuration to accomplish that so I guess this stuff stays for now.


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

Branch: refs/heads/master
Commit: 8fd3bf21efac092f619254245ba83614327c4dcb
Parents: c97d747
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 10:47:20 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 10:47:20 2018 -0400

----------------------------------------------------------------------
 .../main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java   | 3 ---
 .../apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java  | 3 ---
 .../tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java       | 3 ---
 .../org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java    | 3 ---
 4 files changed, 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fd3bf21/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java
index 0971e31..bae56c5 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io;
 
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 
 import java.io.IOException;
@@ -32,9 +31,7 @@ import java.util.function.Consumer;
  * internal {@link Mapper} (if the format has such capability).
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.4.0, replaced by {@link GraphTraversalSource#io(String)}.
  */
-@Deprecated
 public interface Io<R extends GraphReader.ReaderBuilder, W extends GraphWriter.WriterBuilder, M extends Mapper.Builder> {
 
     /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fd3bf21/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java
index b6af646..88431bf 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io.graphml;
 
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.Io;
 import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
@@ -38,9 +37,7 @@ import java.util.function.Consumer;
  * such things.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.4.0, replaced by {@link GraphTraversalSource#io(String)}.
  */
-@Deprecated
 public final class GraphMLIo implements Io<GraphMLReader.Builder, GraphMLWriter.Builder, GraphMLMapper.Builder> {
     private final Graph graph;
     private Optional<Consumer<Mapper.Builder>> onMapper;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fd3bf21/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
index 7f8b835..a3923a1 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io.graphson;
 
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.Io;
 import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
@@ -37,9 +36,7 @@ import java.util.function.Consumer;
  * interfaces should see the {@link GraphSONMapper} for information on the expectations for the {@link IoRegistry}.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.4.0, replaced by {@link GraphTraversalSource#io(String)}.
  */
-@Deprecated
 public final class GraphSONIo implements Io<GraphSONReader.Builder, GraphSONWriter.Builder, GraphSONMapper.Builder> {
     private final Graph graph;
     private final Optional<Consumer<Mapper.Builder>> onMapper;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8fd3bf21/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java
index a7dfe0d..29e63de 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io.gryo;
 
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.Io;
 import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
@@ -37,9 +36,7 @@ import java.util.function.Consumer;
  * interfaces should see the {@link GryoMapper} for information on the expectations for the {@link IoRegistry}.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.4.0, replaced by {@link GraphTraversalSource#io(String)}.
  */
-@Deprecated
 public final class GryoIo implements Io<GryoReader.Builder, GryoWriter.Builder, GryoMapper.Builder> {
 
     private final Graph graph;


[17/38] tinkerpop git commit: TINKERPOP-1996 Moved IoStep implementations to sideEffect package

Posted by sp...@apache.org.
TINKERPOP-1996 Moved IoStep implementations to sideEffect package

These steps really aren't quite sideEffects and not quite map steps either but they seem to fit better as sideEffect. meh


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

Branch: refs/heads/master
Commit: 6d05805ada657bcb3f50a60aa0c313c29d4611bb
Parents: 62175c2
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sat Jul 14 06:23:54 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:40:10 2018 -0400

----------------------------------------------------------------------
 .../dsl/graph/GraphTraversalSource.java         |   2 +-
 .../process/traversal/step/map/IoStep.java      | 241 -------------------
 .../traversal/step/sideEffect/IoStep.java       | 241 +++++++++++++++++++
 .../traversal/step/map/HadoopIoStep.java        | 170 -------------
 .../traversal/step/sideEffect/HadoopIoStep.java | 163 +++++++++++++
 .../traversal/strategy/HadoopIoStrategy.java    |   5 +-
 6 files changed, 407 insertions(+), 415 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6d05805a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
index 7357418..df1b108 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
@@ -31,7 +31,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeStartStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexStartStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.IoStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IoStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.RequirementsStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6d05805a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
deleted file mode 100644
index 668b3dc..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * 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.process.traversal.step.map;
-
-import org.apache.tinkerpop.gremlin.process.traversal.IO;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
-import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.EmptyTraverser;
-import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
-import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
-import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader;
-import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
-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.StringFactory;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Method;
-
-/**
- * Handles read and write operations into the {@link Graph}.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class IoStep<S> extends AbstractStep<S,S> implements ReadWriting {
-
-    private enum Format {
-        GRYO,
-        GRAPHSON,
-        GRAPHML
-    }
-
-    private Parameters parameters = new Parameters();
-    private boolean first = true;
-    private String file;
-    private Mode mode = Mode.UNSET;
-
-    public IoStep(final Traversal.Admin traversal, final String file) {
-        super(traversal);
-
-        if (null == file || file.isEmpty())
-            throw new IllegalArgumentException("file cannot be null or empty");
-
-        this.file = file;
-    }
-
-    @Override
-    public void setMode(final Mode mode) {
-        this.mode = mode;
-    }
-
-    @Override
-    public Mode getMode() {
-        return mode;
-    }
-
-    @Override
-    public String getFile() {
-        return file;
-    }
-
-    @Override
-    public Parameters getParameters() {
-        return this.parameters;
-    }
-
-    @Override
-    public void configure(final Object... keyValues) {
-        this.parameters.set(null, keyValues);
-    }
-
-    @Override
-    protected Traverser.Admin<S> processNextStart() {
-        if (mode == Mode.UNSET) throw new IllegalStateException("IO mode was not set to read() or write()");
-        if (!this.first) throw FastNoSuchElementException.instance();
-
-        this.first = false;
-        final File file = new File(this.file);
-
-        if (mode == Mode.READING) {
-            if (!file.exists()) throw new IllegalStateException(this.file + " does not exist");
-            return read(file);
-        } else if (mode == Mode.WRITING) {
-            return write(file);
-        } else {
-            throw new IllegalStateException("Invalid ReadWriting.Mode configured in IoStep: " + mode.name());
-        }
-    }
-
-    private Traverser.Admin<S> write(final File file) {
-        try (final OutputStream stream = new FileOutputStream(file)) {
-            final Graph graph = (Graph) this.traversal.getGraph().get();
-            constructWriter().writeGraph(stream, graph);
-
-            return EmptyTraverser.instance();
-        } catch (IOException ioe) {
-            throw new IllegalStateException(String.format("Could not write file %s from graph", this.file), ioe);
-        }
-    }
-
-    private Traverser.Admin<S> read(final File file) {
-        try (final InputStream stream = new FileInputStream(file)) {
-            final Graph graph = (Graph) this.traversal.getGraph().get();
-            constructReader().readGraph(stream, graph);
-
-            return EmptyTraverser.instance();
-        } catch (IOException ioe) {
-            throw new IllegalStateException(String.format("Could not read file %s into graph", this.file), ioe);
-        }
-    }
-
-    /**
-     * Builds a {@link GraphReader} instance to use. Attempts to detect the file format to be read using the file
-     * extension or simply uses configurations provided by the user on the parameters given to the step.
-     */
-    private GraphReader constructReader() {
-        final Object objectOrClass = parameters.get(IO.reader, this::detectReader).get(0);
-        if (objectOrClass instanceof GraphReader)
-            return (GraphReader) objectOrClass;
-        else if (objectOrClass instanceof String) {
-            if (objectOrClass.equals(IO.graphson))
-                return GraphSONReader.build().create();
-            else if (objectOrClass.equals(IO.gryo))
-                return GryoReader.build().create();
-            else if (objectOrClass.equals(IO.graphml))
-                return GraphMLReader.build().create();
-            else {
-                try {
-                    final Class<?> graphReaderClazz = Class.forName((String) objectOrClass);
-                    final Method build = graphReaderClazz.getMethod("build");
-                    final GraphReader.ReaderBuilder builder = (GraphReader.ReaderBuilder) build.invoke(null);
-                    return builder.create();
-                } catch (Exception ex) {
-                    throw new IllegalStateException(String.format("Could not construct the specified GraphReader of %s", objectOrClass), ex);
-                }
-            }
-        } else {
-            throw new IllegalStateException("GraphReader could not be determined");
-        }
-    }
-
-    private GraphReader detectReader() {
-        if (file.endsWith(".kryo"))
-            return GryoReader.build().create();
-        else if (file.endsWith(".json"))
-            return GraphSONReader.build().create();
-        else if (file.endsWith(".xml"))
-            return GraphMLReader.build().create();
-        else
-            throw new IllegalStateException("Could not detect the file format - specify the reader explicitly or rename file with a standard extension");
-    }
-
-    /**
-     * Builds a {@link GraphWriter} instance to use. Attempts to detect the file format to be write using the file
-     * extension or simply uses configurations provided by the user on the parameters given to the step.
-     */
-    private GraphWriter constructWriter() {
-        final Object objectOrClass = parameters.get(IO.writer, this::detectWriter).get(0);
-        if (objectOrClass instanceof GraphWriter)
-            return (GraphWriter) objectOrClass;
-        else if (objectOrClass instanceof String) {
-            if (objectOrClass.equals(IO.graphson))
-                return GraphSONWriter.build().create();
-            else if (objectOrClass.equals(IO.gryo))
-                return GryoWriter.build().create();
-            else if (objectOrClass.equals(IO.graphml))
-                return GraphMLWriter.build().create();
-            else {
-                try {
-                    final Class<?> graphWriterClazz = Class.forName((String) objectOrClass);
-                    final Method build = graphWriterClazz.getMethod("build");
-                    final GraphWriter.WriterBuilder builder = (GraphWriter.WriterBuilder) build.invoke(null);
-                    return builder.create();
-                } catch (Exception ex) {
-                    throw new IllegalStateException(String.format("Could not construct the specified GraphReader of %s", objectOrClass), ex);
-                }
-            }
-        } else {
-            throw new IllegalStateException("GraphReader could not be determined");
-        }
-    }
-
-    private GraphWriter detectWriter() {
-        if (file.endsWith(".kryo"))
-            return GryoWriter.build().create();
-        else if (file.endsWith(".json"))
-            return GraphSONWriter.build().create();
-        else if (file.endsWith(".xml"))
-            return GraphMLWriter.build().create();
-        else
-            throw new IllegalStateException("Could not detect the file format - specify the writer explicitly or rename file with a standard extension");
-    }
-
-    @Override
-    public int hashCode() {
-        final int hash = super.hashCode() ^ this.parameters.hashCode();
-        return (null != this.file) ? (hash ^ file.hashCode()) : hash;
-    }
-
-    @Override
-    public String toString() {
-        return StringFactory.stepString(this, file, this.parameters);
-    }
-
-    @Override
-    public IoStep clone() {
-        final IoStep clone = (IoStep) super.clone();
-        clone.parameters = this.parameters.clone();
-        clone.file = this.file;
-        clone.mode = this.mode;
-        return clone;
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6d05805a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
new file mode 100644
index 0000000..74b295b
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
@@ -0,0 +1,241 @@
+/*
+ * 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.process.traversal.step.sideEffect;
+
+import org.apache.tinkerpop.gremlin.process.traversal.IO;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.EmptyTraverser;
+import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
+import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
+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.StringFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Method;
+
+/**
+ * Handles read and write operations into the {@link Graph}.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class IoStep<S> extends AbstractStep<S,S> implements ReadWriting {
+
+    private enum Format {
+        GRYO,
+        GRAPHSON,
+        GRAPHML
+    }
+
+    private Parameters parameters = new Parameters();
+    private boolean first = true;
+    private String file;
+    private Mode mode = Mode.UNSET;
+
+    public IoStep(final Traversal.Admin traversal, final String file) {
+        super(traversal);
+
+        if (null == file || file.isEmpty())
+            throw new IllegalArgumentException("file cannot be null or empty");
+
+        this.file = file;
+    }
+
+    @Override
+    public void setMode(final Mode mode) {
+        this.mode = mode;
+    }
+
+    @Override
+    public Mode getMode() {
+        return mode;
+    }
+
+    @Override
+    public String getFile() {
+        return file;
+    }
+
+    @Override
+    public Parameters getParameters() {
+        return this.parameters;
+    }
+
+    @Override
+    public void configure(final Object... keyValues) {
+        this.parameters.set(null, keyValues);
+    }
+
+    @Override
+    protected Traverser.Admin<S> processNextStart() {
+        if (mode == Mode.UNSET) throw new IllegalStateException("IO mode was not set to read() or write()");
+        if (!this.first) throw FastNoSuchElementException.instance();
+
+        this.first = false;
+        final File file = new File(this.file);
+
+        if (mode == Mode.READING) {
+            if (!file.exists()) throw new IllegalStateException(this.file + " does not exist");
+            return read(file);
+        } else if (mode == Mode.WRITING) {
+            return write(file);
+        } else {
+            throw new IllegalStateException("Invalid ReadWriting.Mode configured in IoStep: " + mode.name());
+        }
+    }
+
+    private Traverser.Admin<S> write(final File file) {
+        try (final OutputStream stream = new FileOutputStream(file)) {
+            final Graph graph = (Graph) this.traversal.getGraph().get();
+            constructWriter().writeGraph(stream, graph);
+
+            return EmptyTraverser.instance();
+        } catch (IOException ioe) {
+            throw new IllegalStateException(String.format("Could not write file %s from graph", this.file), ioe);
+        }
+    }
+
+    private Traverser.Admin<S> read(final File file) {
+        try (final InputStream stream = new FileInputStream(file)) {
+            final Graph graph = (Graph) this.traversal.getGraph().get();
+            constructReader().readGraph(stream, graph);
+
+            return EmptyTraverser.instance();
+        } catch (IOException ioe) {
+            throw new IllegalStateException(String.format("Could not read file %s into graph", this.file), ioe);
+        }
+    }
+
+    /**
+     * Builds a {@link GraphReader} instance to use. Attempts to detect the file format to be read using the file
+     * extension or simply uses configurations provided by the user on the parameters given to the step.
+     */
+    private GraphReader constructReader() {
+        final Object objectOrClass = parameters.get(IO.reader, this::detectReader).get(0);
+        if (objectOrClass instanceof GraphReader)
+            return (GraphReader) objectOrClass;
+        else if (objectOrClass instanceof String) {
+            if (objectOrClass.equals(IO.graphson))
+                return GraphSONReader.build().create();
+            else if (objectOrClass.equals(IO.gryo))
+                return GryoReader.build().create();
+            else if (objectOrClass.equals(IO.graphml))
+                return GraphMLReader.build().create();
+            else {
+                try {
+                    final Class<?> graphReaderClazz = Class.forName((String) objectOrClass);
+                    final Method build = graphReaderClazz.getMethod("build");
+                    final GraphReader.ReaderBuilder builder = (GraphReader.ReaderBuilder) build.invoke(null);
+                    return builder.create();
+                } catch (Exception ex) {
+                    throw new IllegalStateException(String.format("Could not construct the specified GraphReader of %s", objectOrClass), ex);
+                }
+            }
+        } else {
+            throw new IllegalStateException("GraphReader could not be determined");
+        }
+    }
+
+    private GraphReader detectReader() {
+        if (file.endsWith(".kryo"))
+            return GryoReader.build().create();
+        else if (file.endsWith(".json"))
+            return GraphSONReader.build().create();
+        else if (file.endsWith(".xml"))
+            return GraphMLReader.build().create();
+        else
+            throw new IllegalStateException("Could not detect the file format - specify the reader explicitly or rename file with a standard extension");
+    }
+
+    /**
+     * Builds a {@link GraphWriter} instance to use. Attempts to detect the file format to be write using the file
+     * extension or simply uses configurations provided by the user on the parameters given to the step.
+     */
+    private GraphWriter constructWriter() {
+        final Object objectOrClass = parameters.get(IO.writer, this::detectWriter).get(0);
+        if (objectOrClass instanceof GraphWriter)
+            return (GraphWriter) objectOrClass;
+        else if (objectOrClass instanceof String) {
+            if (objectOrClass.equals(IO.graphson))
+                return GraphSONWriter.build().create();
+            else if (objectOrClass.equals(IO.gryo))
+                return GryoWriter.build().create();
+            else if (objectOrClass.equals(IO.graphml))
+                return GraphMLWriter.build().create();
+            else {
+                try {
+                    final Class<?> graphWriterClazz = Class.forName((String) objectOrClass);
+                    final Method build = graphWriterClazz.getMethod("build");
+                    final GraphWriter.WriterBuilder builder = (GraphWriter.WriterBuilder) build.invoke(null);
+                    return builder.create();
+                } catch (Exception ex) {
+                    throw new IllegalStateException(String.format("Could not construct the specified GraphReader of %s", objectOrClass), ex);
+                }
+            }
+        } else {
+            throw new IllegalStateException("GraphReader could not be determined");
+        }
+    }
+
+    private GraphWriter detectWriter() {
+        if (file.endsWith(".kryo"))
+            return GryoWriter.build().create();
+        else if (file.endsWith(".json"))
+            return GraphSONWriter.build().create();
+        else if (file.endsWith(".xml"))
+            return GraphMLWriter.build().create();
+        else
+            throw new IllegalStateException("Could not detect the file format - specify the writer explicitly or rename file with a standard extension");
+    }
+
+    @Override
+    public int hashCode() {
+        final int hash = super.hashCode() ^ this.parameters.hashCode();
+        return (null != this.file) ? (hash ^ file.hashCode()) : hash;
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this, file, this.parameters);
+    }
+
+    @Override
+    public IoStep clone() {
+        final IoStep clone = (IoStep) super.clone();
+        clone.parameters = this.parameters.clone();
+        clone.file = this.file;
+        clone.mode = this.mode;
+        return clone;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6d05805a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
deleted file mode 100644
index 97fdea4..0000000
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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.process.computer.traversal.step.map;
-
-import org.apache.hadoop.mapred.InputFormat;
-import org.apache.tinkerpop.gremlin.hadoop.Constants;
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONInputFormat;
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONOutputFormat;
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat;
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoOutputFormat;
-import org.apache.tinkerpop.gremlin.process.computer.GraphFilter;
-import org.apache.tinkerpop.gremlin.process.computer.Memory;
-import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
-import org.apache.tinkerpop.gremlin.process.traversal.IO;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
-import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-
-import java.lang.reflect.Method;
-
-/**
- * An OLAP oriented step for doing IO operations with {@link GraphTraversalSource#io(String)} which uses the
- * {@link CloneVertexProgram} for its implementation.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class HadoopIoStep extends VertexProgramStep implements ReadWriting {
-
-    private Parameters parameters = new Parameters();
-    private Mode mode = Mode.UNSET;
-    private String file;
-
-    public HadoopIoStep(final Traversal.Admin traversal, final String file) {
-        super(traversal);
-        this.file = file;
-    }
-
-    @Override
-    public void setMode(final Mode mode) {
-        this.mode = mode;
-    }
-
-    @Override
-    public Mode getMode() {
-        return mode;
-    }
-
-    @Override
-    public String getFile() {
-        return file;
-    }
-
-    @Override
-    public void configure(final Object... keyValues) {
-        // TODO: probably should write to the Configuration selectively - no need for actual Parameters?????????
-        this.parameters.set(null, keyValues);
-    }
-
-    @Override
-    public Parameters getParameters() {
-        return parameters;
-    }
-
-    @Override
-    public String toString() {
-        return StringFactory.stepString(this, new GraphFilter(this.computer));
-    }
-
-    @Override
-    public CloneVertexProgram generateProgram(final Graph graph, final Memory memory) {
-        if (mode == Mode.UNSET)
-            throw new IllegalStateException("IO mode was not set to read() or write()");
-        else if (mode == Mode.READING)
-            configureForRead(graph);
-        else if (mode == Mode.WRITING)
-            configureForWrite(graph);
-        else
-            throw new IllegalStateException("Invalid ReadWriting.Mode configured in IoStep: " + mode.name());
-
-        return CloneVertexProgram.build().create(graph);
-    }
-
-    @Override
-    public HadoopIoStep clone() {
-        return (HadoopIoStep) super.clone();
-    }
-
-    @Override
-    public int hashCode() {
-        return super.hashCode();
-    }
-
-    private void configureForRead(final Graph graph) {
-        final String inputFormatClassNameOrKeyword = parameters.get(IO.reader, this::detectReader).get(0);
-        String inputFormatClassName;
-        if (inputFormatClassNameOrKeyword.equals(IO.graphson))
-            inputFormatClassName = GraphSONInputFormat.class.getName();
-        else if (inputFormatClassNameOrKeyword.equals(IO.gryo))
-            inputFormatClassName = GryoInputFormat.class.getName();
-        else if (inputFormatClassNameOrKeyword.equals(IO.graphml))
-            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
-        else
-            inputFormatClassName = inputFormatClassNameOrKeyword;
-
-        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, inputFormatClassName);
-        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, file);
-    }
-
-    private void configureForWrite(final Graph graph) {
-        final String outputFormatClassNameOrKeyword = parameters.get(IO.writer, this::detectWriter).get(0);
-        String outputFormatClassName;
-        if (outputFormatClassNameOrKeyword.equals(IO.graphson))
-            outputFormatClassName = GraphSONOutputFormat.class.getName();
-        else if (outputFormatClassNameOrKeyword.equals(IO.gryo))
-            outputFormatClassName = GryoOutputFormat.class.getName();
-        else if (outputFormatClassNameOrKeyword.equals(IO.graphml))
-            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
-        else
-            outputFormatClassName = outputFormatClassNameOrKeyword;
-        
-        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, outputFormatClassName);
-        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, file);
-    }
-
-    private String detectReader() {
-        if (file.endsWith(".kryo"))
-            return GryoInputFormat.class.getName();
-        else if (file.endsWith(".json"))
-            return GraphSONInputFormat.class.getName();
-        else if (file.endsWith(".xml"))
-            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
-        else
-            throw new IllegalStateException("Could not detect the file format - specify the reader explicitly or rename file with a standard extension");
-    }
-
-    private String detectWriter() {
-        if (file.endsWith(".kryo"))
-            return GryoOutputFormat.class.getName();
-        else if (file.endsWith(".json"))
-            return GraphSONOutputFormat.class.getName();
-        else if (file.endsWith(".xml"))
-            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
-        else
-            throw new IllegalStateException("Could not detect the file format - specify the reader explicitly or rename file with a standard extension");
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6d05805a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/sideEffect/HadoopIoStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/sideEffect/HadoopIoStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/sideEffect/HadoopIoStep.java
new file mode 100644
index 0000000..ca369b6
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/sideEffect/HadoopIoStep.java
@@ -0,0 +1,163 @@
+/*
+ * 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.process.computer.traversal.step.sideEffect;
+
+import org.apache.tinkerpop.gremlin.hadoop.Constants;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONInputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONOutputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoOutputFormat;
+import org.apache.tinkerpop.gremlin.process.computer.GraphFilter;
+import org.apache.tinkerpop.gremlin.process.computer.Memory;
+import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
+import org.apache.tinkerpop.gremlin.process.traversal.IO;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+/**
+ * An OLAP oriented step for doing IO operations with {@link GraphTraversalSource#io(String)} which uses the
+ * {@link CloneVertexProgram} for its implementation.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class HadoopIoStep extends VertexProgramStep implements ReadWriting {
+
+    private Parameters parameters = new Parameters();
+    private Mode mode = Mode.UNSET;
+    private String file;
+
+    public HadoopIoStep(final Traversal.Admin traversal, final String file) {
+        super(traversal);
+        this.file = file;
+    }
+
+    @Override
+    public void setMode(final Mode mode) {
+        this.mode = mode;
+    }
+
+    @Override
+    public Mode getMode() {
+        return mode;
+    }
+
+    @Override
+    public String getFile() {
+        return file;
+    }
+
+    @Override
+    public void configure(final Object... keyValues) {
+        // TODO: probably should write to the Configuration selectively - no need for actual Parameters?????????
+        this.parameters.set(null, keyValues);
+    }
+
+    @Override
+    public Parameters getParameters() {
+        return parameters;
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this, new GraphFilter(this.computer));
+    }
+
+    @Override
+    public CloneVertexProgram generateProgram(final Graph graph, final Memory memory) {
+        if (mode == Mode.UNSET)
+            throw new IllegalStateException("IO mode was not set to read() or write()");
+        else if (mode == Mode.READING)
+            configureForRead(graph);
+        else if (mode == Mode.WRITING)
+            configureForWrite(graph);
+        else
+            throw new IllegalStateException("Invalid ReadWriting.Mode configured in IoStep: " + mode.name());
+
+        return CloneVertexProgram.build().create(graph);
+    }
+
+    @Override
+    public HadoopIoStep clone() {
+        return (HadoopIoStep) super.clone();
+    }
+
+    @Override
+    public int hashCode() {
+        return super.hashCode();
+    }
+
+    private void configureForRead(final Graph graph) {
+        final String inputFormatClassNameOrKeyword = parameters.get(IO.reader, this::detectReader).get(0);
+        String inputFormatClassName;
+        if (inputFormatClassNameOrKeyword.equals(IO.graphson))
+            inputFormatClassName = GraphSONInputFormat.class.getName();
+        else if (inputFormatClassNameOrKeyword.equals(IO.gryo))
+            inputFormatClassName = GryoInputFormat.class.getName();
+        else if (inputFormatClassNameOrKeyword.equals(IO.graphml))
+            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
+        else
+            inputFormatClassName = inputFormatClassNameOrKeyword;
+
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, inputFormatClassName);
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, file);
+    }
+
+    private void configureForWrite(final Graph graph) {
+        final String outputFormatClassNameOrKeyword = parameters.get(IO.writer, this::detectWriter).get(0);
+        String outputFormatClassName;
+        if (outputFormatClassNameOrKeyword.equals(IO.graphson))
+            outputFormatClassName = GraphSONOutputFormat.class.getName();
+        else if (outputFormatClassNameOrKeyword.equals(IO.gryo))
+            outputFormatClassName = GryoOutputFormat.class.getName();
+        else if (outputFormatClassNameOrKeyword.equals(IO.graphml))
+            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
+        else
+            outputFormatClassName = outputFormatClassNameOrKeyword;
+        
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, outputFormatClassName);
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, file);
+    }
+
+    private String detectReader() {
+        if (file.endsWith(".kryo"))
+            return GryoInputFormat.class.getName();
+        else if (file.endsWith(".json"))
+            return GraphSONInputFormat.class.getName();
+        else if (file.endsWith(".xml"))
+            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
+        else
+            throw new IllegalStateException("Could not detect the file format - specify the reader explicitly or rename file with a standard extension");
+    }
+
+    private String detectWriter() {
+        if (file.endsWith(".kryo"))
+            return GryoOutputFormat.class.getName();
+        else if (file.endsWith(".json"))
+            return GraphSONOutputFormat.class.getName();
+        else if (file.endsWith(".xml"))
+            throw new IllegalStateException("GraphML is not a supported file format for OLAP");
+        else
+            throw new IllegalStateException("Could not detect the file format - specify the reader explicitly or rename file with a standard extension");
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6d05805a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
index cbc9b07..8348410 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
@@ -19,15 +19,14 @@
 
 package org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.strategy;
 
-import org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.step.map.HadoopIoStep;
+import org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.step.sideEffect.HadoopIoStep;
 import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.IoStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IoStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 


[32/38] tinkerpop git commit: TINKERPOP-1996 Testing for GraphSON and IoRegistry configuration

Posted by sp...@apache.org.
TINKERPOP-1996 Testing for GraphSON and IoRegistry configuration


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

Branch: refs/heads/master
Commit: ae3f685ad7af326c9f1282da296e9db49f94da03
Parents: 7f1bf17
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 11:55:09 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 11:55:09 2018 -0400

----------------------------------------------------------------------
 .../step/sideEffect/TinkerGraphIoStepTest.java  | 23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae3f685a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphIoStepTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphIoStepTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphIoStepTest.java
index 06c4db8..8bab7da 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphIoStepTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphIoStepTest.java
@@ -72,4 +72,27 @@ public class TinkerGraphIoStepTest {
 
         assertEquals(1, emptyG.V().has("custom", new CustomId("a", uuid)).count().next().intValue());
     }
+
+    @Test
+    public void shouldWriteReadWithCustomIoRegistryGraphSON() throws Exception {
+        final UUID uuid = UUID.randomUUID();
+        g.addV("person").property("name","stephen").property("custom", new CustomId("a", uuid)).iterate();
+
+        final File file = TestHelper.generateTempFile(TinkerGraphIoStepTest.class, "shouldWriteReadWithCustomIoRegistryGraphSON", ".json");
+        g.io(file.getAbsolutePath()).with(IO.registry, CustomId.CustomIdIoRegistry.class.getName()).write().iterate();
+
+        final Graph emptyGraph = TinkerGraph.open();
+        final GraphTraversalSource emptyG = emptyGraph.traversal();
+
+        try {
+            emptyG.io(file.getAbsolutePath()).read().iterate();
+            fail("Can't read without a registry");
+        } catch (Exception ignored) {
+            // do nothing
+        }
+
+        emptyG.io(file.getAbsolutePath()).with(IO.registry, CustomId.CustomIdIoRegistry.instance()).read().iterate();
+
+        assertEquals(1, emptyG.V().has("custom", new CustomId("a", uuid)).count().next().intValue());
+    }
 }


[35/38] tinkerpop git commit: TINKERPOP-1996 Prevent OLTP style execution in Hadoop of io()

Posted by sp...@apache.org.
TINKERPOP-1996 Prevent OLTP style execution in Hadoop of io()


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

Branch: refs/heads/master
Commit: fdb35c69422f95199563e938ec30a2408d419a58
Parents: e9ebacf
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 16:13:47 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 16:13:47 2018 -0400

----------------------------------------------------------------------
 .../process/computer/traversal/strategy/HadoopIoStrategy.java  | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fdb35c69/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
index af3db6e..3614745 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
@@ -29,6 +29,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IoStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.VerificationException;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 
 import java.util.Arrays;
@@ -54,6 +55,11 @@ public final class HadoopIoStrategy extends AbstractTraversalStrategy<TraversalS
 
     @Override
     public void apply(final Traversal.Admin<?, ?> traversal) {
+        // since hadoopgraph can't be modified we can't try to use the existing IoStep for standard processing
+        // without graphcomputer
+        if (traversal.getStartStep() instanceof IoStep)
+            throw new VerificationException("HadoopGraph requires a GraphComputer for io() step", traversal);
+
         // VertexProgramStrategy should wrap up the IoStep in a TraversalVertexProgramStep. use that to grab the
         // GraphComputer that was injected in there and push that in to the HadoopIoStep. this step pattern match
         // is fairly specific and since you really can't chain together steps after io() this approach should work


[36/38] tinkerpop git commit: TINKERPOP-1996 Fixed up typos in docs

Posted by sp...@apache.org.
TINKERPOP-1996 Fixed up typos in docs


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

Branch: refs/heads/master
Commit: 38dc70df6db105595784a93ecf5f5726201a962d
Parents: fdb35c6
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 27 07:07:17 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 27 07:07:17 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/the-traversal.asciidoc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/38dc70df/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index c3b9300..c861d87 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -1086,9 +1086,9 @@ g.io(someOutputFile).
   write().iterate()
 ----
 
-The `IO` class is a helper for the `io()` step that provides expressions that can be used to help configure it
+The `IO` class is a helper for the `io()`-step that provides expressions that can be used to help configure it
 and in this case it allows direct specification of the "reader" or "writer" to use. The "reader" actually refers to
-a `GraphReader` implementation and the `writer" refers to a `GraphWriter` implementation. The implementations of
+a `GraphReader` implementation and the "writer" refers to a `GraphWriter` implementation. The implementations of
 those interfaces provided by default are the standard TinkerPop implementations.
 
 That default is an important point to consider for users. The default TinkerPop implementations are not designed with
@@ -1100,7 +1100,7 @@ writing perspective is not that different in there are no parallel operations in
 to disk requires a single pass of the data without high memory requirements for larger datasets.
 
 In general, TinkerPop recommends that users examine the native bulk import/export tools of the graph implementation
-that they choose. Those tools will often outperform the `io()` step and perhaps be easier to use with a greater
+that they choose. Those tools will often outperform the `io()`-step and perhaps be easier to use with a greater
 feature set. That said, graph providers do have the option to optimize `io()` to back it with their own
 import/export utilities and therefore the default behavior provided by TinkerPop described above might be overridden
 by the graph.
@@ -1111,7 +1111,7 @@ functionality internally using <<clonevertexprogram,CloneVertexProgram>>. With t
 can be imported/exported assuming that there is a Hadoop `InputFormat` or `OutputFormat` to support it.
 
 IMPORTANT: Remote Gremlin Console users or Gremlin Language Variant (GLV) users (e.g. gremlin-python) who utilize
-the `io()` step should recall that their `read()` or `write()` operation will occur on the server and not locally
+the `io()`-step should recall that their `read()` or `write()` operation will occur on the server and not locally
 and therefore the file specified for import/export must be something accessible by the server.
 
 GraphSON and Gryo formats are extensible allowing users and graph providers to extend supported serialization options.


[03/38] tinkerpop git commit: TINKERPOP-1996 Made read()/write() terminator steps

Posted by sp...@apache.org.
TINKERPOP-1996 Made read()/write() terminator steps

Without this approach the with() operator couldn't be used because the traversal would already be iterated on the call to read() and write(). In this way read() and write() are both terminators and modulators at the same time.


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

Branch: refs/heads/master
Commit: 767d65b9d54f1774b13cc5a61db711268f213ff1
Parents: d99909c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jul 11 10:20:39 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:39:29 2018 -0400

----------------------------------------------------------------------
 .../decoration/VertexProgramStrategy.java       |   5 +-
 .../process/traversal/TraversalStrategies.java  |   2 -
 .../traversal/dsl/graph/GraphTraversal.java     |  34 +++++
 .../dsl/graph/GraphTraversalSource.java         |  19 +--
 .../process/traversal/step/ReadWriting.java     |  40 ++++++
 .../gremlin/process/traversal/step/Reading.java |  32 -----
 .../gremlin/process/traversal/step/Writing.java |  32 -----
 .../process/traversal/step/map/IoStep.java      | 135 +++++++++++++++++++
 .../process/traversal/step/map/ReadStep.java    | 113 ----------------
 .../process/traversal/step/map/WriteStep.java   | 111 ---------------
 .../strategy/verification/IoUsageStrategy.java  |  74 ----------
 .../decoration/VertexProgramStrategyTest.java   |   4 +-
 .../verification/IoUsageStrategyTest.java       |  93 -------------
 .../process/traversal/step/map/ReadTest.java    |   8 +-
 .../traversal/step/map/HadoopIoStep.java        | 110 +++++++++++++++
 .../traversal/step/map/HadoopReadStep.java      |  82 -----------
 .../traversal/step/map/HadoopWriteStep.java     |  82 -----------
 .../traversal/strategy/HadoopIoStrategy.java    |  30 ++---
 .../structure/TinkerGraphPlayTest.java          |   2 +-
 19 files changed, 343 insertions(+), 665 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
index c83039a..cb99652 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
@@ -34,8 +34,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
-import org.apache.tinkerpop.gremlin.process.traversal.step.Writing;
+import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
@@ -102,7 +101,7 @@ public final class VertexProgramStrategy extends AbstractTraversalStrategy<Trave
 
         // wrap all non-VertexComputing steps into a TraversalVertexProgramStep
         currentStep = traversal.getStartStep();
-        if (!(currentStep instanceof Reading) && !(currentStep instanceof Writing)) {
+        if (!(currentStep instanceof ReadWriting)) {
             while (!(currentStep instanceof EmptyStep)) {
                 final Traversal.Admin<?, ?> computerTraversal = new DefaultTraversal<>();
                 final Step<?, ?> firstLegalOLAPStep = getFirstLegalOLAPStep(currentStep);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
index 66b0236..ef3e841 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
@@ -36,7 +36,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.Path
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.CountStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RepeatUnrollStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.IoUsageStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.StandardVerificationStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
 import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -223,7 +222,6 @@ public interface TraversalStrategies extends Serializable, Cloneable {
                     PathRetractionStrategy.instance(),
                     LazyBarrierStrategy.instance(),
                     ProfileStrategy.instance(),
-                    IoUsageStrategy.instance(),
                     StandardVerificationStrategy.instance());
             GRAPH_CACHE.put(Graph.class, graphStrategies);
             GRAPH_CACHE.put(EmptyGraph.class, new DefaultTraversalStrategies());

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index 210367f..20f8996 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -39,6 +39,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.ByModulating;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Configuring;
 import org.apache.tinkerpop.gremlin.process.traversal.step.FromToModulating;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Mutating;
+import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TimesModulating;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalOptionParent;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchStep;
@@ -2733,6 +2734,38 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
 
     ////
 
+    ///////////////////// IO TERMINATOR STEPS /////////////////////
+
+    /**
+     * This step is technically a step modulator for the the {@link GraphTraversalSource#io(String)} step which
+     * instructs the step to perform a read with its given configuration.
+     *
+     * @return the traversal that has been iterated with the read IO action executed
+     * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#io-step" target="_blank">Reference Documentation - IO Step</a>
+     * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#read-step" target="_blank">Reference Documentation - Read Step</a>
+     * @since 3.4.0
+     */
+    public default GraphTraversal<S,E> read() {
+        this.asAdmin().getBytecode().addStep(Symbols.read);
+        ((ReadWriting) this.asAdmin().getEndStep()).setMode(ReadWriting.Mode.READING);
+        return this.iterate();
+    }
+
+    /**
+     * This step is technically a step modulator for the the {@link GraphTraversalSource#io(String)} step which
+     * instructs the step to perform a write with its given configuration.
+     *
+     * @return the traversal that has been iterated with the write IO action executed
+     * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#io-step" target="_blank">Reference Documentation - IO Step</a>
+     * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#write-step" target="_blank">Reference Documentation - Write Step</a>
+     * @since 3.4.0
+     */
+    public default GraphTraversal<S,E> write() {
+        this.asAdmin().getBytecode().addStep(Symbols.write);
+        ((ReadWriting) this.asAdmin().getEndStep()).setMode(ReadWriting.Mode.WRITING);
+        return this.iterate();
+    }
+
     /**
      * Iterates the traversal presumably for the generation of side-effects.
      */
@@ -2817,6 +2850,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
         public static final String skip = "skip";
         public static final String tail = "tail";
         public static final String coin = "coin";
+        public static final String io = "io";
         public static final String read = "read";
         public static final String write = "write";
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
index 49e012f..aa4995d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
@@ -24,7 +24,6 @@ import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
 import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
 import org.apache.tinkerpop.gremlin.process.remote.traversal.strategy.decoration.RemoteStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
-import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
@@ -32,8 +31,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeStartStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexStartStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.IoStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.RequirementsStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
@@ -43,8 +41,6 @@ import org.apache.tinkerpop.gremlin.structure.Transaction;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
-import java.util.Map;
-import java.util.NoSuchElementException;
 import java.util.Optional;
 import java.util.function.BinaryOperator;
 import java.util.function.Supplier;
@@ -395,18 +391,11 @@ public class GraphTraversalSource implements TraversalSource {
         return traversal.addStep(new GraphStep<>(traversal, Edge.class, true, edgesIds));
     }
 
-    public <S> GraphTraversal<S, S> read(final String file) {
+    public <S> GraphTraversal<S, S> io(final String file) {
         final GraphTraversalSource clone = this.clone();
-        clone.bytecode.addStep(GraphTraversal.Symbols.read, file);
+        clone.bytecode.addStep(GraphTraversal.Symbols.io, file);
         final GraphTraversal.Admin<S,S> traversal = new DefaultGraphTraversal<>(clone);
-        return traversal.addStep(new ReadStep<S>(traversal, file)).iterate();
-    }
-
-    public <S> GraphTraversal<S, S> write(final String file) {
-        final GraphTraversalSource clone = this.clone();
-        clone.bytecode.addStep(GraphTraversal.Symbols.write, file);
-        final GraphTraversal.Admin<S,S> traversal = new DefaultGraphTraversal<>(clone);
-        return traversal.addStep(new WriteStep<S>(traversal, file)).iterate();
+        return traversal.addStep(new IoStep<S>(traversal, file));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ReadWriting.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ReadWriting.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ReadWriting.java
new file mode 100644
index 0000000..18de925
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ReadWriting.java
@@ -0,0 +1,40 @@
+/*
+ * 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.process.traversal.step;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public interface ReadWriting extends Configuring {
+
+    public enum Mode {
+        UNSET,
+        READING,
+        WRITING
+    }
+
+    /**
+     * Get the file location to write to.
+     */
+    public String getFile();
+
+    public void setMode(final Mode mode);
+
+    public Mode getMode();
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java
deleted file mode 100644
index 3f7c714..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.process.traversal.step;
-
-/**
- * An interface for describing steps that will read a graph from some specified location.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public interface Reading extends Configuring {
-
-    /**
-     * Get the file location to read from.
-     */
-    public String getFile();
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java
deleted file mode 100644
index fe56363..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.process.traversal.step;
-
-/**
- * An interface for describing steps that will write a graph to some specified location.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public interface Writing extends Configuring {
-
-    /**
-     * Get the file location to write to.
-     */
-    public String getFile();
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
new file mode 100644
index 0000000..8d22427
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
@@ -0,0 +1,135 @@
+/*
+ * 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.process.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.EmptyTraverser;
+import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+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.StringFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class IoStep<S> extends AbstractStep<S,S> implements ReadWriting {
+    private Parameters parameters = new Parameters();
+    private boolean first = true;
+    private String file;
+    private Mode mode = Mode.UNSET;
+
+    public IoStep(final Traversal.Admin traversal, final String file) {
+        super(traversal);
+
+        if (null == file || file.isEmpty())
+            throw new IllegalArgumentException("file cannot be null or empty");
+
+        this.file = file;
+    }
+
+    @Override
+    public void setMode(final Mode mode) {
+        this.mode = mode;
+    }
+
+    @Override
+    public Mode getMode() {
+        return mode;
+    }
+
+    @Override
+    public String getFile() {
+        return file;
+    }
+
+    @Override
+    public Parameters getParameters() {
+        return this.parameters;
+    }
+
+    @Override
+    public void configure(final Object... keyValues) {
+        this.parameters.set(null, keyValues);
+    }
+
+    @Override
+    protected Traverser.Admin<S> processNextStart() {
+        if (mode == Mode.UNSET) throw new IllegalStateException("IO mode was not set to read() or write()");
+        if (!this.first) throw FastNoSuchElementException.instance();
+
+        this.first = false;
+        final File file = new File(this.file);
+
+        if (mode == Mode.READING) {
+            if (!file.exists()) throw new IllegalStateException(this.file + " does not exist");
+
+            try (final InputStream stream = new FileInputStream(file)) {
+                final Graph graph = (Graph) this.traversal.getGraph().get();
+                GryoReader.build().create().readGraph(stream, graph);
+
+                return EmptyTraverser.instance();
+            } catch (IOException ioe) {
+                throw new IllegalStateException(String.format("Could not read file %s into graph", this.file), ioe);
+            }
+        } else if (mode == Mode.WRITING) {
+            try (final OutputStream stream = new FileOutputStream(file)) {
+                final Graph graph = (Graph) this.traversal.getGraph().get();
+                GryoWriter.build().create().writeGraph(stream, graph);
+
+                return EmptyTraverser.instance();
+            } catch (IOException ioe) {
+                throw new IllegalStateException(String.format("Could not write file %s from graph", this.file), ioe);
+            }
+        } else {
+            throw new IllegalStateException("Invalid ReadWriting.Mode configured in IoStep: " + mode.name());
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        final int hash = super.hashCode() ^ this.parameters.hashCode();
+        return (null != this.file) ? (hash ^ file.hashCode()) : hash;
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this, file, this.parameters);
+    }
+
+    @Override
+    public IoStep clone() {
+        final IoStep clone = (IoStep) super.clone();
+        clone.parameters = this.parameters.clone();
+        clone.file = this.file;
+        clone.mode = this.mode;
+        return clone;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
deleted file mode 100644
index 99f7e66..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.process.traversal.step.map;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator;
-import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
-import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.EmptyTraverser;
-import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Reads data from a file into a {@link Graph}. This step is meant to be used as the first and last step in a
- * traversal.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class ReadStep<S> extends AbstractStep<S,S> implements Reading {
-
-    private Parameters parameters = new Parameters();
-    private boolean first = true;
-    private String file;
-
-    public ReadStep(final Traversal.Admin traversal, final String file) {
-        super(traversal);
-
-        if (null == file || file.isEmpty())
-            throw new IllegalArgumentException("file cannot be null or empty");
-
-        this.file = file;
-    }
-
-    @Override
-    public String getFile() {
-        return file;
-    }
-
-    @Override
-    public Parameters getParameters() {
-        return this.parameters;
-    }
-
-    @Override
-    public void configure(final Object... keyValues) {
-        this.parameters.set(null, keyValues);
-    }
-
-    @Override
-    protected Traverser.Admin<S> processNextStart() {
-        if (!this.first) throw FastNoSuchElementException.instance();
-
-        this.first = false;
-        final File file = new File(this.file);
-        if (!file.exists()) throw new IllegalStateException(this.file + " does not exist");
-
-        try (final InputStream stream = new FileInputStream(file)) {
-            final Graph graph = (Graph) this.traversal.getGraph().get();
-            GryoReader.build().create().readGraph(stream, graph);
-
-            return EmptyTraverser.instance();
-        } catch (IOException ioe) {
-            throw new IllegalStateException(String.format("Could not read file %s into graph", this.file), ioe);
-        }
-    }
-
-    @Override
-    public int hashCode() {
-        final int hash = super.hashCode() ^ this.parameters.hashCode();
-        return (null != this.file) ? (hash ^ file.hashCode()) : hash;
-    }
-
-    @Override
-    public String toString() {
-        return StringFactory.stepString(this, file, this.parameters);
-    }
-
-    @Override
-    public ReadStep clone() {
-        final ReadStep clone = (ReadStep) super.clone();
-        clone.parameters = this.parameters.clone();
-        clone.file = this.file;
-        return clone;
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
deleted file mode 100644
index 20ffec9..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.process.traversal.step.map;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator;
-import org.apache.tinkerpop.gremlin.process.traversal.step.Writing;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
-import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.EmptyTraverser;
-import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Writes data to a file from a {@link Graph}. This step is meant to be used as the first and last step in a
- * traversal.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class WriteStep<S> extends AbstractStep<S,S> implements Writing {
-
-    private Parameters parameters = new Parameters();
-    private boolean first = true;
-    private String file;
-
-    public WriteStep(final Traversal.Admin traversal, final String file) {
-        super(traversal);
-
-        if (null == file || file.isEmpty())
-            throw new IllegalArgumentException("file cannot be null or empty");
-
-        this.file = file;
-    }
-
-    @Override
-    public String getFile() {
-        return file;
-    }
-
-    @Override
-    public Parameters getParameters() {
-        return this.parameters;
-    }
-
-    @Override
-    public void configure(final Object... keyValues) {
-        this.parameters.set(null, keyValues);
-    }
-
-    @Override
-    protected Traverser.Admin<S> processNextStart() {
-        if (!this.first) throw FastNoSuchElementException.instance();
-
-        this.first = false;
-        final File file = new File(this.file);
-        try (final OutputStream stream = new FileOutputStream(file)) {
-            final Graph graph = (Graph) this.traversal.getGraph().get();
-            GryoWriter.build().create().writeGraph(stream, graph);
-
-            return EmptyTraverser.instance();
-        } catch (IOException ioe) {
-            throw new IllegalStateException(String.format("Could not write file %s from graph", this.file), ioe);
-        }
-    }
-
-    @Override
-    public int hashCode() {
-        final int hash = super.hashCode() ^ this.parameters.hashCode();
-        return (null != this.file) ? (hash ^ file.hashCode()) : hash;
-    }
-
-    @Override
-    public String toString() {
-        return StringFactory.stepString(this, file, this.parameters);
-    }
-
-    @Override
-    public WriteStep clone() {
-        final WriteStep clone = (WriteStep) super.clone();
-        clone.parameters = this.parameters.clone();
-        clone.file = this.file;
-        return clone;
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
deleted file mode 100644
index b4a0669..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.process.traversal.strategy.verification;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Step;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteStep;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * {@code IoUsageStrategy} prevents the {@link GraphTraversalSource#read(String)} and
- * {@link GraphTraversalSource#write(String)} steps from being used outside of their intended scope, which is as the
- * first and last step in a traversal. Therefore, it can only be used as {@code g.read('file.gryo')} and
- * {@code g.write('file.gryo')}. As both of these steps take additional configuration, the use of the
- * {@link GraphTraversal#with(String, Object)} is acceptable.
- * <p/>
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @example <pre>
- * g.read('file.kryo').V()            // throws VerificationException
- * g.write('file.kryo').V()           // throws VerificationException
- * </pre>
- */
-public final class IoUsageStrategy extends AbstractTraversalStrategy<TraversalStrategy.VerificationStrategy> implements TraversalStrategy.VerificationStrategy {
-
-    private static final IoUsageStrategy INSTANCE = new IoUsageStrategy();
-
-    private IoUsageStrategy() {
-    }
-
-    @Override
-    public void apply(final Traversal.Admin<?, ?> traversal) {
-        final Step start = traversal.getStartStep();
-        final Step end = traversal.getEndStep();
-        if ((start instanceof ReadStep || start instanceof WriteStep) && end != start) {
-            if ((end instanceof NoneStep && traversal.getSteps().size() > 2)) {
-                throw new VerificationException("The read() or write() steps must be the first and only step in the traversal - they cannot be used with other steps", traversal);
-            }
-        }
-    }
-
-    public static IoUsageStrategy instance() {
-        return INSTANCE;
-    }
-
-    @Override
-    public Set<Class<? extends VerificationStrategy>> applyPrior() {
-        return Collections.singleton(ComputerVerificationStrategy.class);
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
index 71cb22d..972db9a 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
@@ -69,8 +69,8 @@ public class VertexProgramStrategyTest {
         final ComputerResultStep computerResultStep = new ComputerResultStep(EmptyTraversal.instance());
 
         return Arrays.asList(new Traversal[][]{
-                { EmptyGraph.instance().traversal().read("blah.json"), EmptyGraph.instance().traversal().read("blah.json")},
-                { EmptyGraph.instance().traversal().write("blah.json"), EmptyGraph.instance().traversal().write("blah.json")},
+                { EmptyGraph.instance().traversal().io("blah.json").read(), EmptyGraph.instance().traversal().io("blah.json").read()},
+                { EmptyGraph.instance().traversal().io("blah.json").write(), EmptyGraph.instance().traversal().io("blah.json").write()},
                 {__.V().out().count(), start().addStep(traversal(__.V().out().count())).addStep(computerResultStep)},
                 {__.V().pageRank().out().count(), start().pageRank().asAdmin().addStep(traversal(__.V().out().count())).addStep(computerResultStep)},
                 {__.V().out().pageRank(), start().addStep(traversal(__.V().out())).pageRank().asAdmin().addStep(traversal(__.identity())).addStep(computerResultStep)},

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategyTest.java
deleted file mode 100644
index 907e2b7..0000000
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategyTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.process.traversal.strategy.verification;
-
-import org.apache.tinkerpop.gremlin.TestHelper;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
-import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-@RunWith(Parameterized.class)
-public class IoUsageStrategyTest {
-
-    private static final GraphTraversalSource g = EmptyGraph.instance().traversal();
-
-    private static File junkFile;
-
-    static {
-        try {
-            junkFile = TestHelper.generateTempFile(IoUsageStrategyTest.class, "fake", "kryo");
-        } catch (IOException ioe) {
-            throw new RuntimeException(ioe);
-        }
-    }
-
-    @Parameterized.Parameters(name = "{0}")
-    public static Iterable<Object[]> data() {
-        return Arrays.asList(new Object[][]{
-                {"g.read('a.kryo')", g.read(junkFile.getAbsolutePath()), true},
-                {"g.write('a.kryo')", g.write(junkFile.getAbsolutePath()), true},
-                {"g.read('a.kryo').with(\"x\", \"y\")", g.read(junkFile.getAbsolutePath()).with("x", "y"), true},
-                {"g.write('a.kryo').with(\"x\", \"y\")", g.write(junkFile.getAbsolutePath()).with("x", "y"), true},
-                {"g.read('a.kryo').V()", g.read(junkFile.getAbsolutePath()).V(), false},
-                {"g.write('a.kryo').V()", g.write(junkFile.getAbsolutePath()).V(), false}
-        });
-    }
-
-    @Parameterized.Parameter(value = 0)
-    public String name;
-
-    @Parameterized.Parameter(value = 1)
-    public Traversal traversal;
-
-    @Parameterized.Parameter(value = 2)
-    public boolean allow;
-
-    @Test
-    public void shouldBeVerified() {
-        final TraversalStrategies strategies = new DefaultTraversalStrategies();
-        strategies.addStrategies(IoUsageStrategy.instance());
-        traversal.asAdmin().setStrategies(strategies);
-        if (allow) {
-            traversal.asAdmin().applyStrategies();
-        } else {
-            try {
-                traversal.asAdmin().applyStrategies();
-                fail("The strategy should not allow read()/write() to be used with other steps: " + this.traversal);
-            } catch (VerificationException ise) {
-                assertTrue(ise.getMessage().contains("read() or write() steps"));
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
index 2cfc3f7..6b7b67e 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
@@ -43,11 +43,11 @@ import static org.junit.Assert.assertTrue;
 @RunWith(GremlinProcessRunner.class)
 public abstract class ReadTest extends AbstractGremlinProcessTest {
 
-    public abstract Traversal<Map<String,Object>, Map<String,Object>> get_g_read()  throws IOException;
+    public abstract Traversal<Object,Object> get_g_io_read()  throws IOException;
 
     @Test
     public void g_read() throws IOException {
-        final Traversal<Map<String,Object>, Map<String,Object>> traversal = get_g_read();
+        final Traversal<Object,Object> traversal = get_g_io_read();
         printTraversalForm(traversal);
         assertTrue(traversal.hasNext());
 
@@ -56,9 +56,9 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
 
     public static class Traversals extends ReadTest {
         @Override
-        public Traversal<Map<String,Object>, Map<String,Object>> get_g_read() throws IOException {
+        public Traversal<Object,Object> get_g_io_read() throws IOException {
             final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GryoResourceAccess.class, "tinkerpop-modern-v3d0.kryo", "").getAbsolutePath().replace('\\', '/');
-            return g.read(fileToRead);
+            return g.io(fileToRead).read();
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
new file mode 100644
index 0000000..83a95e0
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
@@ -0,0 +1,110 @@
+/*
+ * 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.process.computer.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.hadoop.Constants;
+import org.apache.tinkerpop.gremlin.process.computer.GraphFilter;
+import org.apache.tinkerpop.gremlin.process.computer.Memory;
+import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class HadoopIoStep extends VertexProgramStep implements ReadWriting {
+
+    private Parameters parameters = new Parameters();
+    private Mode mode = Mode.UNSET;
+    private String file;
+
+    public HadoopIoStep(final Traversal.Admin traversal, final String file) {
+        super(traversal);
+        this.file = file;
+    }
+
+    @Override
+    public void setMode(final Mode mode) {
+        this.mode = mode;
+    }
+
+    @Override
+    public Mode getMode() {
+        return mode;
+    }
+
+    @Override
+    public String getFile() {
+        return file;
+    }
+
+    @Override
+    public void configure(final Object... keyValues) {
+        // TODO: probably should write to the Configuration selectively - no need for actual Parameters?????????
+        this.parameters.set(null, keyValues);
+    }
+
+    @Override
+    public Parameters getParameters() {
+        return parameters;
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this, new GraphFilter(this.computer));
+    }
+
+    @Override
+    public CloneVertexProgram generateProgram(final Graph graph, final Memory memory) {
+        if (mode == Mode.UNSET)
+            throw new IllegalStateException("IO mode was not set to read() or write()");
+        else if (mode == Mode.READING)
+            configureForRead(graph);
+        else if (mode == Mode.WRITING)
+            configureForWrite(graph);
+        else
+            throw new IllegalStateException("Invalid ReadWriting.Mode configured in IoStep: " + mode.name());
+
+        return CloneVertexProgram.build().create(graph);
+    }
+
+    @Override
+    public HadoopIoStep clone() {
+        return (HadoopIoStep) super.clone();
+    }
+
+    @Override
+    public int hashCode() {
+        return super.hashCode();
+    }
+
+    private void configureForRead(final Graph graph) {
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, "org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat");
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, file);
+    }
+
+    private void configureForWrite(final Graph graph) {
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, "org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoOutputFormat");
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, file);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java
deleted file mode 100644
index 1ec3d38..0000000
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.process.computer.traversal.step.map;
-
-import org.apache.tinkerpop.gremlin.hadoop.Constants;
-import org.apache.tinkerpop.gremlin.process.computer.GraphFilter;
-import org.apache.tinkerpop.gremlin.process.computer.Memory;
-import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class HadoopReadStep extends VertexProgramStep implements Reading {
-
-    private Parameters parameters = new Parameters();
-
-    public HadoopReadStep(final Traversal.Admin traversal, final String localFile) {
-        super(traversal);
-
-        final Graph graph = (Graph) traversal.getGraph().get();
-        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, "org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat");
-        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, localFile);
-    }
-
-    @Override
-    public String getFile() {
-        return (String) ((Graph) traversal.getGraph().get()).configuration().getProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION);
-    }
-
-    @Override
-    public void configure(final Object... keyValues) {
-        // TODO: probably should write to the Configuration selectively - no need for actual Parameters?????????
-        this.parameters.set(null, keyValues);
-    }
-
-    @Override
-    public Parameters getParameters() {
-        return parameters;
-    }
-
-    @Override
-    public String toString() {
-        return StringFactory.stepString(this, new GraphFilter(this.computer));
-    }
-
-    @Override
-    public CloneVertexProgram generateProgram(final Graph graph, final Memory memory) {
-        return CloneVertexProgram.build().create(graph);
-    }
-
-    @Override
-    public HadoopReadStep clone() {
-        return (HadoopReadStep) super.clone();
-    }
-
-    @Override
-    public int hashCode() {
-        return super.hashCode();
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java
deleted file mode 100644
index 2bb8e67..0000000
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.process.computer.traversal.step.map;
-
-import org.apache.tinkerpop.gremlin.hadoop.Constants;
-import org.apache.tinkerpop.gremlin.process.computer.GraphFilter;
-import org.apache.tinkerpop.gremlin.process.computer.Memory;
-import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class HadoopWriteStep extends VertexProgramStep implements Reading {
-
-    private Parameters parameters = new Parameters();
-
-    public HadoopWriteStep(final Traversal.Admin traversal, final String localFile) {
-        super(traversal);
-
-        final Graph graph = (Graph) traversal.getGraph().get();
-        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, "org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoOutputFormat");
-        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, localFile);
-    }
-
-    @Override
-    public String getFile() {
-        return (String) ((Graph) traversal.getGraph().get()).configuration().getProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION);
-    }
-
-    @Override
-    public void configure(final Object... keyValues) {
-        // TODO: probably should write to the Configuration selectively - no need for actual Parameters?????????
-        this.parameters.set(null, keyValues);
-    }
-
-    @Override
-    public Parameters getParameters() {
-        return parameters;
-    }
-
-    @Override
-    public String toString() {
-        return StringFactory.stepString(this, new GraphFilter(this.computer));
-    }
-
-    @Override
-    public CloneVertexProgram generateProgram(final Graph graph, final Memory memory) {
-        return CloneVertexProgram.build().create(graph);
-    }
-
-    @Override
-    public HadoopWriteStep clone() {
-        return (HadoopWriteStep) super.clone();
-    }
-
-    @Override
-    public int hashCode() {
-        return super.hashCode();
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
index 7e0e23c..1805df8 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
@@ -19,14 +19,13 @@
 
 package org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.strategy;
 
-import org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.step.map.HadoopReadStep;
-import org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.step.map.HadoopWriteStep;
+import org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.step.map.HadoopIoStep;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
-import org.apache.tinkerpop.gremlin.process.traversal.step.Writing;
+import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.IoStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 
@@ -43,23 +42,16 @@ public final class HadoopIoStrategy extends AbstractTraversalStrategy<TraversalS
 
     @Override
     public void apply(final Traversal.Admin<?, ?> traversal) {
-        // replace Reading and Writing steps with hadoop specific ones
-        if (traversal.getStartStep() instanceof Reading) {
-            final Reading reading = (Reading) traversal.getStartStep();
-            final HadoopReadStep hadoopReadStep = new HadoopReadStep(traversal, reading.getFile());
-            reading.getParameters().getRaw().entrySet().forEach(kv ->
-                hadoopReadStep.configure(null, kv.getKey(), kv.getValue())
+        // replace IoStep steps with hadoop specific one
+        if (traversal.getStartStep() instanceof IoStep) {
+            final ReadWriting readWriting = (ReadWriting) traversal.getStartStep();
+            final HadoopIoStep hadoopIoStep = new HadoopIoStep(traversal, readWriting.getFile());
+            hadoopIoStep.setMode(readWriting.getMode());
+            readWriting.getParameters().getRaw().entrySet().forEach(kv ->
+                    hadoopIoStep.configure(null, kv.getKey(), kv.getValue())
             );
 
-            TraversalHelper.replaceStep((Step) reading, hadoopReadStep, traversal);
-        } else if (traversal.getStartStep() instanceof Writing) {
-            final Writing writing = (Writing) traversal.getStartStep();
-            final HadoopWriteStep hadoopWriteStep = new HadoopWriteStep(traversal, writing.getFile());
-            writing.getParameters().getRaw().entrySet().forEach(kv ->
-                hadoopWriteStep.configure(null, kv.getKey(), kv.getValue())
-            );
-
-            TraversalHelper.replaceStep((Step) writing, hadoopWriteStep, traversal);
+            TraversalHelper.replaceStep((Step) readWriting, hadoopIoStep, traversal);
         }
 
         if (traversal.getEndStep() instanceof NoneStep)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/767d65b9/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
index 82bf2d7..69062ef 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
@@ -340,7 +340,7 @@ public class TinkerGraphPlayTest {
     public void testBlah() {
         TinkerGraph graph = TinkerGraph.open();
         GraphTraversalSource g = graph.traversal();
-        g.read("../data/tinkerpop-modern.kryo");
+        g.io("../data/tinkerpop-modern.kryo").read();
 
         IoTest.assertModernGraph(graph, true, false);
     }


[08/38] tinkerpop git commit: TINKERPOP-1996 none() doesn't need to be removed in HadoopIoStrategy

Posted by sp...@apache.org.
TINKERPOP-1996 none() doesn't need to be removed in HadoopIoStrategy

Not sure why this was there in the first place. Removing it not allows Hadoop integration tests to pass, but seems to have no real effect on existing operations.


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

Branch: refs/heads/master
Commit: be9db8de6a9d2abb5222b7ab5b9326049060e85a
Parents: 13e552b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jul 12 08:17:56 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:39:30 2018 -0400

----------------------------------------------------------------------
 .../process/computer/traversal/strategy/HadoopIoStrategy.java     | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/be9db8de/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
index 38d5a7f..89ee04b 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
@@ -60,9 +60,6 @@ public final class HadoopIoStrategy extends AbstractTraversalStrategy<TraversalS
 
             TraversalHelper.replaceStep((Step) readWriting, hadoopIoStep, traversal);
         }
-
-        if (traversal.getEndStep() instanceof NoneStep)
-            traversal.removeStep(1);
     }
 
     public static HadoopIoStrategy instance() {


[18/38] tinkerpop git commit: TINKERPOP-1996 Added support/testing for io() in GLVs

Posted by sp...@apache.org.
TINKERPOP-1996 Added support/testing for io() in GLVs

Had to revert to using iterate() and stop read/write() from terminating the traversal. Kinda stinks, but we rely on iterate() quite heavily and for remoting allowing read()/write() to terminate means that the traversal will execute during traversal construction in the translator (which is early and potentially bad).


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

Branch: refs/heads/master
Commit: 048ea21c0adf9297233d06222e75c64dbe1fa1ca
Parents: f8e3b8a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jul 19 13:30:02 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:41:01 2018 -0400

----------------------------------------------------------------------
 .../traversal/dsl/graph/GraphTraversal.java     | 11 +--
 gremlin-dotnet/glv/IO.template                  | 46 +++++++++++
 gremlin-dotnet/glv/generate.groovy              |  8 ++
 .../src/Gremlin.Net/Process/Traversal/IO.cs     | 54 +++++++++++++
 .../Gherkin/TraversalEvaluation/IOParameter.cs  | 82 +++++++++++++++++++
 .../TraversalEvaluation/TraversalParser.cs      |  7 ++
 gremlin-javascript/glv/TraversalSource.template |  9 +++
 gremlin-javascript/glv/generate.groovy          |  4 +
 .../gremlin-javascript/lib/process/traversal.js | 25 ++++++
 .../test/cucumber/feature-steps.js              |  2 +
 gremlin-python/glv/TraversalSource.template     | 11 +++
 gremlin-python/glv/generate.groovy              |  4 +
 .../jython/gremlin_python/process/traversal.py  | 19 +++++
 .../src/main/jython/radish/feature_steps.py     |  5 +-
 gremlin-test/features/sideEffect/Read.feature   | 84 ++++++++++++++++++++
 gremlin-test/features/sideEffect/Write.feature  | 60 ++++++++++++++
 .../gremlin/AbstractGraphProvider.java          |  2 +-
 .../process/traversal/step/map/ReadTest.java    | 57 ++++++++++---
 18 files changed, 471 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index 20f8996..a675ad1 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@ -124,6 +124,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCount
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupSideEffectStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IoStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.LambdaSideEffectStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SackValueStep;
@@ -2734,13 +2735,13 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
 
     ////
 
-    ///////////////////// IO TERMINATOR STEPS /////////////////////
+    ///////////////////// IO STEPS /////////////////////
 
     /**
      * This step is technically a step modulator for the the {@link GraphTraversalSource#io(String)} step which
      * instructs the step to perform a read with its given configuration.
      *
-     * @return the traversal that has been iterated with the read IO action executed
+     * @return the traversal with the {@link IoStep} modulated to read
      * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#io-step" target="_blank">Reference Documentation - IO Step</a>
      * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#read-step" target="_blank">Reference Documentation - Read Step</a>
      * @since 3.4.0
@@ -2748,14 +2749,14 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
     public default GraphTraversal<S,E> read() {
         this.asAdmin().getBytecode().addStep(Symbols.read);
         ((ReadWriting) this.asAdmin().getEndStep()).setMode(ReadWriting.Mode.READING);
-        return this.iterate();
+        return this;
     }
 
     /**
      * This step is technically a step modulator for the the {@link GraphTraversalSource#io(String)} step which
      * instructs the step to perform a write with its given configuration.
      *
-     * @return the traversal that has been iterated with the write IO action executed
+     * @return the traversal with the {@link IoStep} modulated to write
      * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#io-step" target="_blank">Reference Documentation - IO Step</a>
      * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#write-step" target="_blank">Reference Documentation - Write Step</a>
      * @since 3.4.0
@@ -2763,7 +2764,7 @@ public interface GraphTraversal<S, E> extends Traversal<S, E> {
     public default GraphTraversal<S,E> write() {
         this.asAdmin().getBytecode().addStep(Symbols.write);
         ((ReadWriting) this.asAdmin().getEndStep()).setMode(ReadWriting.Mode.WRITING);
-        return this.iterate();
+        return this;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-dotnet/glv/IO.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/IO.template b/gremlin-dotnet/glv/IO.template
new file mode 100644
index 0000000..7b25c88
--- /dev/null
+++ b/gremlin-dotnet/glv/IO.template
@@ -0,0 +1,46 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace Gremlin.Net.Process.Traversal
+{
+#pragma warning disable 1591
+
+    /// <summary>
+    ///     <see cref="IO" /> keeps configuration options for the io() step.
+    /// </summary>
+    public class IO
+    {
+        <% io.each {k,v -> %>
+            public const String <%= k %> = "<%= v %>";
+        <% } %>
+    }
+
+#pragma warning restore 1591
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index bd2d9d7..58a5026 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
 import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.process.traversal.IO
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
 import org.apache.tinkerpop.gremlin.structure.Direction
 import java.lang.reflect.Modifier
@@ -303,6 +304,9 @@ def binding = ["pmethods": P.class.getMethods().
                             def graphTraversalT2 = getGraphTraversalT2ForT2(t2)
                             return ["methodName": javaMethod.name, "t2":t2, "tParam":tParam, "parameters":parameters, "paramNames":paramNames, "callGenericTypeArg":callGenericTypeArg, "graphTraversalT2":graphTraversalT2]
                         },
+               "io": IO.class.getFields().
+                       sort{ a, b -> a.name <=> b.name }.
+                       collectEntries{ f -> [(f.name) : f.get(null)]},
                "toCSharpMethodName": toCSharpMethodName]
 
 def engine = new groovy.text.GStringTemplateEngine()
@@ -322,6 +326,10 @@ def pTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/P.template
 def pFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/P.cs")
 pFile.newWriter().withWriter{ it << pTemplate }
 
+def ioTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/IO.template")).make(binding)
+def ioFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/IO.cs")
+ioFile.newWriter().withWriter{ it << ioTemplate }
+
 
 def createEnum = { enumClass ->
     def b = ["enumClass": enumClass,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
new file mode 100644
index 0000000..288f7e3
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
@@ -0,0 +1,54 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace Gremlin.Net.Process.Traversal
+{
+#pragma warning disable 1591
+
+    /// <summary>
+    ///     <see cref="IO" /> keeps configuration options for the io() step.
+    /// </summary>
+    public class IO
+    {
+        
+            public const String graphml = "graphml";
+        
+            public const String graphson = "graphson";
+        
+            public const String gryo = "gryo";
+        
+            public const String reader = "~tinkerpop.io.reader";
+        
+            public const String writer = "~tinkerpop.io.writer";
+        
+    }
+
+#pragma warning restore 1591
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/IOParameter.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/IOParameter.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/IOParameter.cs
new file mode 100644
index 0000000..513e589
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/IOParameter.cs
@@ -0,0 +1,82 @@
+#region License
+
+/*
+ * 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.
+ */
+
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Dynamic;
+using System.Linq;
+using System.Reflection;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
+{
+    /// <summary>
+    /// Represents a parameter for the io() step - (e.g. IO.graphml)
+    /// </summary>
+    internal class IOParameter : ITokenParameter, IEquatable<IOParameter>
+    {
+        private readonly string _text;
+        private readonly string _value;
+        
+        public IOParameter(string text)
+        {
+            _text = text;
+            var separatorIndex = text.IndexOf('.');
+            _value = text.Substring(separatorIndex + 1);
+        }
+
+        public bool Equals(IOParameter other)
+        {
+            return _text == other._text;
+        }
+
+        public override bool Equals(object obj)
+        {
+            if (ReferenceEquals(null, obj)) return false;
+            if (ReferenceEquals(this, obj)) return true;
+            if (obj.GetType() != GetType()) return false;
+            return Equals((IOParameter) obj);
+        }
+
+        public override int GetHashCode()
+        {
+            return _text.GetHashCode();
+        }
+
+        public object GetValue()
+        {
+            var field = typeof(IO).GetField(_value, BindingFlags.Static | BindingFlags.Public);
+            return field.GetValue(null);
+        }
+
+        public void SetContextParameterValues(IDictionary<string, object> parameterValues)
+        {
+
+        }
+
+        public Type GetParameterType()
+        {
+            return typeof(String);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
index e3f6a3f..f8e4095 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/TraversalEvaluation/TraversalParser.cs
@@ -44,6 +44,8 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
 
         private static readonly Regex RegexEnum = new Regex(@"\w+\.\w+", RegexOptions.Compiled);
 
+        private static readonly Regex RegexIO = new Regex(@"IO.\w+", RegexOptions.Compiled);
+
         private static readonly Regex RegexParam = new Regex(@"\w+", RegexOptions.Compiled);
         
         private static readonly HashSet<Type> NumericTypes = new HashSet<Type>
@@ -424,6 +426,11 @@ namespace Gremlin.Net.IntegrationTest.Gherkin.TraversalEvaluation
                 i += parameterText.Length - 1;
                 return LiteralParameter.Create(Convert.ToBoolean(parameterText));
             }
+            if (RegexIO.IsMatch(parameterText))
+            {
+                i += parameterText.Length - 1;
+                return new IOParameter(parameterText);
+            }
             if (RegexEnum.IsMatch(parameterText))
             {
                 i += parameterText.Length - 1;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index 6965110..321956c 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -111,6 +111,14 @@ class Traversal {
   };
 }
 
+class IO {
+<% io.each {k,v -> %>
+    static get <%= k %>() {
+        return "<%= v %>"
+    }
+<% } %>
+}
+
 class P {
   /**
    * Represents an operation.
@@ -190,6 +198,7 @@ class EnumValue {
 module.exports = {
   EnumValue,
   P,
+  IO,
   Traversal,
   TraversalSideEffects,
   Traverser<%

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-javascript/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/generate.groovy b/gremlin-javascript/glv/generate.groovy
index 8778e89..a339689 100644
--- a/gremlin-javascript/glv/generate.groovy
+++ b/gremlin-javascript/glv/generate.groovy
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
 import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.process.traversal.IO
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
 import java.lang.reflect.Modifier
 
@@ -88,6 +89,9 @@ def binding = ["enums": CoreImports.getClassImports()
                        collect { it.name }.
                        unique().
                        sort { a, b -> a <=> b },
+               "io": IO.class.getFields().
+                       sort{ a, b -> a.name <=> b.name }.
+                       collectEntries{ f -> [(f.name) : f.get(null)]},
                "toJs": toJs,
                "version": determineVersion(),
                "decapitalize": decapitalize]

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index d39ccf0..3f69fb1 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -111,6 +111,30 @@ class Traversal {
   };
 }
 
+class IO {
+
+    static get graphml() {
+        return "graphml"
+    }
+
+    static get graphson() {
+        return "graphson"
+    }
+
+    static get gryo() {
+        return "gryo"
+    }
+
+    static get reader() {
+        return "~tinkerpop.io.reader"
+    }
+
+    static get writer() {
+        return "~tinkerpop.io.writer"
+    }
+
+}
+
 class P {
   /**
    * Represents an operation.
@@ -250,6 +274,7 @@ class EnumValue {
 module.exports = {
   EnumValue,
   P,
+  IO,
   Traversal,
   TraversalSideEffects,
   Traverser,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 16aae78..320d3f4 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -187,6 +187,7 @@ function getSandbox(g, parameters) {
     },
     Order: traversalModule.order,
     P: traversalModule.P,
+    IO: traversalModule.IO,
     Pick: traversalModule.pick,
     Pop: traversalModule.pop,
     Scope: traversalModule.scope,
@@ -207,6 +208,7 @@ function translate(traversalText) {
   // Change according to naming convention
   traversalText = traversalText.replace(/\.in\(/g, '.in_(');
   traversalText = traversalText.replace(/\.from\(/g, '.from_(');
+  traversalText = traversalText.replace(/\.with\(/g, '.with_(');
   return traversalText;
 }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-python/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-python/glv/TraversalSource.template b/gremlin-python/glv/TraversalSource.template
index b6f5b9f..3ca2786 100644
--- a/gremlin-python/glv/TraversalSource.template
+++ b/gremlin-python/glv/TraversalSource.template
@@ -135,6 +135,17 @@ statics.add_static('<%= method %>',<%= method %>)
 <% } %>
 
 '''
+IO
+'''
+
+
+class IO(object):
+<% io.each {k,v -> %>
+    <%= k %> = "<%= v %>"
+<% } %>
+
+
+'''
 TRAVERSER
 '''
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-python/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/glv/generate.groovy b/gremlin-python/glv/generate.groovy
index 57cc9c9..f810e10 100644
--- a/gremlin-python/glv/generate.groovy
+++ b/gremlin-python/glv/generate.groovy
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
 import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.process.traversal.IO
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
 import java.lang.reflect.Modifier
 // this is a bit of a copy of what's in SymbolHelper - no way around it because this code generation task occurs
@@ -78,6 +79,9 @@ def binding = ["enums": CoreImports.getClassImports()
                        collect { toPython(it.name) }.
                        unique().
                        sort { a, b -> a <=> b },
+               "io": IO.class.getFields().
+                       sort{ a, b -> a.name <=> b.name }.
+                       collectEntries{ f -> [(f.name) : f.get(null)]},
                "toPython": toPython,
                "toJava": toJava]
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
index 068c865..d9fb4d9 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
@@ -305,6 +305,25 @@ statics.add_static('without',without)
 
 
 '''
+IO
+'''
+
+
+class IO(object):
+
+    graphml = "graphml"
+
+    graphson = "graphson"
+
+    gryo = "gryo"
+
+    reader = "~tinkerpop.io.reader"
+
+    writer = "~tinkerpop.io.writer"
+
+
+
+'''
 TRAVERSER
 '''
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 5067d1b..99022a0 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -21,7 +21,7 @@ import json
 import re
 from gremlin_python.structure.graph import Graph, Path
 from gremlin_python.process.graph_traversal import __
-from gremlin_python.process.traversal import Barrier, Cardinality, P, Pop, Scope, Column, Order, Direction, T, Pick, Operator
+from gremlin_python.process.traversal import Barrier, Cardinality, P, Pop, Scope, Column, Order, Direction, T, Pick, Operator, IO
 from radish import given, when, then
 from hamcrest import *
 
@@ -34,6 +34,7 @@ regex_in = re.compile(r"([(.,\s])in\(")
 regex_is = re.compile(r"([(.,\s])is\(")
 regex_not = re.compile(r"([(.,\s])not\(")
 regex_or = re.compile(r"([(.,\s])or\(")
+regex_with = re.compile(r"([(.,\s])with\(")
 regex_true = re.compile(r"(true)")
 regex_false = re.compile(r"(false)")
 
@@ -241,6 +242,7 @@ def _translate(traversal):
     replaced = regex_not.sub(r"\1not_(", replaced)
     replaced = regex_or.sub(r"\1or_(", replaced)
     replaced = regex_in.sub(r"\1in_(", replaced)
+    replaced = regex_with.sub(r"\1with_(", replaced)
     replaced = regex_true.sub(r"True", replaced)
     return regex_false.sub(r"False", replaced)
 
@@ -254,6 +256,7 @@ def _make_traversal(g, traversal_string, params):
          "Direction": Direction,
          "Order": Order,
          "P": P,
+         "IO": IO,
          "Pick": Pick,
          "Pop": Pop,
          "Scope": Scope,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-test/features/sideEffect/Read.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/sideEffect/Read.feature b/gremlin-test/features/sideEffect/Read.feature
new file mode 100644
index 0000000..ae96102
--- /dev/null
+++ b/gremlin-test/features/sideEffect/Read.feature
@@ -0,0 +1,84 @@
+# 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.
+
+Feature: Step - read()
+
+  Scenario: g_io_readXkryoX
+    Given the empty graph
+    And the traversal of
+      """
+      g.io("data/tinkerpop-modern.kryo").read()
+      """
+    When iterated to list
+    Then the result should be empty
+    And the graph should return 6 for count of "g.V()"
+    And the graph should return 6 for count of "g.E()"
+
+  Scenario: g_io_read_withXreader_gryoX
+    Given the empty graph
+    And the traversal of
+      """
+      g.io("data/tinkerpop-modern.kryo").with(IO.reader, IO.gryo).read()
+      """
+    When iterated to list
+    Then the result should be empty
+    And the graph should return 6 for count of "g.V()"
+    And the graph should return 6 for count of "g.E()"
+
+  Scenario: g_io_readXgraphsonX
+    Given the empty graph
+    And the traversal of
+      """
+      g.io("data/tinkerpop-modern.json").read()
+      """
+    When iterated to list
+    Then the result should be empty
+    And the graph should return 6 for count of "g.V()"
+    And the graph should return 6 for count of "g.E()"
+
+  Scenario: g_io_read_withXreader_graphsonX
+    Given the empty graph
+    And the traversal of
+      """
+      g.io("data/tinkerpop-modern.json").with(IO.reader, IO.graphson).read()
+      """
+    When iterated to list
+    Then the result should be empty
+    And the graph should return 6 for count of "g.V()"
+    And the graph should return 6 for count of "g.E()"
+
+  Scenario: g_io_readXgraphmlX
+    Given the empty graph
+    And the traversal of
+      """
+      g.io("data/tinkerpop-modern.xml").read()
+      """
+    When iterated to list
+    Then the result should be empty
+    And the graph should return 6 for count of "g.V()"
+    And the graph should return 6 for count of "g.E()"
+
+  Scenario: g_io_read_withXreader_graphmlX
+    Given the empty graph
+    And the traversal of
+      """
+      g.io("data/tinkerpop-modern.xml").with(IO.reader, IO.graphml).read()
+      """
+    When iterated to list
+    Then the result should be empty
+    And the graph should return 6 for count of "g.V()"
+    And the graph should return 6 for count of "g.E()"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-test/features/sideEffect/Write.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/sideEffect/Write.feature b/gremlin-test/features/sideEffect/Write.feature
new file mode 100644
index 0000000..9a774e8
--- /dev/null
+++ b/gremlin-test/features/sideEffect/Write.feature
@@ -0,0 +1,60 @@
+# 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.
+
+Feature: Step - write()
+
+  Scenario: g_io_writeXkryoX
+    Given an unsupported test
+    Then nothing should happen because
+      """
+      We don't have a nice way to assert the remotely written file with this framework - just testing compilation.
+      """
+
+  Scenario: g_io_write_withXwriter_gryoX
+    Given an unsupported test
+    Then nothing should happen because
+      """
+      We don't have a nice way to assert the remotely written file with this framework - just testing compilation.
+      """
+
+  Scenario: g_io_writeXgraphsonX
+    Given an unsupported test
+    Then nothing should happen because
+      """
+      We don't have a nice way to assert the remotely written file with this framework - just testing compilation.
+      """
+
+  Scenario: g_io_write_withXwriter_graphsonX
+    Given an unsupported test
+    Then nothing should happen because
+      """
+      We don't have a nice way to assert the remotely written file with this framework - just testing compilation.
+      """
+
+  Scenario: g_io_writeXgraphmlX
+    Given an unsupported test
+    Then nothing should happen because
+      """
+      We don't have a nice way to assert the remotely written file with this framework - just testing compilation.
+      """
+
+  Scenario: g_io_write_withXwriter_graphmlX
+    Given an unsupported test
+    Then nothing should happen because
+      """
+      We don't have a nice way to assert the remotely written file with this framework - just testing compilation.
+      """
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
index b6fc43c..9774411 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
@@ -145,6 +145,6 @@ public abstract class AbstractGraphProvider implements GraphProvider {
     protected void readIntoGraph(final Graph graph, final String path) throws IOException {
         final String dataFile = TestHelper.generateTempFileFromResource(graph.getClass(),
                 GryoResourceAccess.class, path.substring(path.lastIndexOf(File.separator) + 1), "", false).getAbsolutePath();
-        graph.traversal().io(dataFile).read();
+        graph.traversal().io(dataFile).read().iterate();
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/048ea21c/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
index ab59194..24bacbb 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
@@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
 import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
 import org.apache.tinkerpop.gremlin.process.traversal.IO;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -34,8 +35,10 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import java.io.IOException;
+import java.util.function.Supplier;
 
 import static org.apache.tinkerpop.gremlin.structure.Graph.Features.GraphFeatures.FEATURE_IO_READ;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 
 /**
@@ -62,9 +65,14 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GryoResourceAccess.class, "tinkerpop-modern-v3d0.kryo", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_readXkryoX(fileToRead);
         printTraversalForm(traversal);
-        assertFalse(traversal.hasNext());
+        traversal.iterate();
 
-        IoTest.assertModernGraph(graph, false, true);
+        if (graph instanceof RemoteGraph) {
+            assertEquals(6L, g.V().count().next().longValue());
+            assertEquals(6L, g.E().count().next().longValue());
+        } else {
+            IoTest.assertModernGraph(graph, false, true);
+        }
     }
 
     @Test
@@ -73,9 +81,14 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GryoResourceAccess.class, "tinkerpop-modern-v3d0.kryo", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_read_withXreader_gryoX(fileToRead);
         printTraversalForm(traversal);
-        assertFalse(traversal.hasNext());
+        traversal.iterate();
 
-        IoTest.assertModernGraph(graph, false, true);
+        if (graph instanceof RemoteGraph) {
+            assertEquals(6L, g.V().count().next().longValue());
+            assertEquals(6L, g.E().count().next().longValue());
+        } else {
+            IoTest.assertModernGraph(graph, false, true);
+        }
     }
 
     @Test
@@ -84,9 +97,14 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphSONResourceAccess.class, "tinkerpop-modern-v3d0.json", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_readXjsonX(fileToRead);
         printTraversalForm(traversal);
-        assertFalse(traversal.hasNext());
+        traversal.iterate();
 
-        IoTest.assertModernGraph(graph, false, true);
+        if (graph instanceof RemoteGraph) {
+            assertEquals(6L, g.V().count().next().longValue());
+            assertEquals(6L, g.E().count().next().longValue());
+        } else {
+            IoTest.assertModernGraph(graph, false, true);
+        }
     }
 
     @Test
@@ -95,9 +113,14 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphSONResourceAccess.class, "tinkerpop-modern-v3d0.json", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_read_withXreader_graphsonX(fileToRead);
         printTraversalForm(traversal);
-        assertFalse(traversal.hasNext());
+        traversal.iterate();
 
-        IoTest.assertModernGraph(graph, false, true);
+        if (graph instanceof RemoteGraph) {
+            assertEquals(6L, g.V().count().next().longValue());
+            assertEquals(6L, g.E().count().next().longValue());
+        } else {
+            IoTest.assertModernGraph(graph, false, true);
+        }
     }
 
     @Test
@@ -106,9 +129,14 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphMLResourceAccess.class, "tinkerpop-modern.xml", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_readXxmlX(fileToRead);
         printTraversalForm(traversal);
-        assertFalse(traversal.hasNext());
+        traversal.iterate();
 
-        IoTest.assertModernGraph(graph, false, true);
+        if (graph instanceof RemoteGraph) {
+            assertEquals(6L, g.V().count().next().longValue());
+            assertEquals(6L, g.E().count().next().longValue());
+        } else {
+            IoTest.assertModernGraph(graph, false, true);
+        }
     }
 
     @Test
@@ -117,9 +145,14 @@ public abstract class ReadTest extends AbstractGremlinProcessTest {
         final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphMLResourceAccess.class, "tinkerpop-modern.xml", "").getAbsolutePath().replace('\\', '/');
         final Traversal<Object,Object> traversal = get_g_io_read_withXreader_graphmlX(fileToRead);
         printTraversalForm(traversal);
-        assertFalse(traversal.hasNext());
+        traversal.iterate();
 
-        IoTest.assertModernGraph(graph, false, true);
+        if (graph instanceof RemoteGraph) {
+            assertEquals(6L, g.V().count().next().longValue());
+            assertEquals(6L, g.E().count().next().longValue());
+        } else {
+            IoTest.assertModernGraph(graph, false, true);
+        }
     }
 
     public static class Traversals extends ReadTest {


[37/38] tinkerpop git commit: TINKERPOP-1996 Fixed up typos in docs

Posted by sp...@apache.org.
TINKERPOP-1996 Fixed up typos in docs


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

Branch: refs/heads/master
Commit: 10478be0c9cabb6b20723c3185464977767172bc
Parents: 38dc70d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 27 07:10:41 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 27 07:10:41 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/the-traversal.asciidoc | 6 +++---
 docs/src/upgrade/release-3.4.x.asciidoc   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/10478be0/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index c861d87..d096933 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -1060,9 +1060,9 @@ job of the `io()`-step. By default, TinkerPop supports three formats for importi
 
 NOTE: Additional documentation for TinkerPop IO formats can be found in the link:http://tinkerpop.apache.org/docs/x.y.z/dev/io/[IO Reference].
 
-By itself the `io()` step merely configures the kind of importing and exporting that is going
+By itself the `io()`-step merely configures the kind of importing and exporting that is going
 to occur and it is the follow-on call to the `read()` or `write()` step that determines which of those actions will
-execute. Therefore, a typical usage of the `io()` step would look like this:
+execute. Therefore, a typical usage of the `io()`-step would look like this:
 
 [source,java]
 ----
@@ -1073,7 +1073,7 @@ g.io(someOutputFile).write().iterate()
 IMPORTANT: The commands above are still traversals and therefore require iteration to be executed, hence the use of
 `iterate()` as a termination step.
 
-By default, the `io()` step will try to detect the right file format using the file name extension. To gain greater
+By default, the `io()`-step will try to detect the right file format using the file name extension. To gain greater
 control of the format use the `with()` step modulator to provide further information to `io()`. For example:
 
 [source,java]

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/10478be0/docs/src/upgrade/release-3.4.x.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.4.x.asciidoc b/docs/src/upgrade/release-3.4.x.asciidoc
index 0bb3903..8d87397 100644
--- a/docs/src/upgrade/release-3.4.x.asciidoc
+++ b/docs/src/upgrade/release-3.4.x.asciidoc
@@ -81,7 +81,7 @@ g.io(someInputFile).read().iterate()
 g.io(someOutputFile).write().iterate()
 ----
 
-While `io()` step is still single-threaded for OLTP style loading, it can be utilized in conjunction with OLAP which
+While `io()`-step is still single-threaded for OLTP style loading, it can be utilized in conjunction with OLAP which
 internally uses `CloneVertexProgram` and therefore any graph `InputFormat` or `OutputFormat` can be configured in
 conjunction with this step for parallel loads of large datasets.
 


[31/38] tinkerpop git commit: TINKERPOP-1996 No need to assert io() against VertexProgramStrategy

Posted by sp...@apache.org.
TINKERPOP-1996 No need to assert io() against VertexProgramStrategy


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

Branch: refs/heads/master
Commit: 7f1bf1783efb8a7eca17d0367af66c6289455fd8
Parents: e6e4413
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 11:52:13 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 11:52:13 2018 -0400

----------------------------------------------------------------------
 .../strategy/decoration/VertexProgramStrategyTest.java         | 6 ------
 1 file changed, 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7f1bf178/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
index d3bb6ef..8ceef48 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
@@ -43,7 +43,6 @@ import static org.junit.Assert.assertEquals;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
- * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 @RunWith(Parameterized.class)
 public class VertexProgramStrategyTest {
@@ -68,12 +67,7 @@ public class VertexProgramStrategyTest {
     public static Iterable<Object[]> generateTestParameters() {
 
         final ComputerResultStep computerResultStep = new ComputerResultStep(EmptyTraversal.instance());
-
-        // The tests for io() need to verify that there is no change i.e. we don't want the step getting wrapped up in
-        // traversalvertexprogramstep stuff or else it won't execute properly in OLAP
         return Arrays.asList(new Traversal[][]{
-                { EmptyGraph.instance().traversal().io("blah.json"), EmptyGraph.instance().traversal().io("blah.json")},
-                { EmptyGraph.instance().traversal().io("blah.json"), EmptyGraph.instance().traversal().io("blah.json")},
                 {__.V().out().count(), start().addStep(traversal(__.V().out().count())).addStep(computerResultStep)},
                 {__.V().pageRank().out().count(), start().pageRank().asAdmin().addStep(traversal(__.V().out().count())).addStep(computerResultStep)},
                 {__.V().out().pageRank(), start().addStep(traversal(__.V().out())).pageRank().asAdmin().addStep(traversal(__.identity())).addStep(computerResultStep)},


[19/38] tinkerpop git commit: TINKERPOP-1996 Removed unecessary enum

Posted by sp...@apache.org.
TINKERPOP-1996 Removed unecessary enum


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

Branch: refs/heads/master
Commit: f8e3b8a1df1639405a29f261a9d7da147e88b356
Parents: 8187016
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 16 14:47:47 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:41:01 2018 -0400

----------------------------------------------------------------------
 .../process/traversal/step/sideEffect/IoStep.java     | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f8e3b8a1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
index 74b295b..9804333 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
@@ -18,6 +18,8 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect;
 
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.commons.configuration.Configuration;
 import org.apache.tinkerpop.gremlin.process.traversal.IO;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
@@ -52,12 +54,6 @@ import java.lang.reflect.Method;
  */
 public class IoStep<S> extends AbstractStep<S,S> implements ReadWriting {
 
-    private enum Format {
-        GRYO,
-        GRAPHSON,
-        GRAPHML
-    }
-
     private Parameters parameters = new Parameters();
     private boolean first = true;
     private String file;
@@ -219,6 +215,12 @@ public class IoStep<S> extends AbstractStep<S,S> implements ReadWriting {
             throw new IllegalStateException("Could not detect the file format - specify the writer explicitly or rename file with a standard extension");
     }
 
+    private Configuration getConfFromParameters() {
+        final Configuration conf = new BaseConfiguration();
+        parameters.getRaw().forEach((key, value) -> conf.setProperty(key.toString(), value.get(0)));
+        return conf;
+    }
+
     @Override
     public int hashCode() {
         final int hash = super.hashCode() ^ this.parameters.hashCode();


[22/38] tinkerpop git commit: TINKERPOP-1996 Added iterate() to read()/write() steps in docs

Posted by sp...@apache.org.
TINKERPOP-1996 Added iterate() to read()/write() steps in docs


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

Branch: refs/heads/master
Commit: ae3b149789b8a9779d0549cee8a6ca2e2febbd2b
Parents: a580b6f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jul 19 14:24:15 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 14:24:15 2018 -0400

----------------------------------------------------------------------
 docs/src/recipes/centrality.asciidoc            |  2 +-
 .../reference/implementations-neo4j.asciidoc    |  4 +--
 .../implementations-tinkergraph.asciidoc        |  8 ++---
 docs/src/reference/the-traversal.asciidoc       | 35 +++++++++++---------
 4 files changed, 26 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae3b1497/docs/src/recipes/centrality.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/recipes/centrality.asciidoc b/docs/src/recipes/centrality.asciidoc
index 0c1d4bc..59e6a4d 100644
--- a/docs/src/recipes/centrality.asciidoc
+++ b/docs/src/recipes/centrality.asciidoc
@@ -156,7 +156,7 @@ give it the highest rank. Consider the following example using the Grateful Dead
 
 [gremlin-groovy]
 ----
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g.V().repeat(groupCount('m').by('name').out()).times(5).cap('m').                <1>
   order(local).by(values, desc).limit(local, 10).next()                          <2>
 g.V().repeat(groupCount('m').by('name').out().timeLimit(100)).times(5).cap('m'). <3>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae3b1497/docs/src/reference/implementations-neo4j.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/implementations-neo4j.asciidoc b/docs/src/reference/implementations-neo4j.asciidoc
index 1760bd6..cfbf612 100644
--- a/docs/src/reference/implementations-neo4j.asciidoc
+++ b/docs/src/reference/implementations-neo4j.asciidoc
@@ -94,7 +94,7 @@ labels), a linear scan of the vertex-label partition is still faster than a line
 ----
 graph = Neo4jGraph.open('/tmp/neo4j')
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g.tx().commit()
 clock(1000) {g.V().hasLabel('artist').has('name','Garcia').iterate()}  <1>
 graph.cypher("CREATE INDEX ON :artist(name)") <2>
@@ -162,7 +162,7 @@ It is possible to leverage Cypher from within Gremlin by using the `Neo4jGraph.c
 ----
 graph = Neo4jGraph.open('/tmp/neo4j')
 g = graph.traversal()
-g.io('data/tinkerpop-modern.kryo').read()
+g.io('data/tinkerpop-modern.kryo').read().iterate()
 graph.cypher('MATCH (a {name:"marko"}) RETURN a')
 graph.cypher('MATCH (a {name:"marko"}) RETURN a').select('a').out('knows').values('name')
 graph.close()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae3b1497/docs/src/reference/implementations-tinkergraph.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/implementations-tinkergraph.asciidoc b/docs/src/reference/implementations-tinkergraph.asciidoc
index acd37dd..fe14d0f 100644
--- a/docs/src/reference/implementations-tinkergraph.asciidoc
+++ b/docs/src/reference/implementations-tinkergraph.asciidoc
@@ -90,12 +90,12 @@ TinkerGraph over the Grateful Dead graph.
 ----
 graph = TinkerGraph.open()
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 clock(1000) {g.V().has('name','Garcia').iterate()} <1>
 graph = TinkerGraph.open()
 g = graph.traversal()
 graph.createIndex('name',Vertex.class)
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 clock(1000){g.V().has('name','Garcia').iterate()} <2>
 ----
 
@@ -159,12 +159,12 @@ cardinality to `list` or else the data will import as `single`.  Consider the fo
 ----
 graph = TinkerGraph.open()
 g = graph.traversal()
-g.io("data/tinkerpop-crew.kryo").read()
+g.io("data/tinkerpop-crew.kryo").read().iterate()
 g.V().properties()
 conf = new BaseConfiguration()
 conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality","list")
 graph = TinkerGraph.open(conf)
 g = graph.traversal()
-g.io("data/tinkerpop-crew.kryo").read()
+g.io("data/tinkerpop-crew.kryo").read().iterate()
 g.V().properties()
 ----

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae3b1497/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index cca71f6..cd2f5f2 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -401,7 +401,7 @@ made more salient on a larger graph. Therefore, the example below leverages the
 ----
 graph = TinkerGraph.open()
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g = graph.traversal().withoutStrategies(LazyBarrierStrategy) <1>
 clockWithResult(1){g.V().both().both().both().count().next()} <2>
 clockWithResult(1){g.V().repeat(both()).times(3).count().next()} <3>
@@ -424,7 +424,7 @@ optimization scenario with the added benefit of reducing the risk of an out-of-m
 ----
 graph = TinkerGraph.open()
 g = graph.traversal()  <1>
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 clockWithResult(1){g.V().both().both().both().count().next()}
 g.V().both().both().both().count().iterate().toString()  <2>
 ----
@@ -1066,10 +1066,13 @@ execute. Therefore, a typical usage of the `io()` step would look like this:
 
 [source,java]
 ----
-g.io(someInputFile).read()
-g.io(someOutputFile).write()
+g.io(someInputFile).read().iterate()
+g.io(someOutputFile).write().iterate()
 ----
 
+IMPORTANT: The commands above are still traversals and therefore require iteration to be executed, hence the use of
+`iterate()` as a termination step.
+
 By default, the `io()` step will try to detect the right file format using the file name extension. To gain greater
 control of the format use the `with()` step modulator to provide further information to `io()`. For example:
 
@@ -1077,13 +1080,13 @@ control of the format use the `with()` step modulator to provide further informa
 ----
 g.io(someInputFile).
     with(IO.reader, IO.graphson).
-  read()
+  read().iterate()
 g.io(someOutputFile).
     with(IO.writer,IO.graphml).
-  write()
+  write().iterate()
 ----
 
-The `IO` class is a helper that for the `io()` step that provides expressions that can be used to help configure it
+The `IO` class is a helper for the `io()` step that provides expressions that can be used to help configure it
 and in this case it allows direct specification of the "reader" or "writer" to use. The "reader" actually refers to
 a `GraphReader` implementation and the `writer" refers to a `GraphWriter` implementation. The implementations of
 those interfaces provided by default are the standard TinkerPop implementations.
@@ -1136,8 +1139,8 @@ GraphML to appear before all `<edge>` elements if vertex labels are important to
 
 [source,java]
 ----
-g.io("graph.xml").read()
-g.io("graph.xml").write()
+g.io("graph.xml").read().iterate()
+g.io("graph.xml").write().iterate()
 ----
 
 NOTE: If using GraphML generated from TinkerPop 2.x, read more about its incompatibilities in the
@@ -1157,8 +1160,8 @@ but it is generally best used in two cases:
 
 [source,java]
 ----
-g.io("graph.json").read()
-g.io("graph.json").write()
+g.io("graph.json").read().iterate()
+g.io("graph.json").write().iterate()
 ----
 
 NOTE: Additional documentation for GraphSON can be found in the link:http://tinkerpop.apache.org/docs/x.y.z/dev/io/#graphson[IO Reference].
@@ -1182,8 +1185,8 @@ other.  Failure to do so, may result in errors.
 
 [source,java]
 ----
-g.io("graph.kryo").read()
-g.io("graph.kryo").write()
+g.io("graph.kryo").read().iterate()
+g.io("graph.kryo").write().iterate()
 ----
 
 *Additional References*
@@ -1403,7 +1406,7 @@ songs which Jerry Garcia has both sung and written (using the Grateful Dead grap
 [gremlin-groovy]
 ----
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g.V().match(
         __.as('a').has('name', 'Garcia'),
         __.as('a').in('writtenBy').as('b'),
@@ -2495,7 +2498,7 @@ ranking.
 [gremlin-groovy]
 ----
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g.V().hasLabel('song').out('followedBy').groupCount().by('name').
       order(local).by(values,desc).limit(local, 5)
 g.V().hasLabel('song').out('followedBy').groupCount().by('name').
@@ -2509,7 +2512,7 @@ Similarly, for extracting the values from a path or map.
 [gremlin-groovy]
 ----
 g = graph.traversal()
-g.io('data/grateful-dead.xml').read()
+g.io('data/grateful-dead.xml').read().iterate()
 g.V().hasLabel('song').out('sungBy').groupCount().by('name') <1>
 g.V().hasLabel('song').out('sungBy').groupCount().by('name').select(values) <2>
 g.V().hasLabel('song').out('sungBy').groupCount().by('name').select(values).unfold().


[12/38] tinkerpop git commit: TINKERPOP-1996 Deprecated Graph.io() and related infrastructure.

Posted by sp...@apache.org.
TINKERPOP-1996 Deprecated Graph.io() and related infrastructure.


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

Branch: refs/heads/master
Commit: ae796378e07925f9385f3ec65c10022b59aab8b5
Parents: 328737a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jul 12 14:33:03 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:40:09 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                                | 2 ++
 .../main/java/org/apache/tinkerpop/gremlin/structure/Graph.java   | 3 +++
 .../main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java   | 3 +++
 .../java/org/apache/tinkerpop/gremlin/structure/io/IoCore.java    | 3 +++
 .../apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java  | 3 +++
 .../tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java       | 3 +++
 .../org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java    | 3 +++
 7 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae796378/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index c0cd27d..bc78bbe 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -27,6 +27,8 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
 
 * Bumped to Netty 4.1.25.
 * Bumped to Spark 2.3.1.
+* Added the `io()` start step and `read()` and `write()` termination steps to the Gremlin language.
+* Deprecated `Graph.io()` and related infrastructure.
 * Moved `Parameterizing` interface to the `org.apache.tinkerpop.gremlin.process.traversal.step` package with other marker interfaces of its type.
 * Replaced `Parameterizing.addPropertyMutations()` with `Configuring.configure()`.
 * Changed interface hierarchy for `Parameterizing` and `Mutating` interfaces as they are tightly related.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae796378/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
index dc14cc6..f1fc54a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
@@ -300,7 +300,10 @@ public interface Graph extends AutoCloseable, Host {
      * For those graphs that do not need to register any custom serializers, the default implementation should suffice.
      * If the default is overridden, take care to register the current graph via the
      * {@link org.apache.tinkerpop.gremlin.structure.io.Io.Builder#graph(Graph)} method.
+     *
+     * @deprecated As of release 3.4.0, replaced by {@link GraphTraversalSource#io(String)}.
      */
+    @Deprecated
     public default <I extends Io> I io(final Io.Builder<I> builder) {
         return (I) builder.graph(this).create();
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae796378/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java
index bae56c5..0971e31 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Io.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io;
 
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 
 import java.io.IOException;
@@ -31,7 +32,9 @@ import java.util.function.Consumer;
  * internal {@link Mapper} (if the format has such capability).
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.4.0, replaced by {@link GraphTraversalSource#io(String)}.
  */
+@Deprecated
 public interface Io<R extends GraphReader.ReaderBuilder, W extends GraphWriter.WriterBuilder, M extends Mapper.Builder> {
 
     /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae796378/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoCore.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoCore.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoCore.java
index 9d9ad60..a357184 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoCore.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoCore.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io;
 
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
@@ -27,7 +28,9 @@ import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
  * methods statically.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.4.0, replaced by {@link GraphTraversalSource#io(String)}.
  */
+@Deprecated
 public final class IoCore {
 
     private IoCore() {}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae796378/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java
index 88431bf..b6af646 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLIo.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io.graphml;
 
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.Io;
 import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
@@ -37,7 +38,9 @@ import java.util.function.Consumer;
  * such things.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.4.0, replaced by {@link GraphTraversalSource#io(String)}.
  */
+@Deprecated
 public final class GraphMLIo implements Io<GraphMLReader.Builder, GraphMLWriter.Builder, GraphMLMapper.Builder> {
     private final Graph graph;
     private Optional<Consumer<Mapper.Builder>> onMapper;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae796378/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
index a3923a1..7f8b835 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io.graphson;
 
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.Io;
 import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
@@ -36,7 +37,9 @@ import java.util.function.Consumer;
  * interfaces should see the {@link GraphSONMapper} for information on the expectations for the {@link IoRegistry}.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.4.0, replaced by {@link GraphTraversalSource#io(String)}.
  */
+@Deprecated
 public final class GraphSONIo implements Io<GraphSONReader.Builder, GraphSONWriter.Builder, GraphSONMapper.Builder> {
     private final Graph graph;
     private final Optional<Consumer<Mapper.Builder>> onMapper;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ae796378/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java
index 29e63de..a7dfe0d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoIo.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io.gryo;
 
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.Io;
 import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
@@ -36,7 +37,9 @@ import java.util.function.Consumer;
  * interfaces should see the {@link GryoMapper} for information on the expectations for the {@link IoRegistry}.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.4.0, replaced by {@link GraphTraversalSource#io(String)}.
  */
+@Deprecated
 public final class GryoIo implements Io<GryoReader.Builder, GryoWriter.Builder, GryoMapper.Builder> {
 
     private final Graph graph;


[25/38] tinkerpop git commit: TINKERPOP-1996 Added some docs around IO.registry

Posted by sp...@apache.org.
TINKERPOP-1996 Added some docs around IO.registry


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

Branch: refs/heads/master
Commit: 51dc82122af6b8d8c783de58a0451b8b2071c051
Parents: 9423397
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 07:15:07 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 07:15:07 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/the-traversal.asciidoc | 30 ++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/51dc8212/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc
index cd2f5f2..c3b9300 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -1114,6 +1114,36 @@ IMPORTANT: Remote Gremlin Console users or Gremlin Language Variant (GLV) users
 the `io()` step should recall that their `read()` or `write()` operation will occur on the server and not locally
 and therefore the file specified for import/export must be something accessible by the server.
 
+GraphSON and Gryo formats are extensible allowing users and graph providers to extend supported serialization options.
+These extensions are exposed through `IoRegistry` implementations. To apply an `IoRegistry` use the `with()` option
+and the `IO.registry` key, where the value is either an actual `IoRegistry` instance or the fully qualified class
+name of one.
+
+[source,java]
+----
+g.io(someInputFile).
+    with(IO.reader, IO.gryo).
+    with(IO.registry, TinkerIoRegistryV3d0.instance())
+  read().iterate()
+g.io(someOutputFile).
+    with(IO.writer,IO.graphson).
+    with(IO.registry, "org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0")
+  write().iterate()
+----
+
+GLVs will obviously always be forced to use the latter form as they can't explicitly create an instance of an
+`IoRegistry` to pass to the server (nor are `IoRegistry` instances necessarily serializable).
+
+The version of the formats (e.g. GraphSON 2.0 or 3.0) utilized by `io()` is determined entirely by the `IO.reader` and
+`IO.writer` configurations or their defaults. The defaults will always be the latest version for the current release
+of TinkerPop. It is also possible for graph providers to override these defaults, so consult the documentation of the
+underlying graph database in use for any details on that.
+
+For more advanced configuration of `GraphReader` and `GraphWriter` operations (e.g. normalized output for GraphSON,
+disabling class registrations for Gryo, etc.) then construct the appropriate `GraphReader` and `GraphWriter` using
+the `build()` method on their implementations and use it directly. It can be passed directly to the `IO.reader` or
+`IO.writer` options. Obviously, these are JVM based operations and thus not available to GLVs as portable features.
+
 [[_graphml_reader_writer]]
 [[graphml]]
 ==== GraphML


[27/38] tinkerpop git commit: TINKERPOP-1996 Fixed up general strategy application around io()

Posted by sp...@apache.org.
TINKERPOP-1996 Fixed up general strategy application around io()

The GraphComputer was not being set properly in the HadoopIoStep and therefore executions of OLAP runs would not work even if withComputer(SparkGraphComputer) was set. It only worked if the gremlin.hadoop.defaultGraphComputer property was set which was weird.


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

Branch: refs/heads/master
Commit: c97d747f4b05cef42eb0e53adae50fcdee083a2e
Parents: 4d979cf
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 10:30:00 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 10:30:00 2018 -0400

----------------------------------------------------------------------
 .../step/map/TraversalVertexProgramStep.java    |  4 ---
 .../decoration/VertexProgramStrategy.java       | 30 +++++++++-----------
 .../traversal/step/sideEffect/IoStep.java       |  2 --
 .../traversal/strategy/HadoopIoStrategy.java    | 28 ++++++++++++------
 4 files changed, 33 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c97d747f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
index 4eb950f..30cfee5 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
@@ -19,19 +19,15 @@
 
 package org.apache.tinkerpop.gremlin.process.computer.traversal.step.map;
 
-import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
 import org.apache.tinkerpop.gremlin.process.computer.GraphFilter;
 import org.apache.tinkerpop.gremlin.process.computer.Memory;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.MemoryTraversalSideEffects;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.finalization.ComputerFinalizationStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
 import org.apache.tinkerpop.gremlin.process.traversal.util.PureTraversal;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c97d747f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
index cb99652..fa6e23f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
@@ -101,23 +101,21 @@ public final class VertexProgramStrategy extends AbstractTraversalStrategy<Trave
 
         // wrap all non-VertexComputing steps into a TraversalVertexProgramStep
         currentStep = traversal.getStartStep();
-        if (!(currentStep instanceof ReadWriting)) {
+        while (!(currentStep instanceof EmptyStep)) {
+            final Traversal.Admin<?, ?> computerTraversal = new DefaultTraversal<>();
+            final Step<?, ?> firstLegalOLAPStep = getFirstLegalOLAPStep(currentStep);
+            final Step<?, ?> lastLegalOLAPStep = getLastLegalOLAPStep(currentStep);
+            if (!(firstLegalOLAPStep instanceof EmptyStep)) {
+                final int index = TraversalHelper.stepIndex(firstLegalOLAPStep, traversal);
+                TraversalHelper.removeToTraversal(firstLegalOLAPStep, lastLegalOLAPStep.getNextStep(), (Traversal.Admin) computerTraversal);
+                final TraversalVertexProgramStep traversalVertexProgramStep = new TraversalVertexProgramStep(traversal, computerTraversal);
+                traversal.addStep(index, traversalVertexProgramStep);
+            }
+            currentStep = traversal.getStartStep();
             while (!(currentStep instanceof EmptyStep)) {
-                final Traversal.Admin<?, ?> computerTraversal = new DefaultTraversal<>();
-                final Step<?, ?> firstLegalOLAPStep = getFirstLegalOLAPStep(currentStep);
-                final Step<?, ?> lastLegalOLAPStep = getLastLegalOLAPStep(currentStep);
-                if (!(firstLegalOLAPStep instanceof EmptyStep)) {
-                    final int index = TraversalHelper.stepIndex(firstLegalOLAPStep, traversal);
-                    TraversalHelper.removeToTraversal(firstLegalOLAPStep, lastLegalOLAPStep.getNextStep(), (Traversal.Admin) computerTraversal);
-                    final TraversalVertexProgramStep traversalVertexProgramStep = new TraversalVertexProgramStep(traversal, computerTraversal);
-                    traversal.addStep(index, traversalVertexProgramStep);
-                }
-                currentStep = traversal.getStartStep();
-                while (!(currentStep instanceof EmptyStep)) {
-                    if (!(currentStep instanceof VertexComputing))
-                        break;
-                    currentStep = currentStep.getNextStep();
-                }
+                if (!(currentStep instanceof VertexComputing))
+                    break;
+                currentStep = currentStep.getNextStep();
             }
         }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c97d747f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
index 1d4f40b..e5b3a6a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
@@ -18,8 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect;
 
-import org.apache.commons.configuration.BaseConfiguration;
-import org.apache.commons.configuration.Configuration;
 import org.apache.tinkerpop.gremlin.process.traversal.IO;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c97d747f/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
index 8348410..af3db6e 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.strategy;
 
 import org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.step.sideEffect.HadoopIoStep;
 import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.TraversalVertexProgramStep;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
@@ -30,6 +31,11 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IoStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * The default implementation of the {@link IoStep} is a single threaded operation and doesn't properly take into
  * account the method by which OLAP read/writes take place with Hadoop. This strategy removes that step and replaces
@@ -48,16 +54,20 @@ public final class HadoopIoStrategy extends AbstractTraversalStrategy<TraversalS
 
     @Override
     public void apply(final Traversal.Admin<?, ?> traversal) {
-        // replace IoStep steps with hadoop specific one
-        if (traversal.getStartStep() instanceof IoStep) {
-            final ReadWriting readWriting = (ReadWriting) traversal.getStartStep();
-            final HadoopIoStep hadoopIoStep = new HadoopIoStep(traversal, readWriting.getFile());
-            hadoopIoStep.setMode(readWriting.getMode());
-            readWriting.getParameters().getRaw().entrySet().forEach(kv ->
-                    hadoopIoStep.configure(kv.getKey(), kv.getValue().get(0))
-            );
+        // VertexProgramStrategy should wrap up the IoStep in a TraversalVertexProgramStep. use that to grab the
+        // GraphComputer that was injected in there and push that in to the HadoopIoStep. this step pattern match
+        // is fairly specific and since you really can't chain together steps after io() this approach should work
+        if (traversal.getStartStep() instanceof TraversalVertexProgramStep) {
+            final TraversalVertexProgramStep tvp = (TraversalVertexProgramStep) traversal.getStartStep();
+            if (tvp.computerTraversal.get().getStartStep() instanceof ReadWriting) {
+                final ReadWriting readWriting = (ReadWriting) tvp.computerTraversal.get().getStartStep();
+                final HadoopIoStep hadoopIoStep = new HadoopIoStep(traversal, readWriting.getFile());
+                hadoopIoStep.setMode(readWriting.getMode());
+                hadoopIoStep.setComputer(tvp.getComputer());
+                readWriting.getParameters().getRaw().forEach((key, value) -> value.forEach(v -> hadoopIoStep.configure(key, v)));
 
-            TraversalHelper.replaceStep((Step) readWriting, hadoopIoStep, traversal);
+                TraversalHelper.replaceStep(tvp, hadoopIoStep, traversal);
+            }
         }
     }
 


[34/38] tinkerpop git commit: TINKERPOP-1996 Added IoStep to list of unsupported steps

Posted by sp...@apache.org.
TINKERPOP-1996 Added IoStep to list of unsupported steps

If this isn't there then GraphReader/Writer will blow up as it tries to mutate the graph. IoStep is an OLTP only step. For OLAP each graph implementation will need to add its own GraphComputer-ready step.


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

Branch: refs/heads/master
Commit: e9ebacfc84aca0e0ac30720bba68939f77c4c5d0
Parents: 23c71b6
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 15:08:45 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 15:08:45 2018 -0400

----------------------------------------------------------------------
 .../strategy/verification/ComputerVerificationStrategy.java       | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e9ebacfc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/ComputerVerificationStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/ComputerVerificationStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/ComputerVerificationStrategy.java
index 2d076b6..5c2d299 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/ComputerVerificationStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/ComputerVerificationStrategy.java
@@ -28,6 +28,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.Mutating;
 import org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IoStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.ProfileStep;
@@ -46,7 +47,7 @@ public final class ComputerVerificationStrategy extends AbstractTraversalStrateg
 
     private static final ComputerVerificationStrategy INSTANCE = new ComputerVerificationStrategy();
     private static final Set<Class<?>> UNSUPPORTED_STEPS = new HashSet<>(Arrays.asList(
-            InjectStep.class, Mutating.class, SubgraphStep.class, ComputerResultStep.class
+            InjectStep.class, Mutating.class, SubgraphStep.class, ComputerResultStep.class, IoStep.class
     ));
 
     private ComputerVerificationStrategy() {


[26/38] tinkerpop git commit: TINKERPOP-1996 Pass configurations from with() through to Hadoop

Posted by sp...@apache.org.
TINKERPOP-1996 Pass configurations from with() through to Hadoop

This will allow users to override or add to the Hadoop/Spark/OLAP configuration as needed


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

Branch: refs/heads/master
Commit: 4d979cf8dc4482d574191a76a0c60e281f887563
Parents: 51dc821
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 07:35:48 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 07:35:48 2018 -0400

----------------------------------------------------------------------
 .../traversal/step/sideEffect/HadoopIoStep.java | 29 ++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4d979cf8/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/sideEffect/HadoopIoStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/sideEffect/HadoopIoStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/sideEffect/HadoopIoStep.java
index ca369b6..2e96276 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/sideEffect/HadoopIoStep.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/sideEffect/HadoopIoStep.java
@@ -29,6 +29,7 @@ import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
 import org.apache.tinkerpop.gremlin.process.traversal.IO;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
@@ -37,7 +38,9 @@ import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
 /**
  * An OLAP oriented step for doing IO operations with {@link GraphTraversalSource#io(String)} which uses the
- * {@link CloneVertexProgram} for its implementation.
+ * {@link CloneVertexProgram} for its implementation. Standard Hadoop OLAP configurations can be passed using the
+ * {@link GraphTraversal#with(String, Object)} step modulator as all options aside from those in {@link IO} will be
+ * transferred.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
@@ -69,7 +72,6 @@ public class HadoopIoStep extends VertexProgramStep implements ReadWriting {
 
     @Override
     public void configure(final Object... keyValues) {
-        // TODO: probably should write to the Configuration selectively - no need for actual Parameters?????????
         this.parameters.set(null, keyValues);
     }
 
@@ -121,6 +123,8 @@ public class HadoopIoStep extends VertexProgramStep implements ReadWriting {
 
         graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, inputFormatClassName);
         graph.configuration().setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, file);
+
+        addParametersToConfiguration(graph);
     }
 
     private void configureForWrite(final Graph graph) {
@@ -137,6 +141,27 @@ public class HadoopIoStep extends VertexProgramStep implements ReadWriting {
         
         graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, outputFormatClassName);
         graph.configuration().setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, file);
+
+        addParametersToConfiguration(graph);
+    }
+
+    /**
+     * Overwrites all configurations from values passed using {@link GraphTraversal#with(String, Object)}.
+     */
+    private void addParametersToConfiguration(final Graph graph) {
+        parameters.getRaw(IO.writer, IO.writer, IO.registry).entrySet().forEach(kv -> {
+            if (kv.getValue().size() == 1)
+                graph.configuration().setProperty(kv.getKey().toString(), kv.getValue().get(0));
+            else {
+                // reset the default configuration with the first option then add to that for List options
+                for (int ix = 0; ix < kv.getValue().size(); ix++) {
+                    if (ix == 0)
+                        graph.configuration().setProperty(kv.getKey().toString(), kv.getValue().get(ix));
+                    else
+                        graph.configuration().addProperty(kv.getKey().toString(), kv.getValue().get(ix));
+                }
+            }
+        });
     }
 
     private String detectReader() {


[38/38] tinkerpop git commit: Merge branch 'TINKERPOP-1996'

Posted by sp...@apache.org.
Merge branch 'TINKERPOP-1996'


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

Branch: refs/heads/master
Commit: edd8234684bedb7c073479724b2ee645a801cbc5
Parents: 7d21ee0 10478be
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 31 07:35:52 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jul 31 07:35:52 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   4 +
 docs/src/recipes/centrality.asciidoc            |   2 +-
 .../reference/implementations-neo4j.asciidoc    |   5 +-
 .../implementations-tinkergraph.asciidoc        |   8 +-
 docs/src/reference/the-graph.asciidoc           | 370 -------------------
 docs/src/reference/the-traversal.asciidoc       | 186 +++++++++-
 docs/src/upgrade/release-3.4.x.asciidoc         |  49 ++-
 .../tinkerpop/gremlin/jsr223/CoreImports.java   |   2 +
 .../step/map/TraversalVertexProgramStep.java    |   4 -
 .../decoration/VertexProgramStrategy.java       |  11 +-
 .../tinkerpop/gremlin/process/traversal/IO.java |  83 +++++
 .../traversal/dsl/graph/GraphTraversal.java     |  37 ++
 .../dsl/graph/GraphTraversalSource.java         |  22 ++
 .../process/traversal/step/ReadWriting.java     |  48 +++
 .../traversal/step/sideEffect/IoStep.java       | 254 +++++++++++++
 .../process/traversal/step/util/Parameters.java |   4 +-
 .../ComputerVerificationStrategy.java           |   3 +-
 .../StandardVerificationStrategy.java           |   9 +
 .../tinkerpop/gremlin/structure/Graph.java      |  30 ++
 .../tinkerpop/gremlin/structure/io/IoCore.java  |   3 +
 .../traversal/dsl/graph/GraphTraversalTest.java |   5 +-
 .../decoration/VertexProgramStrategyTest.java   |   2 +-
 .../StandardVerificationStrategyTest.java       |  13 +-
 .../glv/GraphTraversalSource.template           |   4 +-
 gremlin-dotnet/glv/IO.template                  |  46 +++
 gremlin-dotnet/glv/generate.groovy              |  13 +-
 .../Process/Traversal/GraphTraversal.cs         |  15 +-
 .../Process/Traversal/GraphTraversalSource.cs   |  11 +
 .../src/Gremlin.Net/Process/Traversal/IO.cs     |  56 +++
 .../Gherkin/TraversalEvaluation/IOParameter.cs  |  82 ++++
 .../TraversalEvaluation/TraversalParser.cs      |   7 +
 .../groovy/jsr223/GroovyTranslatorProvider.java |   6 +
 gremlin-javascript/glv/TraversalSource.template |   9 +
 gremlin-javascript/glv/generate.groovy          |   4 +
 .../lib/process/graph-traversal.js              |  30 ++
 .../gremlin-javascript/lib/process/traversal.js |  29 ++
 .../test/cucumber/feature-steps.js              |   2 +
 gremlin-python/glv/TraversalSource.template     |  11 +
 gremlin-python/glv/generate.groovy              |   4 +
 .../gremlin_python/process/graph_traversal.py   |  13 +
 .../jython/gremlin_python/process/traversal.py  |  21 ++
 .../src/main/jython/radish/feature_steps.py     |   5 +-
 gremlin-test/features/sideEffect/Read.feature   |  84 +++++
 gremlin-test/features/sideEffect/Write.feature  |  60 +++
 .../gremlin/AbstractGraphProvider.java          |  22 +-
 .../apache/tinkerpop/gremlin/TestHelper.java    |  24 +-
 .../gremlin/process/ProcessComputerSuite.java   |   4 +
 .../gremlin/process/ProcessStandardSuite.java   |   4 +
 .../process/traversal/step/map/ReadTest.java    | 188 ++++++++++
 .../process/traversal/step/map/WriteTest.java   | 183 +++++++++
 .../ElementIdStrategyProcessTest.java           |   1 -
 .../gremlin/structure/io/util/CustomId.java     |  39 ++
 .../gremlin/process/FeatureCoverageTest.java    |   6 +-
 .../traversal/step/sideEffect/HadoopIoStep.java | 188 ++++++++++
 .../traversal/strategy/HadoopIoStrategy.java    |  83 +++++
 .../gremlin/hadoop/structure/HadoopGraph.java   |  24 ++
 .../step/sideEffect/TinkerGraphIoStepTest.java  |  98 +++++
 .../structure/TinkerGraphPlayTest.java          |   6 +-
 ...ctTinkerGraphGraphSONTranslatorProvider.java |   5 +
 .../gryo/TinkerGraphGryoTranslatorProvider.java |   7 +-
 60 files changed, 2121 insertions(+), 427 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/edd82346/CHANGELOG.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/edd82346/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/edd82346/docs/src/upgrade/release-3.4.x.asciidoc
----------------------------------------------------------------------
diff --cc docs/src/upgrade/release-3.4.x.asciidoc
index 2d699dc,8d87397..9951024
--- a/docs/src/upgrade/release-3.4.x.asciidoc
+++ b/docs/src/upgrade/release-3.4.x.asciidoc
@@@ -31,12 -31,12 +31,12 @@@ Please see the link:https://github.com/
  
  ==== with() Step
  
 -This version of TinkerPop introduces the `with()` step to Gremlin. It isn't really a step but is instead a step
 +This version of TinkerPop introduces the `with()`-step to Gremlin. It isn't really a step but is instead a step
  modulator. This modulator allows the step it is modifying to accept configurations that can be used to alter the
 -behavior of the step itself. A good example of its usage is shown with the revised syntax of the `pageRank()` step
 +behavior of the step itself. A good example of its usage is shown with the revised syntax of the `pageRank()`-step
  which now uses `with()` to replace the old `by()` options:
  
- [groovy]
+ [source,groovy]
  ----
  g.V().hasLabel('person').
    pageRank().
@@@ -47,9 -47,9 +47,9 @@@
    valueMap('name','friendRank')
  ----
  
 -A similar change was made for `peerPressure()` step:
 +A similar change was made for `peerPressure()`-step:
  
- [groovy]
+ [source,groovy]
  ----
  g.V().hasLabel('person').
    peerPressure().

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/edd82346/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/edd82346/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/edd82346/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------


[20/38] tinkerpop git commit: TINKERPOP-1996 Used g.io() in tests by default

Posted by sp...@apache.org.
TINKERPOP-1996 Used g.io() in tests by default


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

Branch: refs/heads/master
Commit: 8187016886b8b699ff107c9b6a7dfe95deb7e4a1
Parents: 5bf19e2
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 16 12:10:02 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:41:01 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  5 ++--
 .../gremlin/AbstractGraphProvider.java          |  8 +++----
 .../apache/tinkerpop/gremlin/TestHelper.java    | 24 ++++++++++++++------
 3 files changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/81870168/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 1add03c..1848421 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -25,11 +25,12 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 
 This release also includes changes from <<release-3-3-3, 3.3.3>>.
 
-* Bumped to Netty 4.1.25.
-* Bumped to Spark 2.3.1.
+* `AbstractGraphProvider` uses `g.io()` for loading test data.
 * Added the `io()` start step and `read()` and `write()` termination steps to the Gremlin language.
 * Added `GraphFeatures.supportsIoRead()` and `GraphFeatures.supportsIoWrite()`.
 * Deprecated `Graph.io()` and related infrastructure.
+* Bumped to Netty 4.1.25.
+* Bumped to Spark 2.3.1.
 * Moved `Parameterizing` interface to the `org.apache.tinkerpop.gremlin.process.traversal.step` package with other marker interfaces of its type.
 * Replaced `Parameterizing.addPropertyMutations()` with `Configuring.configure()`.
 * Changed interface hierarchy for `Parameterizing` and `Mutating` interfaces as they are tightly related.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/81870168/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
index 75d033b..b6fc43c 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGraphProvider.java
@@ -25,6 +25,7 @@ import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
 import org.apache.commons.configuration.BaseConfiguration;
 import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoResourceAccess;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -142,9 +143,8 @@ public abstract class AbstractGraphProvider implements GraphProvider {
      * @param path the path to the file to load into the graph
      */
     protected void readIntoGraph(final Graph graph, final String path) throws IOException {
-        final GraphReader reader = GryoReader.build().create();
-        try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream(path)) {
-            reader.readGraph(stream, graph);
-        }
+        final String dataFile = TestHelper.generateTempFileFromResource(graph.getClass(),
+                GryoResourceAccess.class, path.substring(path.lastIndexOf(File.separator) + 1), "", false).getAbsolutePath();
+        graph.traversal().io(dataFile).read();
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/81870168/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java
index 38d9a25..cda32e2 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java
@@ -152,17 +152,27 @@ public final class TestHelper {
      * {@link TestHelper#makeTestDataPath} in a subdirectory called {@code temp/resources}.
      */
     public static File generateTempFileFromResource(final Class graphClass, final Class resourceClass, final String resourceName, final String extension) throws IOException {
+        return generateTempFileFromResource(graphClass, resourceClass, resourceName, extension, true);
+    }
+
+    /**
+     * Copies a file stored as part of a resource to the file system in the path returned from
+     * {@link TestHelper#makeTestDataPath} in a subdirectory called {@code temp/resources}.
+     */
+    public static File generateTempFileFromResource(final Class graphClass, final Class resourceClass, final String resourceName, final String extension, final boolean overwrite) throws IOException {
         final File temp = makeTestDataPath(graphClass, "resources");
         if (!temp.exists()) temp.mkdirs();
         final File tempFile = new File(temp, resourceName + extension);
-        final FileOutputStream outputStream = new FileOutputStream(tempFile);
-        int data;
-        final InputStream inputStream = resourceClass.getResourceAsStream(resourceName);
-        while ((data = inputStream.read()) != -1) {
-            outputStream.write(data);
+        if (!tempFile.exists() || overwrite) {
+            try (final FileOutputStream outputStream = new FileOutputStream(tempFile)) {
+                int data;
+                try (final InputStream inputStream = resourceClass.getResourceAsStream(resourceName)) {
+                    while ((data = inputStream.read()) != -1) {
+                        outputStream.write(data);
+                    }
+                }
+            }
         }
-        outputStream.close();
-        inputStream.close();
         return tempFile;
     }
 


[06/38] tinkerpop git commit: TINKERPOP-1996 Have the basics of OLAP read()/write() steps working

Posted by sp...@apache.org.
TINKERPOP-1996 Have the basics of OLAP read()/write() steps working

This is still fairly skeletal at this point. Just trying to make sure things work properly before building read()/write() out fully.


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

Branch: refs/heads/master
Commit: 0785090f67ff88a834f77c7181a69594049c65ea
Parents: ec1d05f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 10 12:21:52 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:39:29 2018 -0400

----------------------------------------------------------------------
 .../decoration/VertexProgramStrategy.java       | 34 ++++----
 .../process/traversal/TraversalStrategies.java  |  2 +
 .../gremlin/process/traversal/step/Reading.java | 27 +++++++
 .../gremlin/process/traversal/step/Writing.java | 26 +++++++
 .../process/traversal/step/map/ReadStep.java    | 10 ++-
 .../process/traversal/step/map/WriteStep.java   |  8 +-
 .../strategy/verification/IoUsageStrategy.java  |  8 ++
 .../decoration/VertexProgramStrategyTest.java   |  3 +
 .../gremlin/process/ProcessStandardSuite.java   |  2 +
 .../process/traversal/step/map/ReadTest.java    | 64 +++++++++++++++
 .../traversal/step/map/HadoopReadStep.java      | 82 ++++++++++++++++++++
 .../traversal/step/map/HadoopWriteStep.java     | 82 ++++++++++++++++++++
 .../traversal/strategy/HadoopIoStrategy.java    | 68 ++++++++++++++++
 .../gremlin/hadoop/structure/HadoopGraph.java   |  8 ++
 14 files changed, 407 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
index 89e40cb..c83039a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/VertexProgramStrategy.java
@@ -34,6 +34,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Writing;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
@@ -100,23 +102,26 @@ public final class VertexProgramStrategy extends AbstractTraversalStrategy<Trave
 
         // wrap all non-VertexComputing steps into a TraversalVertexProgramStep
         currentStep = traversal.getStartStep();
-        while (!(currentStep instanceof EmptyStep)) {
-            Traversal.Admin<?, ?> computerTraversal = new DefaultTraversal<>();
-            Step<?, ?> firstLegalOLAPStep = getFirstLegalOLAPStep(currentStep);
-            Step<?, ?> lastLegalOLAPStep = getLastLegalOLAPStep(currentStep);
-            if (!(firstLegalOLAPStep instanceof EmptyStep)) {
-                int index = TraversalHelper.stepIndex(firstLegalOLAPStep, traversal);
-                TraversalHelper.removeToTraversal(firstLegalOLAPStep, lastLegalOLAPStep.getNextStep(), (Traversal.Admin) computerTraversal);
-                final TraversalVertexProgramStep traversalVertexProgramStep = new TraversalVertexProgramStep(traversal, computerTraversal);
-                traversal.addStep(index, traversalVertexProgramStep);
-            }
-            currentStep = traversal.getStartStep();
+        if (!(currentStep instanceof Reading) && !(currentStep instanceof Writing)) {
             while (!(currentStep instanceof EmptyStep)) {
-                if (!(currentStep instanceof VertexComputing))
-                    break;
-                currentStep = currentStep.getNextStep();
+                final Traversal.Admin<?, ?> computerTraversal = new DefaultTraversal<>();
+                final Step<?, ?> firstLegalOLAPStep = getFirstLegalOLAPStep(currentStep);
+                final Step<?, ?> lastLegalOLAPStep = getLastLegalOLAPStep(currentStep);
+                if (!(firstLegalOLAPStep instanceof EmptyStep)) {
+                    final int index = TraversalHelper.stepIndex(firstLegalOLAPStep, traversal);
+                    TraversalHelper.removeToTraversal(firstLegalOLAPStep, lastLegalOLAPStep.getNextStep(), (Traversal.Admin) computerTraversal);
+                    final TraversalVertexProgramStep traversalVertexProgramStep = new TraversalVertexProgramStep(traversal, computerTraversal);
+                    traversal.addStep(index, traversalVertexProgramStep);
+                }
+                currentStep = traversal.getStartStep();
+                while (!(currentStep instanceof EmptyStep)) {
+                    if (!(currentStep instanceof VertexComputing))
+                        break;
+                    currentStep = currentStep.getNextStep();
+                }
             }
         }
+
         // if the last vertex computing step is a TraversalVertexProgramStep convert to OLTP with ComputerResultStep
         TraversalHelper.getLastStepOfAssignableClass(VertexComputing.class, traversal).ifPresent(step -> {
             if (step instanceof TraversalVertexProgramStep) {
@@ -126,6 +131,7 @@ public final class VertexProgramStrategy extends AbstractTraversalStrategy<Trave
                 TraversalHelper.insertAfterStep(computerResultStep, (Step) step, traversal);
             }
         });
+        
         // if there is a dangling vertex computing step, add an identity traversal (solve this in the future with a specialized MapReduce)
         if (traversal.getEndStep() instanceof VertexComputing && !(traversal.getEndStep() instanceof TraversalVertexProgramStep)) {
             final TraversalVertexProgramStep traversalVertexProgramStep = new TraversalVertexProgramStep(traversal, __.identity().asAdmin());

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
index ef3e841..66b0236 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
@@ -36,6 +36,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.Path
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.CountStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RepeatUnrollStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.IoUsageStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.StandardVerificationStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
 import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -222,6 +223,7 @@ public interface TraversalStrategies extends Serializable, Cloneable {
                     PathRetractionStrategy.instance(),
                     LazyBarrierStrategy.instance(),
                     ProfileStrategy.instance(),
+                    IoUsageStrategy.instance(),
                     StandardVerificationStrategy.instance());
             GRAPH_CACHE.put(Graph.class, graphStrategies);
             GRAPH_CACHE.put(EmptyGraph.class, new DefaultTraversalStrategies());

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java
new file mode 100644
index 0000000..b79378b
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java
@@ -0,0 +1,27 @@
+/*
+ * 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.process.traversal.step;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public interface Reading extends Configuring {
+
+    public String getLocalFile();
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java
new file mode 100644
index 0000000..7b455f2
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java
@@ -0,0 +1,26 @@
+/*
+ * 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.process.traversal.step;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public interface Writing extends Configuring {
+    public String getLocalFile();
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
index afc3e53..2612d18 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Configuring;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
 import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
@@ -43,7 +44,7 @@ import java.util.Map;
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
-public class ReadStep extends AbstractStep<Map<String,Object>, Map<String,Object>> implements Configuring {
+public class ReadStep extends AbstractStep<Map<String,Object>, Map<String,Object>> implements Reading {
 
     private Parameters parameters = new Parameters();
     private boolean first = true;
@@ -54,12 +55,16 @@ public class ReadStep extends AbstractStep<Map<String,Object>, Map<String,Object
 
         if (null == localFile || localFile.isEmpty())
             throw new IllegalArgumentException("localFile cannot be null or empty");
-        if (!new File(localFile).exists()) throw new IllegalStateException(localFile + " does not exist");
 
         this.localFile = localFile;
     }
 
     @Override
+    public String getLocalFile() {
+        return localFile;
+    }
+
+    @Override
     public Parameters getParameters() {
         return this.parameters;
     }
@@ -76,6 +81,7 @@ public class ReadStep extends AbstractStep<Map<String,Object>, Map<String,Object
         this.first = false;
         final TraverserGenerator generator = this.getTraversal().getTraverserGenerator();
         final File file = new File(localFile);
+        if (!file.exists()) throw new IllegalStateException(localFile + " does not exist");
 
         try (final InputStream stream = new FileInputStream(file)) {
             final Graph graph = (Graph) this.traversal.getGraph().get();

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
index e9346cf..3a035e7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Configuring;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Writing;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
 import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
@@ -43,7 +44,7 @@ import java.util.Map;
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
-public class WriteStep extends AbstractStep<Map<String,Object>, Map<String,Object>> implements Configuring {
+public class WriteStep extends AbstractStep<Map<String,Object>, Map<String,Object>> implements Writing {
 
     private Parameters parameters = new Parameters();
     private boolean first = true;
@@ -59,6 +60,11 @@ public class WriteStep extends AbstractStep<Map<String,Object>, Map<String,Objec
     }
 
     @Override
+    public String getLocalFile() {
+        return localFile;
+    }
+
+    @Override
     public Parameters getParameters() {
         return this.parameters;
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
index 95761ff..e9c7ec8 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
@@ -26,6 +26,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
 
+import java.util.Collections;
+import java.util.Set;
+
 /**
  * {@code IoUsageStrategy} prevents the {@link GraphTraversalSource#read(String)} and
  * {@link GraphTraversalSource#write(String)} steps from being used outside of their intended scope, which is as the
@@ -57,4 +60,9 @@ public final class IoUsageStrategy extends AbstractTraversalStrategy<TraversalSt
     public static IoUsageStrategy instance() {
         return INSTANCE;
     }
+
+    @Override
+    public Set<Class<? extends VerificationStrategy>> applyPrior() {
+        return Collections.singleton(ComputerVerificationStrategy.class);
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
index c091bb3..71cb22d 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/VertexProgramStrategyTest.java
@@ -32,6 +32,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
 import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversal;
+import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -68,6 +69,8 @@ public class VertexProgramStrategyTest {
         final ComputerResultStep computerResultStep = new ComputerResultStep(EmptyTraversal.instance());
 
         return Arrays.asList(new Traversal[][]{
+                { EmptyGraph.instance().traversal().read("blah.json"), EmptyGraph.instance().traversal().read("blah.json")},
+                { EmptyGraph.instance().traversal().write("blah.json"), EmptyGraph.instance().traversal().write("blah.json")},
                 {__.V().out().count(), start().addStep(traversal(__.V().out().count())).addStep(computerResultStep)},
                 {__.V().pageRank().out().count(), start().pageRank().asAdmin().addStep(traversal(__.V().out().count())).addStep(computerResultStep)},
                 {__.V().out().pageRank(), start().addStep(traversal(__.V().out())).pageRank().asAdmin().addStep(traversal(__.identity())).addStep(computerResultStep)},

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java
index f7c19ac..43da8b7 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessStandardSuite.java
@@ -63,6 +63,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.PathTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProjectTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.SelectTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.SumTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.UnfoldTest;
@@ -153,6 +154,7 @@ public class ProcessStandardSuite extends AbstractGremlinSuite {
             ProfileTest.Traversals.class,
             ProjectTest.Traversals.class,
             PropertiesTest.Traversals.class,
+            ReadTest.Traversals.class,
             SelectTest.Traversals.class,
             VertexTest.Traversals.class,
             UnfoldTest.Traversals.class,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
new file mode 100644
index 0000000..2cfc3f7
--- /dev/null
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.process.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.LoadGraphWith;
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
+import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
+import org.apache.tinkerpop.gremlin.process.IgnoreEngine;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.io.IoTest;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoResourceAccess;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@RunWith(GremlinProcessRunner.class)
+public abstract class ReadTest extends AbstractGremlinProcessTest {
+
+    public abstract Traversal<Map<String,Object>, Map<String,Object>> get_g_read()  throws IOException;
+
+    @Test
+    public void g_read() throws IOException {
+        final Traversal<Map<String,Object>, Map<String,Object>> traversal = get_g_read();
+        printTraversalForm(traversal);
+        assertTrue(traversal.hasNext());
+
+        IoTest.assertModernGraph(graph, false, true);
+    }
+
+    public static class Traversals extends ReadTest {
+        @Override
+        public Traversal<Map<String,Object>, Map<String,Object>> get_g_read() throws IOException {
+            final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GryoResourceAccess.class, "tinkerpop-modern-v3d0.kryo", "").getAbsolutePath().replace('\\', '/');
+            return g.read(fileToRead);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java
new file mode 100644
index 0000000..c896d76
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java
@@ -0,0 +1,82 @@
+/*
+ * 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.process.computer.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.hadoop.Constants;
+import org.apache.tinkerpop.gremlin.process.computer.GraphFilter;
+import org.apache.tinkerpop.gremlin.process.computer.Memory;
+import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class HadoopReadStep extends VertexProgramStep implements Reading {
+
+    private Parameters parameters = new Parameters();
+
+    public HadoopReadStep(final Traversal.Admin traversal, final String localFile) {
+        super(traversal);
+
+        final Graph graph = (Graph) traversal.getGraph().get();
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, "org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat");
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, localFile);
+    }
+
+    @Override
+    public String getLocalFile() {
+        return (String) ((Graph) traversal.getGraph().get()).configuration().getProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION);
+    }
+
+    @Override
+    public void configure(final Object... keyValues) {
+        // TODO: probably should write to the Configuration selectively - no need for actual Parameters?????????
+        this.parameters.set(null, keyValues);
+    }
+
+    @Override
+    public Parameters getParameters() {
+        return parameters;
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this, new GraphFilter(this.computer));
+    }
+
+    @Override
+    public CloneVertexProgram generateProgram(final Graph graph, final Memory memory) {
+        return CloneVertexProgram.build().create(graph);
+    }
+
+    @Override
+    public HadoopReadStep clone() {
+        return (HadoopReadStep) super.clone();
+    }
+
+    @Override
+    public int hashCode() {
+        return super.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java
new file mode 100644
index 0000000..0711a2e
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java
@@ -0,0 +1,82 @@
+/*
+ * 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.process.computer.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.hadoop.Constants;
+import org.apache.tinkerpop.gremlin.process.computer.GraphFilter;
+import org.apache.tinkerpop.gremlin.process.computer.Memory;
+import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class HadoopWriteStep extends VertexProgramStep implements Reading {
+
+    private Parameters parameters = new Parameters();
+
+    public HadoopWriteStep(final Traversal.Admin traversal, final String localFile) {
+        super(traversal);
+
+        final Graph graph = (Graph) traversal.getGraph().get();
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, "org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoOutputFormat");
+        graph.configuration().setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, localFile);
+    }
+
+    @Override
+    public String getLocalFile() {
+        return (String) ((Graph) traversal.getGraph().get()).configuration().getProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION);
+    }
+
+    @Override
+    public void configure(final Object... keyValues) {
+        // TODO: probably should write to the Configuration selectively - no need for actual Parameters?????????
+        this.parameters.set(null, keyValues);
+    }
+
+    @Override
+    public Parameters getParameters() {
+        return parameters;
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this, new GraphFilter(this.computer));
+    }
+
+    @Override
+    public CloneVertexProgram generateProgram(final Graph graph, final Memory memory) {
+        return CloneVertexProgram.build().create(graph);
+    }
+
+    @Override
+    public HadoopWriteStep clone() {
+        return (HadoopWriteStep) super.clone();
+    }
+
+    @Override
+    public int hashCode() {
+        return super.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
new file mode 100644
index 0000000..47986f9
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
@@ -0,0 +1,68 @@
+/*
+ *  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.process.computer.traversal.strategy;
+
+import org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.step.map.HadoopReadStep;
+import org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.step.map.HadoopWriteStep;
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Writing;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class HadoopIoStrategy extends AbstractTraversalStrategy<TraversalStrategy.ProviderOptimizationStrategy>
+        implements TraversalStrategy.ProviderOptimizationStrategy {
+
+    private static final HadoopIoStrategy INSTANCE = new HadoopIoStrategy();
+
+    private HadoopIoStrategy() {
+    }
+
+    @Override
+    public void apply(final Traversal.Admin<?, ?> traversal) {
+        // replace Reading and Writing steps with hadoop specific ones
+        if (traversal.getStartStep() instanceof Reading) {
+            final Reading reading = (Reading) traversal.getStartStep();
+            final HadoopReadStep hadoopReadStep = new HadoopReadStep(traversal, reading.getLocalFile());
+            reading.getParameters().getRaw().entrySet().forEach(kv ->
+                hadoopReadStep.configure(null, kv.getKey(), kv.getValue())
+            );
+
+            TraversalHelper.replaceStep((Step) reading, hadoopReadStep, traversal);
+        } else if (traversal.getStartStep() instanceof Writing) {
+            final Writing writing = (Writing) traversal.getStartStep();
+            final HadoopWriteStep hadoopWriteStep = new HadoopWriteStep(traversal, writing.getLocalFile());
+            writing.getParameters().getRaw().entrySet().forEach(kv ->
+                hadoopWriteStep.configure(null, kv.getKey(), kv.getValue())
+            );
+
+            TraversalHelper.replaceStep((Step) writing, hadoopWriteStep, traversal);
+        }
+    }
+
+    public static HadoopIoStrategy instance() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0785090f/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
index ea8334b..14c5360 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
@@ -24,9 +24,11 @@ import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.tinkerpop.gremlin.hadoop.Constants;
 import org.apache.tinkerpop.gremlin.hadoop.process.computer.AbstractHadoopGraphComputer;
+import org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.strategy.HadoopIoStrategy;
 import org.apache.tinkerpop.gremlin.hadoop.structure.io.HadoopEdgeIterator;
 import org.apache.tinkerpop.gremlin.hadoop.structure.io.HadoopVertexIterator;
 import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Transaction;
@@ -148,6 +150,12 @@ public final class HadoopGraph implements Graph {
         this.setProperty(Graph.GRAPH, HadoopGraph.class.getName());
     }};
 
+    static {
+        TraversalStrategies.GlobalCache.registerStrategies(HadoopGraph.class,
+                TraversalStrategies.GlobalCache.getStrategies(Graph.class).clone().addStrategies(
+                        HadoopIoStrategy.instance()));
+    }
+
     protected final HadoopConfiguration configuration;
 
     private HadoopGraph(final Configuration configuration) {


[11/38] tinkerpop git commit: TINKERPOP-1996 Fixed a bad method call for Configuring steps

Posted by sp...@apache.org.
TINKERPOP-1996 Fixed a bad method call for Configuring steps


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

Branch: refs/heads/master
Commit: 9e4da0149247a50277e2a468b0becf892426ce2e
Parents: ae79637
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 13 11:37:02 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:40:09 2018 -0400

----------------------------------------------------------------------
 .../process/computer/traversal/strategy/HadoopIoStrategy.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9e4da014/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
index 89ee04b..6d3899e 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
@@ -55,7 +55,7 @@ public final class HadoopIoStrategy extends AbstractTraversalStrategy<TraversalS
             final HadoopIoStep hadoopIoStep = new HadoopIoStep(traversal, readWriting.getFile());
             hadoopIoStep.setMode(readWriting.getMode());
             readWriting.getParameters().getRaw().entrySet().forEach(kv ->
-                    hadoopIoStep.configure(null, kv.getKey(), kv.getValue())
+                    hadoopIoStep.configure(kv.getKey(), kv.getValue())
             );
 
             TraversalHelper.replaceStep((Step) readWriting, hadoopIoStep, traversal);


[04/38] tinkerpop git commit: TINKERPOP-1996 Minor refactoring of Reading/Writing and javadoc

Posted by sp...@apache.org.
TINKERPOP-1996 Minor refactoring of Reading/Writing and javadoc


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

Branch: refs/heads/master
Commit: ff2773a5ef1eff379cb5f3b809d4677ff64a076d
Parents: 0785090
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 10 12:55:06 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:39:29 2018 -0400

----------------------------------------------------------------------
 .../gremlin/process/traversal/step/Reading.java |  7 ++++-
 .../gremlin/process/traversal/step/Writing.java |  8 +++++-
 .../process/traversal/step/map/ReadStep.java    | 27 ++++++++++----------
 .../process/traversal/step/map/WriteStep.java   | 25 +++++++++---------
 .../traversal/step/map/HadoopReadStep.java      |  2 +-
 .../traversal/step/map/HadoopWriteStep.java     |  2 +-
 .../traversal/strategy/HadoopIoStrategy.java    |  4 +--
 7 files changed, 42 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff2773a5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java
index b79378b..3f7c714 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Reading.java
@@ -19,9 +19,14 @@
 package org.apache.tinkerpop.gremlin.process.traversal.step;
 
 /**
+ * An interface for describing steps that will read a graph from some specified location.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public interface Reading extends Configuring {
 
-    public String getLocalFile();
+    /**
+     * Get the file location to read from.
+     */
+    public String getFile();
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff2773a5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java
index 7b455f2..fe56363 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Writing.java
@@ -19,8 +19,14 @@
 package org.apache.tinkerpop.gremlin.process.traversal.step;
 
 /**
+ * An interface for describing steps that will write a graph to some specified location.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public interface Writing extends Configuring {
-    public String getLocalFile();
+
+    /**
+     * Get the file location to write to.
+     */
+    public String getFile();
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff2773a5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
index 2612d18..7c71ab5 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
@@ -21,7 +21,6 @@ package org.apache.tinkerpop.gremlin.process.traversal.step.map;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator;
-import org.apache.tinkerpop.gremlin.process.traversal.step.Configuring;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
@@ -48,20 +47,20 @@ public class ReadStep extends AbstractStep<Map<String,Object>, Map<String,Object
 
     private Parameters parameters = new Parameters();
     private boolean first = true;
-    private String localFile;
+    private String file;
 
-    public ReadStep(final Traversal.Admin traversal, final String localFile) {
+    public ReadStep(final Traversal.Admin traversal, final String file) {
         super(traversal);
 
-        if (null == localFile || localFile.isEmpty())
-            throw new IllegalArgumentException("localFile cannot be null or empty");
+        if (null == file || file.isEmpty())
+            throw new IllegalArgumentException("file cannot be null or empty");
 
-        this.localFile = localFile;
+        this.file = file;
     }
 
     @Override
-    public String getLocalFile() {
-        return localFile;
+    public String getFile() {
+        return file;
     }
 
     @Override
@@ -80,8 +79,8 @@ public class ReadStep extends AbstractStep<Map<String,Object>, Map<String,Object
 
         this.first = false;
         final TraverserGenerator generator = this.getTraversal().getTraverserGenerator();
-        final File file = new File(localFile);
-        if (!file.exists()) throw new IllegalStateException(localFile + " does not exist");
+        final File file = new File(this.file);
+        if (!file.exists()) throw new IllegalStateException(this.file + " does not exist");
 
         try (final InputStream stream = new FileInputStream(file)) {
             final Graph graph = (Graph) this.traversal.getGraph().get();
@@ -93,26 +92,26 @@ public class ReadStep extends AbstractStep<Map<String,Object>, Map<String,Object
 
             return generator.generate(stats, this, 1L);
         } catch (IOException ioe) {
-            throw new IllegalStateException(String.format("Could not read file %s into graph", localFile), ioe);
+            throw new IllegalStateException(String.format("Could not read file %s into graph", this.file), ioe);
         }
     }
 
     @Override
     public int hashCode() {
         final int hash = super.hashCode() ^ this.parameters.hashCode();
-        return (null != this.localFile) ? (hash ^ localFile.hashCode()) : hash;
+        return (null != this.file) ? (hash ^ file.hashCode()) : hash;
     }
 
     @Override
     public String toString() {
-        return StringFactory.stepString(this, localFile, this.parameters);
+        return StringFactory.stepString(this, file, this.parameters);
     }
 
     @Override
     public ReadStep clone() {
         final ReadStep clone = (ReadStep) super.clone();
         clone.parameters = this.parameters.clone();
-        clone.localFile = this.localFile;
+        clone.file = this.file;
         return clone;
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff2773a5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
index 3a035e7..d27cd24 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
@@ -21,7 +21,6 @@ package org.apache.tinkerpop.gremlin.process.traversal.step.map;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator;
-import org.apache.tinkerpop.gremlin.process.traversal.step.Configuring;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Writing;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
@@ -48,20 +47,20 @@ public class WriteStep extends AbstractStep<Map<String,Object>, Map<String,Objec
 
     private Parameters parameters = new Parameters();
     private boolean first = true;
-    private String localFile;
+    private String file;
 
-    public WriteStep(final Traversal.Admin traversal, final String localFile) {
+    public WriteStep(final Traversal.Admin traversal, final String file) {
         super(traversal);
 
-        if (null == localFile || localFile.isEmpty())
-            throw new IllegalArgumentException("localFile cannot be null or empty");
+        if (null == file || file.isEmpty())
+            throw new IllegalArgumentException("file cannot be null or empty");
 
-        this.localFile = localFile;
+        this.file = file;
     }
 
     @Override
-    public String getLocalFile() {
-        return localFile;
+    public String getFile() {
+        return file;
     }
 
     @Override
@@ -81,7 +80,7 @@ public class WriteStep extends AbstractStep<Map<String,Object>, Map<String,Objec
         this.first = false;
         final TraverserGenerator generator = this.getTraversal().getTraverserGenerator();
 
-        final File file = new File(localFile);
+        final File file = new File(this.file);
         try (final OutputStream stream = new FileOutputStream(file)) {
             final Graph graph = (Graph) this.traversal.getGraph().get();
             GryoWriter.build().create().writeGraph(stream, graph);
@@ -92,26 +91,26 @@ public class WriteStep extends AbstractStep<Map<String,Object>, Map<String,Objec
 
             return generator.generate(stats, this, 1L);
         } catch (IOException ioe) {
-            throw new IllegalStateException(String.format("Could not write file %s from graph", localFile), ioe);
+            throw new IllegalStateException(String.format("Could not write file %s from graph", this.file), ioe);
         }
     }
 
     @Override
     public int hashCode() {
         final int hash = super.hashCode() ^ this.parameters.hashCode();
-        return (null != this.localFile) ? (hash ^ localFile.hashCode()) : hash;
+        return (null != this.file) ? (hash ^ file.hashCode()) : hash;
     }
 
     @Override
     public String toString() {
-        return StringFactory.stepString(this, localFile, this.parameters);
+        return StringFactory.stepString(this, file, this.parameters);
     }
 
     @Override
     public WriteStep clone() {
         final WriteStep clone = (WriteStep) super.clone();
         clone.parameters = this.parameters.clone();
-        clone.localFile = this.localFile;
+        clone.file = this.file;
         return clone;
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff2773a5/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java
index c896d76..1ec3d38 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopReadStep.java
@@ -45,7 +45,7 @@ public class HadoopReadStep extends VertexProgramStep implements Reading {
     }
 
     @Override
-    public String getLocalFile() {
+    public String getFile() {
         return (String) ((Graph) traversal.getGraph().get()).configuration().getProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION);
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff2773a5/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java
index 0711a2e..2bb8e67 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopWriteStep.java
@@ -45,7 +45,7 @@ public class HadoopWriteStep extends VertexProgramStep implements Reading {
     }
 
     @Override
-    public String getLocalFile() {
+    public String getFile() {
         return (String) ((Graph) traversal.getGraph().get()).configuration().getProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION);
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff2773a5/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
index 47986f9..d8d8bab 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
@@ -45,7 +45,7 @@ public final class HadoopIoStrategy extends AbstractTraversalStrategy<TraversalS
         // replace Reading and Writing steps with hadoop specific ones
         if (traversal.getStartStep() instanceof Reading) {
             final Reading reading = (Reading) traversal.getStartStep();
-            final HadoopReadStep hadoopReadStep = new HadoopReadStep(traversal, reading.getLocalFile());
+            final HadoopReadStep hadoopReadStep = new HadoopReadStep(traversal, reading.getFile());
             reading.getParameters().getRaw().entrySet().forEach(kv ->
                 hadoopReadStep.configure(null, kv.getKey(), kv.getValue())
             );
@@ -53,7 +53,7 @@ public final class HadoopIoStrategy extends AbstractTraversalStrategy<TraversalS
             TraversalHelper.replaceStep((Step) reading, hadoopReadStep, traversal);
         } else if (traversal.getStartStep() instanceof Writing) {
             final Writing writing = (Writing) traversal.getStartStep();
-            final HadoopWriteStep hadoopWriteStep = new HadoopWriteStep(traversal, writing.getLocalFile());
+            final HadoopWriteStep hadoopWriteStep = new HadoopWriteStep(traversal, writing.getFile());
             writing.getParameters().getRaw().entrySet().forEach(kv ->
                 hadoopWriteStep.configure(null, kv.getKey(), kv.getValue())
             );


[29/38] tinkerpop git commit: TINKERPOP-1996 Added upgrade docs

Posted by sp...@apache.org.
TINKERPOP-1996 Added upgrade docs


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

Branch: refs/heads/master
Commit: ded7c187480a68b6f7be2d0cb777461f57a2871c
Parents: 8fd3bf2
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 20 11:20:03 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 20 11:20:03 2018 -0400

----------------------------------------------------------------------
 docs/src/upgrade/release-3.4.x.asciidoc | 49 ++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ded7c187/docs/src/upgrade/release-3.4.x.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.4.x.asciidoc b/docs/src/upgrade/release-3.4.x.asciidoc
index 97e14e3..0bb3903 100644
--- a/docs/src/upgrade/release-3.4.x.asciidoc
+++ b/docs/src/upgrade/release-3.4.x.asciidoc
@@ -36,7 +36,7 @@ modulator. This modulator allows the step it is modifying to accept configuratio
 behavior of the step itself. A good example of its usage is shown with the revised syntax of the `pageRank()` step
 which now uses `with()` to replace the old `by()` options:
 
-[groovy]
+[source,groovy]
 ----
 g.V().hasLabel('person').
   pageRank().
@@ -49,7 +49,7 @@ g.V().hasLabel('person').
 
 A similar change was made for `peerPressure()` step:
 
-[groovy]
+[source,groovy]
 ----
 g.V().hasLabel('person').
   peerPressure().
@@ -65,6 +65,33 @@ release where breaking changes are allowed.
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1975[TINKERPOP-1975],
 link:http://tinkerpop.apache.org/docs/3.4.0/reference/#with-step[Reference Documentation]
 
+==== io() Step
+
+There have been some important changes to IO operations for reading and writing graph data. The use of `Graph.io()`
+has been deprecated to further remove dependence on the Graph (Structure) API for users and to extend these basic
+operations to GLV users by making these features available as part of the Gremlin language.
+
+It is now possible to simply use Gremlin:
+
+[source,groovy]
+----
+graph = ...
+g = graph.traversal()
+g.io(someInputFile).read().iterate()
+g.io(someOutputFile).write().iterate()
+----
+
+While `io()` step is still single-threaded for OLTP style loading, it can be utilized in conjunction with OLAP which
+internally uses `CloneVertexProgram` and therefore any graph `InputFormat` or `OutputFormat` can be configured in
+conjunction with this step for parallel loads of large datasets.
+
+It is also worth noting that the `io()`-step may be overriden by graph providers to utilize their native bulk-loading
+features, so consult the documentation of the implementation being used to determine if there are any improved
+efficiencies there.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1996[TINKERPOP-1996],
+link:http://tinkerpop.apache.org/docs/3.4.0/reference/#io-step[Reference Documentation]
+
 ==== Removal of Giraph Support
 
 Support for Giraph has been removed as of this version. There were a number of reasons for this decision which were
@@ -284,6 +311,24 @@ See: link:https://issues.apache.org/jira/browse/TINKERPOP-1522[TINKERPOP-1522]
 
 ==== Graph Database Providers
 
+===== io() Step
+
+The new `io()`-step that was introduced provides some new changes to consider. Note that `Graph.io()` has been
+deprecated and users are no longer instructed to utilize that method. It is not yet decided when that method will be
+removed completely, but given the public nature of it and the high chance of common usage, it should be hanging around
+for some time.
+
+As with any step in Gremlin, it is possible to replace it with a more provider specific implementation that could be
+more efficient. Developing a `TraversalStrategy` to do this is encouraged, especially for those graph providers who
+might have special bulk loaders that could be abstracted by this step. Examples of this are already shown with
+`HadoopGraph` which replaces the simple single-threaded loader with `CloneVertexProgram`. Graph providers are
+encouraged to use the `with()` step to capture any necessary configurations required for their underlying loader to
+work. Graph providers should not feel restricted to `graphson`, `gryo` and `graphml` formats either. If a graph
+supports CSV or some custom graph specific format, it shouldn't be difficult to gather the configurations necessary to
+make that available to users.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1996[TINKERPOP-1996]
+
 ===== Caching Graph Features
 
 For graph implementations that have expensive creation times, it can be time consuming to run the TinkerPop test suite


[10/38] tinkerpop git commit: TINKERPOP-1996 Removed OptOuts for read()/write() tests

Posted by sp...@apache.org.
TINKERPOP-1996 Removed OptOuts for read()/write() tests

Not necessary because existing checks ignore these. For read() you can't write to a HadoopGraph directly (i.e. create vertices/edges) and for write() (and technically read()) it is ignored as it requires a GraphComputer to work.


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

Branch: refs/heads/master
Commit: bd275a7ffa4f0d04634c830aa4f7577375c7944c
Parents: 9e4da01
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 13 11:37:21 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:40:09 2018 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/hadoop/structure/HadoopGraph.java   | 10 ----------
 1 file changed, 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bd275a7f/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
index 5935ebf..14c5360 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
@@ -142,16 +142,6 @@ import java.util.stream.Stream;
         method = "g_V_matchXa_followedBy_count_isXgtX10XX_b__a_0followedBy_count_isXgtX10XX_bX_count",
         reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
         computers = {"ALL"})
-@Graph.OptOut(
-        test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest$Traversals",
-        method = "*",
-        reason = "This body of tests is not configured to properly suit OLAP based testing and HadoopGraph is not designed to handle single-threaded OLTP reads/writes.",
-        computers = {"ALL"})
-@Graph.OptOut(
-        test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest$Traversals",
-        method = "*",
-        reason = "This body of tests is not configured to properly suit OLAP based testing and HadoopGraph is not designed to handle single-threaded OLTP reads/writes.",
-        computers = {"ALL"})
 public final class HadoopGraph implements Graph {
 
     public static final Logger LOGGER = LoggerFactory.getLogger(HadoopGraph.class);


[15/38] tinkerpop git commit: TINKERPOP-1996 Updated changelog

Posted by sp...@apache.org.
TINKERPOP-1996 Updated changelog


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

Branch: refs/heads/master
Commit: 576649fd5456f6390bf9481d01438a7e78db083e
Parents: f148e93
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 13 15:22:43 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:40:10 2018 -0400

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


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/576649fd/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index bc78bbe..1add03c 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -28,6 +28,7 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
 * Bumped to Netty 4.1.25.
 * Bumped to Spark 2.3.1.
 * Added the `io()` start step and `read()` and `write()` termination steps to the Gremlin language.
+* Added `GraphFeatures.supportsIoRead()` and `GraphFeatures.supportsIoWrite()`.
 * Deprecated `Graph.io()` and related infrastructure.
 * Moved `Parameterizing` interface to the `org.apache.tinkerpop.gremlin.process.traversal.step` package with other marker interfaces of its type.
 * Replaced `Parameterizing.addPropertyMutations()` with `Configuring.configure()`.


[02/38] tinkerpop git commit: TINKERPOP-1996 Added some javadoc and code formatting

Posted by sp...@apache.org.
TINKERPOP-1996 Added some javadoc and code formatting


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

Branch: refs/heads/master
Commit: d181563d24a401ac6550e06d86d78b12a8f16f51
Parents: 767d65b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jul 11 10:36:11 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:39:29 2018 -0400

----------------------------------------------------------------------
 .../traversal/dsl/graph/GraphTraversalSource.java     | 14 ++++++++++++++
 .../gremlin/process/traversal/step/ReadWriting.java   |  8 ++++++++
 .../gremlin/process/traversal/step/map/IoStep.java    |  2 ++
 .../computer/traversal/step/map/HadoopIoStep.java     |  4 ++++
 .../computer/traversal/strategy/HadoopIoStrategy.java |  7 +++++++
 .../tinkergraph/structure/TinkerGraphPlayTest.java    |  2 --
 6 files changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d181563d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
index aa4995d..7357418 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
@@ -391,6 +391,20 @@ public class GraphTraversalSource implements TraversalSource {
         return traversal.addStep(new GraphStep<>(traversal, Edge.class, true, edgesIds));
     }
 
+    /**
+     * Performs a read or write based operation on the {@link Graph} backing this {@code GraphTraversalSource}. This
+     * step can be accompanied by the {@link GraphTraversal#with(String, Object)} modulator for further configuration
+     * and must be accompanied by a {@link GraphTraversal#read()} or {@link GraphTraversal#write()} modulator step
+     * which will terminate the traversal.
+     *
+     * @param file the name of file for which the read or write will apply - note that the context of how this
+     *             parameter is used is wholly dependent on the implementation
+     * @return the traversal with the {@link IoStep} added
+     * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#io-step" target="_blank">Reference Documentation - IO Step</a>
+     * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#read-step" target="_blank">Reference Documentation - Read Step</a>
+     * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#write-step" target="_blank">Reference Documentation - Write Step</a>
+     * @since 3.4.0
+     */
     public <S> GraphTraversal<S, S> io(final String file) {
         final GraphTraversalSource clone = this.clone();
         clone.bytecode.addStep(GraphTraversal.Symbols.io, file);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d181563d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ReadWriting.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ReadWriting.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ReadWriting.java
index 18de925..d0e8bbf 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ReadWriting.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ReadWriting.java
@@ -18,11 +18,19 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.step;
 
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+
 /**
+ * An interface that defines a {@link Step} as one that handles IO based operations for a {@link Graph}.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public interface ReadWriting extends Configuring {
 
+    /**
+     * Determines the mode of the the IO operation as being for reading or writing (or by default "unset")
+     */
     public enum Mode {
         UNSET,
         READING,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d181563d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
index 8d22427..b633360 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/IoStep.java
@@ -38,6 +38,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 /**
+ * Handles read and write operations into the {@link Graph}.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class IoStep<S> extends AbstractStep<S,S> implements ReadWriting {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d181563d/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
index 83a95e0..62937da 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/step/map/HadoopIoStep.java
@@ -24,12 +24,16 @@ import org.apache.tinkerpop.gremlin.process.computer.Memory;
 import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.step.ReadWriting;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
 /**
+ * An OLAP oriented step for doing IO operations with {@link GraphTraversalSource#io(String)} which uses the
+ * {@link CloneVertexProgram} for its implementation.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class HadoopIoStep extends VertexProgramStep implements ReadWriting {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d181563d/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
index 1805df8..38d5a7f 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
@@ -20,6 +20,8 @@
 package org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.strategy;
 
 import org.apache.tinkerpop.gremlin.hadoop.process.computer.traversal.step.map.HadoopIoStep;
+import org.apache.tinkerpop.gremlin.process.computer.clone.CloneVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.VertexProgramStep;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
@@ -30,6 +32,11 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversal
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 
 /**
+ * The default implementation of the {@link IoStep} is a single threaded operation and doesn't properly take into
+ * account the method by which OLAP read/writes take place with Hadoop. This strategy removes that step and replaces
+ * it with the {@link HadoopIoStep} which is a {@link VertexProgramStep} that uses the {@link CloneVertexProgram} to
+ * execute the IO operation in an OLAP fashion.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public final class HadoopIoStrategy extends AbstractTraversalStrategy<TraversalStrategy.ProviderOptimizationStrategy>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d181563d/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
index 69062ef..598e434 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
@@ -20,9 +20,7 @@ package org.apache.tinkerpop.gremlin.tinkergraph.structure;
 
 import org.apache.tinkerpop.gremlin.process.computer.Computer;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
-import org.apache.tinkerpop.gremlin.process.traversal.Pop;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;


[07/38] tinkerpop git commit: TINKERPOP-1996 read()/write() api changes for return type

Posted by sp...@apache.org.
TINKERPOP-1996 read()/write() api changes for return type

No more weird Map status return for read() and write(). Both just work like a terminator and self iterate to return nothing.


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

Branch: refs/heads/master
Commit: d99909c4e19fcb3ec3b8a8c94eb054a4332ad219
Parents: ff2773a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 10 14:53:52 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 13:39:29 2018 -0400

----------------------------------------------------------------------
 .../traversal/dsl/graph/GraphTraversalSource.java | 18 ++++++++++--------
 .../process/traversal/step/map/ReadStep.java      | 12 ++++--------
 .../process/traversal/step/map/WriteStep.java     | 13 ++++---------
 .../strategy/verification/IoUsageStrategy.java    | 10 ++++++++--
 .../Process/Traversal/GraphTraversalSource.cs     | 12 ++++++------
 .../traversal/strategy/HadoopIoStrategy.java      |  4 ++++
 .../structure/TinkerGraphPlayTest.java            | 10 ++++++++++
 7 files changed, 46 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d99909c4/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
index 9b82108..49e012f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
 import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
 import org.apache.tinkerpop.gremlin.process.remote.traversal.strategy.decoration.RemoteStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
@@ -43,6 +44,7 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
 import java.util.Map;
+import java.util.NoSuchElementException;
 import java.util.Optional;
 import java.util.function.BinaryOperator;
 import java.util.function.Supplier;
@@ -393,18 +395,18 @@ public class GraphTraversalSource implements TraversalSource {
         return traversal.addStep(new GraphStep<>(traversal, Edge.class, true, edgesIds));
     }
 
-    public GraphTraversal<Map<String,Object>, Map<String,Object>> read(final String localFile) {
+    public <S> GraphTraversal<S, S> read(final String file) {
         final GraphTraversalSource clone = this.clone();
-        clone.bytecode.addStep(GraphTraversal.Symbols.read, localFile);
-        final GraphTraversal.Admin<Map<String,Object>, Map<String,Object>> traversal = new DefaultGraphTraversal<>(clone);
-        return traversal.addStep(new ReadStep(traversal, localFile));
+        clone.bytecode.addStep(GraphTraversal.Symbols.read, file);
+        final GraphTraversal.Admin<S,S> traversal = new DefaultGraphTraversal<>(clone);
+        return traversal.addStep(new ReadStep<S>(traversal, file)).iterate();
     }
 
-    public GraphTraversal<Map<String,Object>, Map<String,Object>> write(final String localFile) {
+    public <S> GraphTraversal<S, S> write(final String file) {
         final GraphTraversalSource clone = this.clone();
-        clone.bytecode.addStep(GraphTraversal.Symbols.write, localFile);
-        final GraphTraversal.Admin<Map<String,Object>, Map<String,Object>> traversal = new DefaultGraphTraversal<>(clone);
-        return traversal.addStep(new WriteStep(traversal, localFile));
+        clone.bytecode.addStep(GraphTraversal.Symbols.write, file);
+        final GraphTraversal.Admin<S,S> traversal = new DefaultGraphTraversal<>(clone);
+        return traversal.addStep(new WriteStep<S>(traversal, file)).iterate();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d99909c4/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
index 7c71ab5..99f7e66 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ReadStep.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.EmptyTraverser;
 import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
@@ -43,7 +44,7 @@ import java.util.Map;
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
-public class ReadStep extends AbstractStep<Map<String,Object>, Map<String,Object>> implements Reading {
+public class ReadStep<S> extends AbstractStep<S,S> implements Reading {
 
     private Parameters parameters = new Parameters();
     private boolean first = true;
@@ -74,11 +75,10 @@ public class ReadStep extends AbstractStep<Map<String,Object>, Map<String,Object
     }
 
     @Override
-    protected Traverser.Admin<Map<String,Object>> processNextStart() {
+    protected Traverser.Admin<S> processNextStart() {
         if (!this.first) throw FastNoSuchElementException.instance();
 
         this.first = false;
-        final TraverserGenerator generator = this.getTraversal().getTraverserGenerator();
         final File file = new File(this.file);
         if (!file.exists()) throw new IllegalStateException(this.file + " does not exist");
 
@@ -86,11 +86,7 @@ public class ReadStep extends AbstractStep<Map<String,Object>, Map<String,Object
             final Graph graph = (Graph) this.traversal.getGraph().get();
             GryoReader.build().create().readGraph(stream, graph);
 
-            final Map<String,Object> stats = new LinkedHashMap<>();
-            stats.put("vertices", IteratorUtils.count(graph.vertices()));
-            stats.put("edges", IteratorUtils.count(graph.edges()));
-
-            return generator.generate(stats, this, 1L);
+            return EmptyTraverser.instance();
         } catch (IOException ioe) {
             throw new IllegalStateException(String.format("Could not read file %s into graph", this.file), ioe);
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d99909c4/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
index d27cd24..20ffec9 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/WriteStep.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Writing;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Parameters;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.EmptyTraverser;
 import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
@@ -43,7 +44,7 @@ import java.util.Map;
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
-public class WriteStep extends AbstractStep<Map<String,Object>, Map<String,Object>> implements Writing {
+public class WriteStep<S> extends AbstractStep<S,S> implements Writing {
 
     private Parameters parameters = new Parameters();
     private boolean first = true;
@@ -74,22 +75,16 @@ public class WriteStep extends AbstractStep<Map<String,Object>, Map<String,Objec
     }
 
     @Override
-    protected Traverser.Admin<Map<String,Object>> processNextStart() {
+    protected Traverser.Admin<S> processNextStart() {
         if (!this.first) throw FastNoSuchElementException.instance();
 
         this.first = false;
-        final TraverserGenerator generator = this.getTraversal().getTraverserGenerator();
-
         final File file = new File(this.file);
         try (final OutputStream stream = new FileOutputStream(file)) {
             final Graph graph = (Graph) this.traversal.getGraph().get();
             GryoWriter.build().create().writeGraph(stream, graph);
 
-            final Map<String, Object> stats = new LinkedHashMap<>();
-            stats.put("vertices", IteratorUtils.count(graph.vertices()));
-            stats.put("edges", IteratorUtils.count(graph.edges()));
-
-            return generator.generate(stats, this, 1L);
+            return EmptyTraverser.instance();
         } catch (IOException ioe) {
             throw new IllegalStateException(String.format("Could not write file %s from graph", this.file), ioe);
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d99909c4/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
index e9c7ec8..b4a0669 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/IoUsageStrategy.java
@@ -18,10 +18,12 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.strategy.verification;
 
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
@@ -52,8 +54,12 @@ public final class IoUsageStrategy extends AbstractTraversalStrategy<TraversalSt
 
     @Override
     public void apply(final Traversal.Admin<?, ?> traversal) {
-        if ((traversal.getStartStep() instanceof ReadStep || traversal.getStartStep() instanceof WriteStep) && traversal.getSteps().size() > 1) {
-            throw new VerificationException("The read() or write() steps must be the first and only step in the traversal - they cannot be used with other steps", traversal);
+        final Step start = traversal.getStartStep();
+        final Step end = traversal.getEndStep();
+        if ((start instanceof ReadStep || start instanceof WriteStep) && end != start) {
+            if ((end instanceof NoneStep && traversal.getSteps().size() > 2)) {
+                throw new VerificationException("The read() or write() steps must be the first and only step in the traversal - they cannot be used with other steps", traversal);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d99909c4/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
index 630ac28..4292850 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs
@@ -337,10 +337,10 @@ namespace Gremlin.Net.Process.Traversal
         ///     Spawns a <see cref="GraphTraversal{SType, EType}" /> off this graph traversal source and adds the read step to that
         ///     traversal.
         /// </summary>
-        public GraphTraversal<IDictionary<string, object>, IDictionary<string, object>> Read(string localFile)
+        public GraphTraversal<S, S> Read<S>(string file)
         {
-            var traversal = new GraphTraversal<IDictionary<string, object>, IDictionary<string, object>>(TraversalStrategies, new Bytecode(Bytecode));
-                traversal.Bytecode.AddStep("read", localFile);
+            var traversal = new GraphTraversal<S, S>(TraversalStrategies, new Bytecode(Bytecode));
+                traversal.Bytecode.AddStep("read", file);
             return traversal;
         }
 
@@ -348,10 +348,10 @@ namespace Gremlin.Net.Process.Traversal
         ///     Spawns a <see cref="GraphTraversal{SType, EType}" /> off this graph traversal source and adds the write step to that
         ///     traversal.
         /// </summary>
-        public GraphTraversal<IDictionary<string, object>, IDictionary<string, object>> Write(string localFile)
+        public GraphTraversal<S, S> Write<S>(string file)
         {
-            var traversal = new GraphTraversal<IDictionary<string, object>, IDictionary<string, object>>(TraversalStrategies, new Bytecode(Bytecode));
-                traversal.Bytecode.AddStep("write", localFile);
+            var traversal = new GraphTraversal<S, S>(TraversalStrategies, new Bytecode(Bytecode));
+                traversal.Bytecode.AddStep("write", file);
             return traversal;
         }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d99909c4/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
index d8d8bab..7e0e23c 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/traversal/strategy/HadoopIoStrategy.java
@@ -26,6 +26,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Reading;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Writing;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 
@@ -60,6 +61,9 @@ public final class HadoopIoStrategy extends AbstractTraversalStrategy<TraversalS
 
             TraversalHelper.replaceStep((Step) writing, hadoopWriteStep, traversal);
         }
+
+        if (traversal.getEndStep() instanceof NoneStep)
+            traversal.removeStep(1);
     }
 
     public static HadoopIoStrategy instance() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d99909c4/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
index e0018fc..82bf2d7 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
@@ -28,6 +28,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathRetractionStrategy;
 import org.apache.tinkerpop.gremlin.structure.*;
+import org.apache.tinkerpop.gremlin.structure.io.IoTest;
 import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo;
 import org.apache.tinkerpop.gremlin.util.TimeUtil;
 import org.junit.Ignore;
@@ -334,4 +335,13 @@ public class TinkerGraphPlayTest {
         System.out.println(g.V().as("a").both().as("b").dedup("a", "b").by(T.label).select("a", "b").toList());
 
     }
+
+    @Test
+    public void testBlah() {
+        TinkerGraph graph = TinkerGraph.open();
+        GraphTraversalSource g = graph.traversal();
+        g.read("../data/tinkerpop-modern.kryo");
+
+        IoTest.assertModernGraph(graph, true, false);
+    }
 }


[23/38] tinkerpop git commit: TINKERPOP-1996 Added support for setting IoRegistries using with()

Posted by sp...@apache.org.
TINKERPOP-1996 Added support for setting IoRegistries using with()

IORegistry instances are important because they feed serializer information to the Reader/Writer instances. Of all the configuration options that one seemed like the most important to make possible using with().


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

Branch: refs/heads/master
Commit: ff71c6abee0b39d7ee95128c3d64906daad96a76
Parents: ae3b149
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jul 19 16:13:57 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 19 16:13:57 2018 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/process/traversal/IO.java |  7 ++
 .../traversal/step/sideEffect/IoStep.java       | 75 ++++++++++++--------
 .../process/traversal/step/util/Parameters.java |  4 +-
 .../Process/Traversal/GraphTraversal.cs         | 21 ++----
 .../src/Gremlin.Net/Process/Traversal/IO.cs     |  2 +
 .../gremlin-javascript/lib/process/traversal.js |  4 ++
 .../jython/gremlin_python/process/traversal.py  |  2 +
 .../gremlin/structure/io/util/CustomId.java     | 39 ++++++++++
 .../step/sideEffect/TinkerGraphIoStepTest.java  | 75 ++++++++++++++++++++
 9 files changed, 181 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff71c6ab/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java
index 6668cf1..67b4670 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/IO.java
@@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
 import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
+import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
 import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader;
 import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
@@ -73,4 +74,10 @@ public class IO {
      * the file extension provided to it.
      */
     public static final String writer = Graph.Hidden.hide("tinkerpop.io.writer");
+
+    /**
+     * A key that identifies the fully qualified class names of {@link IoRegistry} instances to use. May be specified
+     * multiple times (i.e. once for each registry) using the {@link GraphTraversal#with(String, Object)} modulator.
+     */
+    public static final String registry = Graph.Hidden.hide("tinkerpop.io.registry");
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff71c6ab/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
index 9804333..1d4f40b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/IoStep.java
@@ -31,10 +31,13 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementExce
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
 import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
+import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
 import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader;
 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.GraphSONReader;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
 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.StringFactory;
@@ -46,6 +49,9 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * Handles read and write operations into the {@link Graph}.
@@ -138,15 +144,19 @@ public class IoStep<S> extends AbstractStep<S,S> implements ReadWriting {
      * extension or simply uses configurations provided by the user on the parameters given to the step.
      */
     private GraphReader constructReader() {
-        final Object objectOrClass = parameters.get(IO.reader, this::detectReader).get(0);
+        final Object objectOrClass = parameters.get(IO.reader, this::detectFileType).get(0);
         if (objectOrClass instanceof GraphReader)
             return (GraphReader) objectOrClass;
         else if (objectOrClass instanceof String) {
-            if (objectOrClass.equals(IO.graphson))
-                return GraphSONReader.build().create();
-            else if (objectOrClass.equals(IO.gryo))
-                return GryoReader.build().create();
-            else if (objectOrClass.equals(IO.graphml))
+            if (objectOrClass.equals(IO.graphson)) {
+                final GraphSONMapper.Builder builder = GraphSONMapper.build();
+                detectRegistries().forEach(builder::addRegistry);
+                return GraphSONReader.build().mapper(builder.create()).create();
+            } else if (objectOrClass.equals(IO.gryo)){
+                final GryoMapper.Builder builder = GryoMapper.build();
+                detectRegistries().forEach(builder::addRegistry);
+                return GryoReader.build().mapper(builder.create()).create();
+            } else if (objectOrClass.equals(IO.graphml))
                 return GraphMLReader.build().create();
             else {
                 try {
@@ -163,31 +173,24 @@ public class IoStep<S> extends AbstractStep<S,S> implements ReadWriting {
         }
     }
 
-    private GraphReader detectReader() {
-        if (file.endsWith(".kryo"))
-            return GryoReader.build().create();
-        else if (file.endsWith(".json"))
-            return GraphSONReader.build().create();
-        else if (file.endsWith(".xml"))
-            return GraphMLReader.build().create();
-        else
-            throw new IllegalStateException("Could not detect the file format - specify the reader explicitly or rename file with a standard extension");
-    }
-
     /**
      * Builds a {@link GraphWriter} instance to use. Attempts to detect the file format to be write using the file
      * extension or simply uses configurations provided by the user on the parameters given to the step.
      */
     private GraphWriter constructWriter() {
-        final Object objectOrClass = parameters.get(IO.writer, this::detectWriter).get(0);
+        final Object objectOrClass = parameters.get(IO.writer, this::detectFileType).get(0);
         if (objectOrClass instanceof GraphWriter)
             return (GraphWriter) objectOrClass;
         else if (objectOrClass instanceof String) {
-            if (objectOrClass.equals(IO.graphson))
-                return GraphSONWriter.build().create();
-            else if (objectOrClass.equals(IO.gryo))
-                return GryoWriter.build().create();
-            else if (objectOrClass.equals(IO.graphml))
+            if (objectOrClass.equals(IO.graphson)) {
+                final GraphSONMapper.Builder builder = GraphSONMapper.build();
+                detectRegistries().forEach(builder::addRegistry);
+                return GraphSONWriter.build().mapper(builder.create()).create();
+            } else if (objectOrClass.equals(IO.gryo)){
+                final GryoMapper.Builder builder = GryoMapper.build();
+                detectRegistries().forEach(builder::addRegistry);
+                return GryoWriter.build().mapper(builder.create()).create();
+            }else if (objectOrClass.equals(IO.graphml))
                 return GraphMLWriter.build().create();
             else {
                 try {
@@ -204,21 +207,31 @@ public class IoStep<S> extends AbstractStep<S,S> implements ReadWriting {
         }
     }
 
-    private GraphWriter detectWriter() {
+    private String detectFileType() {
         if (file.endsWith(".kryo"))
-            return GryoWriter.build().create();
+            return IO.gryo;
         else if (file.endsWith(".json"))
-            return GraphSONWriter.build().create();
+            return IO.graphson;
         else if (file.endsWith(".xml"))
-            return GraphMLWriter.build().create();
+            return IO.graphml;
         else
             throw new IllegalStateException("Could not detect the file format - specify the writer explicitly or rename file with a standard extension");
     }
 
-    private Configuration getConfFromParameters() {
-        final Configuration conf = new BaseConfiguration();
-        parameters.getRaw().forEach((key, value) -> conf.setProperty(key.toString(), value.get(0)));
-        return conf;
+    private List<IoRegistry> detectRegistries() {
+        final List<Object> k = parameters.get(IO.registry, Collections::emptyList);
+        return parameters.get(IO.registry, null).stream().map(cn -> {
+            try {
+                if (cn instanceof IoRegistry)
+                    return (IoRegistry) cn;
+                else {
+                    final Class<?> clazz = Class.forName(cn.toString());
+                    return (IoRegistry) clazz.getMethod("instance").invoke(null);
+                }
+            } catch (Exception ex) {
+                throw new IllegalStateException(ex);
+            }
+        }).collect(Collectors.toList());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff71c6ab/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/Parameters.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/Parameters.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/Parameters.java
index 40d9330..eb57f4b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/Parameters.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/Parameters.java
@@ -100,11 +100,11 @@ public final class Parameters implements Cloneable, Serializable {
      * Gets the value of a key and if that key isn't present returns the default value from the {@link Supplier}.
      *
      * @param key          the key to retrieve
-     * @param defaultValue the default value generator
+     * @param defaultValue the default value generator which if null will return an empty list
      */
     public <E> List<E> get(final Object key, final Supplier<E> defaultValue) {
         final List<E> list = (List<E>) this.parameters.get(key);
-        return (null == list) ? Collections.singletonList(defaultValue.get()) : list;
+        return (null == list) ? (null == defaultValue ? Collections.emptyList() : Collections.singletonList(defaultValue.get())) : list;
 
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff71c6ab/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
index 82d72c0..361b246 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs
@@ -1256,20 +1256,20 @@ namespace Gremlin.Net.Process.Traversal
         }
 
         /// <summary>
-        ///     Adds the repeat step to this <see cref="GraphTraversal{SType, EType}" />.
+        ///     Adds the read step to this <see cref="GraphTraversal{SType, EType}" />.
         /// </summary>
-        public GraphTraversal<S, E> Repeat (string loopName, ITraversal repeatTraversal)
+        public GraphTraversal<S, E> Read ()
         {
-            Bytecode.AddStep("repeat", loopName, repeatTraversal);
+            Bytecode.AddStep("read");
             return Wrap<S, E>(this);
         }
 
         /// <summary>
-        ///     Adds the read step to this <see cref="GraphTraversal{SType, EType}" />.
+        ///     Adds the repeat step to this <see cref="GraphTraversal{SType, EType}" />.
         /// </summary>
-        public GraphTraversal<S, E> Read ()
+        public GraphTraversal<S, E> Repeat (string loopName, ITraversal repeatTraversal)
         {
-            Bytecode.AddStep("read");
+            Bytecode.AddStep("repeat", loopName, repeatTraversal);
             return Wrap<S, E>(this);
         }
 
@@ -1713,15 +1713,6 @@ namespace Gremlin.Net.Process.Traversal
         }
 
         /// <summary>
-        ///     Adds the with step to this <see cref="GraphTraversal{SType, EType}" />.
-        /// </summary>
-        public GraphTraversal<S, E> With (string key, object value)
-        {
-            Bytecode.AddStep("with", key, value);
-            return Wrap<S, E>(this);
-        }
-
-        /// <summary>
         ///     Adds the write step to this <see cref="GraphTraversal{SType, EType}" />.
         /// </summary>
         public GraphTraversal<S, E> Write ()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff71c6ab/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
index 288f7e3..861b431 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
@@ -46,6 +46,8 @@ namespace Gremlin.Net.Process.Traversal
         
             public const String reader = "~tinkerpop.io.reader";
         
+            public const String registry = "~tinkerpop.io.registry";
+        
             public const String writer = "~tinkerpop.io.writer";
         
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff71c6ab/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index 3f69fb1..09aec91 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -129,6 +129,10 @@ class IO {
         return "~tinkerpop.io.reader"
     }
 
+    static get registry() {
+        return "~tinkerpop.io.registry"
+    }
+
     static get writer() {
         return "~tinkerpop.io.writer"
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff71c6ab/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
index d9fb4d9..49bb7b1 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
@@ -319,6 +319,8 @@ class IO(object):
 
     reader = "~tinkerpop.io.reader"
 
+    registry = "~tinkerpop.io.registry"
+
     writer = "~tinkerpop.io.writer"
 
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff71c6ab/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/util/CustomId.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/util/CustomId.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/util/CustomId.java
index d503ae8..0ab3b90 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/util/CustomId.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/util/CustomId.java
@@ -18,9 +18,14 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io.util;
 
+import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry;
+import org.apache.tinkerpop.gremlin.structure.io.Io;
+import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.AbstractObjectDeserializer;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.TinkerPopJacksonModule;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
 import org.apache.tinkerpop.shaded.jackson.core.JsonGenerationException;
 import org.apache.tinkerpop.shaded.jackson.core.JsonGenerator;
 import org.apache.tinkerpop.shaded.jackson.core.JsonParser;
@@ -31,11 +36,13 @@ import org.apache.tinkerpop.shaded.jackson.databind.deser.std.StdDeserializer;
 import org.apache.tinkerpop.shaded.jackson.databind.jsontype.TypeSerializer;
 import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdScalarSerializer;
 import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdSerializer;
+import org.javatuples.Pair;
 
 import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -66,6 +73,24 @@ public class CustomId {
     }
 
     @Override
+    public boolean equals(final Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final CustomId customId = (CustomId) o;
+
+        if (!cluster.equals(customId.cluster)) return false;
+        return elementId.equals(customId.elementId);
+    }
+
+    @Override
+    public int hashCode() {
+        int result = cluster.hashCode();
+        result = 31 * result + elementId.hashCode();
+        return result;
+    }
+
+    @Override
     public String toString() {
         return cluster + ":" + elementId;
     }
@@ -219,4 +244,18 @@ public class CustomId {
             return "simple";
         }
     }
+
+    public static class CustomIdIoRegistry extends AbstractIoRegistry {
+
+        private static final CustomIdIoRegistry INSTANCE = new CustomIdIoRegistry();
+
+        private CustomIdIoRegistry() {
+            register(GryoIo.class, CustomId.class, null);
+            register(GraphSONIo.class, null, new CustomIdTinkerPopJacksonModuleV3d0());
+        }
+
+        public static CustomIdIoRegistry instance() {
+            return INSTANCE;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ff71c6ab/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphIoStepTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphIoStepTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphIoStepTest.java
new file mode 100644
index 0000000..06c4db8
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphIoStepTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.tinkergraph.process.traversal.step.sideEffect;
+
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.apache.tinkerpop.gremlin.process.traversal.IO;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.util.CustomId;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * It was hard to test the {@link IO#registry} configuration as a generic test. Opted to test it as a bit of a
+ * standalone test with TinkerGraph.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class TinkerGraphIoStepTest {
+
+    private Graph graph;
+    private GraphTraversalSource g;
+
+    @Before
+    public void setup() {
+        graph = TinkerGraph.open();
+        g = graph.traversal();
+    }
+
+    @Test
+    public void shouldWriteReadWithCustomIoRegistryGryo() throws Exception {
+        final UUID uuid = UUID.randomUUID();
+        g.addV("person").property("name","stephen").property("custom", new CustomId("a", uuid)).iterate();
+
+        final File file = TestHelper.generateTempFile(TinkerGraphIoStepTest.class, "shouldWriteReadWithCustomIoRegistryGryo", ".kryo");
+        g.io(file.getAbsolutePath()).with(IO.registry, CustomId.CustomIdIoRegistry.class.getName()).write().iterate();
+
+        final Graph emptyGraph = TinkerGraph.open();
+        final GraphTraversalSource emptyG = emptyGraph.traversal();
+
+        try {
+            emptyG.io(file.getAbsolutePath()).read().iterate();
+            fail("Can't read without a registry");
+        } catch (Exception ignored) {
+            // do nothing
+        }
+
+        emptyG.io(file.getAbsolutePath()).with(IO.registry, CustomId.CustomIdIoRegistry.instance()).read().iterate();
+
+        assertEquals(1, emptyG.V().has("custom", new CustomId("a", uuid)).count().next().intValue());
+    }
+}