You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/05/10 00:58:43 UTC
incubator-tinkerpop git commit: TraveraslScriptFunction tests the
bindings at constructor. GroovyHasTest minor tweak. private Constants() {}.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master 0c24fddc9 -> 4ae2b2a5a
TraveraslScriptFunction tests the bindings at constructor. GroovyHasTest minor tweak. private Constants() {}.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/4ae2b2a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/4ae2b2a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/4ae2b2a5
Branch: refs/heads/master
Commit: 4ae2b2a5aea3473685158aaaede3caa311466d21
Parents: 0c24fdd
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Sat May 9 16:58:36 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Sat May 9 16:58:36 2015 -0600
----------------------------------------------------------------------
.../process/traversal/util/TraversalScriptFunction.java | 11 ++++-------
.../process/traversal/step/filter/GroovyHasTest.groovy | 4 ++--
.../org/apache/tinkerpop/gremlin/hadoop/Constants.java | 4 ++++
3 files changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4ae2b2a5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalScriptFunction.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalScriptFunction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalScriptFunction.java
index 6d67b0b..110e070 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalScriptFunction.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalScriptFunction.java
@@ -18,10 +18,10 @@
*/
package org.apache.tinkerpop.gremlin.process.traversal.util;
-import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
import javax.script.Bindings;
import javax.script.ScriptEngine;
@@ -44,6 +44,8 @@ public final class TraversalScriptFunction<S, E> implements Function<Graph, Trav
this.scriptEngineName = scriptEngineName;
this.traversalScript = traversalScript;
this.bindings = bindings;
+ if (this.bindings.length % 2 != 0)
+ throw new IllegalArgumentException("The provided key/value bindings array length must be a multiple of two");
}
public Traversal.Admin<S, E> apply(final Graph graph) {
@@ -51,16 +53,11 @@ public final class TraversalScriptFunction<S, E> implements Function<Graph, Trav
final ScriptEngine engine = ScriptEngineCache.get(this.scriptEngineName);
final Bindings engineBindings = engine.createBindings();
engineBindings.put("g", this.traversalContextBuilder.create(graph));
- if (this.bindings.length % 2 != 0)
- throw new IllegalArgumentException("The provided key/value bindings array length must be a multiple of two");
for (int i = 0; i < this.bindings.length; i = i + 2) {
engineBindings.put((String) this.bindings[i], this.bindings[i + 1]);
}
final Traversal.Admin<S, E> traversal = (Traversal.Admin<S, E>) engine.eval(this.traversalScript, engineBindings);
- if (!traversal.isLocked()) {
- traversal.setGraph(graph);
- traversal.applyStrategies();
- }
+ if (!traversal.isLocked()) traversal.applyStrategies();
return traversal;
} catch (final ScriptException e) {
throw new IllegalStateException(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4ae2b2a5/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy
index cbedf72..e292bfc 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy
@@ -18,8 +18,8 @@
*/
package org.apache.tinkerpop.gremlin.process.traversal.step.filter
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalScriptHelper
import org.apache.tinkerpop.gremlin.process.traversal.Traversal
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalScriptHelper
import org.apache.tinkerpop.gremlin.structure.Edge
import org.apache.tinkerpop.gremlin.structure.Vertex
@@ -41,7 +41,7 @@ public abstract class GroovyHasTest {
@Override
public Traversal<Vertex, Vertex> get_g_VX1X_hasXkeyX(final Object v1Id, final String key) {
- TraversalScriptHelper.compute("g.V(v1Id).has('${key}')", g, "v1Id", v1Id);
+ TraversalScriptHelper.compute("g.V(v1Id).has(k)", g, "v1Id", v1Id, "k", key);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4ae2b2a5/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/Constants.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/Constants.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/Constants.java
index 2d70bdc..2aaa53b 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/Constants.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/Constants.java
@@ -25,6 +25,10 @@ import org.apache.tinkerpop.gremlin.structure.Graph;
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class Constants {
+
+ private Constants() {
+ }
+
public static final String GREMLIN_HADOOP_INPUT_LOCATION = "gremlin.hadoop.inputLocation";
public static final String GREMLIN_HADOOP_OUTPUT_LOCATION = "gremlin.hadoop.outputLocation";
public static final String GREMLIN_HADOOP_GRAPH_INPUT_FORMAT = "gremlin.hadoop.graphInputFormat";