You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2017/07/31 16:32:31 UTC

tinkerpop git commit: Removed previously deprecated `ScriptElementFactory`.

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1724 [created] 18509fbbd


Removed previously deprecated `ScriptElementFactory`.


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

Branch: refs/heads/TINKERPOP-1724
Commit: 18509fbbdaa35bb855569fb628a8e5375218a038
Parents: 86edf56
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Mon Jul 31 18:31:33 2017 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Mon Jul 31 18:31:33 2017 +0200

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 data/script-input.groovy                        |  4 +-
 .../implementations-hadoop-end.asciidoc         |  3 +-
 .../structure/io/script/ScriptRecordReader.java | 41 ++------------------
 4 files changed, 6 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18509fbb/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index cbf0621..09476a0 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.3.0 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Removed previously deprecated `ScriptElementFactory`.
 * Bumped to support Giraph 1.2.0.
 * Bumped to support Spark 2.2.0.
 * Detected if type checking was required in `GremlinGroovyScriptEngine` and disabled related infrastructure if not.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18509fbb/data/script-input.groovy
----------------------------------------------------------------------
diff --git a/data/script-input.groovy b/data/script-input.groovy
index 4e1d219..b111cce 100644
--- a/data/script-input.groovy
+++ b/data/script-input.groovy
@@ -16,9 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-def parse(line, factory) {
-    // "factory" should no longer be used, as ScriptElementFactory is now deprecated
-    // instead use the global "graph" variable which is the local star graph for the current element
+def parse(line) {
     def parts = line.split(/ /)
     def (id, label, name, x) = parts[0].split(/:/).toList()
     def v1 = graph.addVertex(T.id, id, T.label, label)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18509fbb/docs/src/reference/implementations-hadoop-end.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/implementations-hadoop-end.asciidoc b/docs/src/reference/implementations-hadoop-end.asciidoc
index 3fe768d..6963aa1 100644
--- a/docs/src/reference/implementations-hadoop-end.asciidoc
+++ b/docs/src/reference/implementations-hadoop-end.asciidoc
@@ -91,9 +91,8 @@ As such, `ScriptInputFormat` can be used. With `ScriptInputFormat` a script is s
 mapper in the Hadoop job. The script must have the following method defined:
 
 [source,groovy]
-def parse(String line, ScriptElementFactory factory) { ... }
+def parse(String line) { ... }
 
-`ScriptElementFactory` is a legacy from previous versions and, although it's still functional, it should no longer be used.
 In order to create vertices and edges, the `parse()` method gets access to a global variable named `graph`, which holds
 the local `StarGraph` for the current line/vertex.
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18509fbb/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
index 3299c1c..7dd4e2b 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java
@@ -60,14 +60,12 @@ public final class ScriptRecordReader extends RecordReader<NullWritable, VertexW
     protected final static String SCRIPT_ENGINE = "gremlin.hadoop.scriptInputFormat.scriptEngine";
     private final static String GRAPH = "graph";
     private final static String LINE = "line";
-    private final static String FACTORY = "factory";
-    private final static String READ_CALL = "parse(" + LINE + "," + FACTORY + ")";
+    private final static String READ_CALL = "parse(" + LINE + ")";
     private final VertexWritable vertexWritable = new VertexWritable();
     private final LineRecordReader lineRecordReader;
     private final GremlinScriptEngineManager manager = new CachedGremlinScriptEngineManager();
 
     private ScriptEngine engine;
-    private String parse;
     private CompiledScript script;
 
     private GraphFilter graphFilter = new GraphFilter();
@@ -86,8 +84,8 @@ public final class ScriptRecordReader extends RecordReader<NullWritable, VertexW
         final FileSystem fs = FileSystem.get(configuration);
         try (final InputStream stream = fs.open(new Path(configuration.get(SCRIPT_FILE)));
              final InputStreamReader reader = new InputStreamReader(stream)) {
-            this.parse = String.join("\n", IOUtils.toString(reader), READ_CALL);
-            script = ((Compilable) engine).compile(this.parse);
+            final String parse = String.join("\n", IOUtils.toString(reader), READ_CALL);
+            script = ((Compilable) engine).compile(parse);
         } catch (ScriptException e) {
             throw new IOException(e.getMessage(), e);
         }
@@ -100,10 +98,8 @@ public final class ScriptRecordReader extends RecordReader<NullWritable, VertexW
             try {
                 final Bindings bindings = this.engine.createBindings();
                 final StarGraph graph = StarGraph.open();
-                final ScriptElementFactory factory = new ScriptElementFactory(graph);
                 bindings.put(GRAPH, graph);
                 bindings.put(LINE, this.lineRecordReader.getCurrentValue().toString());
-                bindings.put(FACTORY, factory);
                 final StarGraph.StarVertex sv = (StarGraph.StarVertex) script.eval(bindings);
                 if (sv != null) {
                     final Optional<StarGraph.StarVertex> vertex = sv.applyGraphFilter(this.graphFilter);
@@ -137,35 +133,4 @@ public final class ScriptRecordReader extends RecordReader<NullWritable, VertexW
     public synchronized void close() throws IOException {
         this.lineRecordReader.close();
     }
-
-    @Deprecated
-    protected class ScriptElementFactory {
-
-        private final StarGraph graph;
-
-        public ScriptElementFactory() {
-            this(StarGraph.open());
-        }
-
-        public ScriptElementFactory(final StarGraph graph) {
-            this.graph = graph;
-        }
-
-        public Vertex vertex(final Object id) {
-            return vertex(id, Vertex.DEFAULT_LABEL);
-        }
-
-        public Vertex vertex(final Object id, final String label) {
-            final Iterator<Vertex> vertices = graph.vertices(id);
-            return vertices.hasNext() ? vertices.next() : graph.addVertex(T.id, id, T.label, label);
-        }
-
-        public Edge edge(final Vertex out, final Vertex in) {
-            return edge(out, in, Edge.DEFAULT_LABEL);
-        }
-
-        public Edge edge(final Vertex out, final Vertex in, final String label) {
-            return out.addEdge(label, in);
-        }
-    }
 }