tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [20/26] tinkerpop git commit: TINKERPOP-1996 Minor refactoring of Reading/Writing and javadoc
Date Thu, 12 Jul 2018 15:00:24 GMT
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/585980bb
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/585980bb
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/585980bb

Branch: refs/heads/TINKERPOP-1996
Commit: 585980bbb1c9e545c6bf0baf7bc2cfb9847901ec
Parents: 23815ec
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Tue Jul 10 12:55:06 2018 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Thu Jul 12 10:59:38 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/585980bb/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/585980bb/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/585980bb/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/585980bb/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/585980bb/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/585980bb/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/585980bb/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())
             );


Mime
View raw message