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 2015/07/18 13:03:00 UTC

[1/2] incubator-tinkerpop git commit: Add some javadoc to StarGraph.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/tp30 f85f1bb54 -> d747d0acd


Add some javadoc to StarGraph.


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

Branch: refs/heads/tp30
Commit: d2d285ed153ddf83c3eb32ed662f5d8f1b2ebd19
Parents: f85f1bb
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sat Jul 18 06:31:42 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Sat Jul 18 06:31:42 2015 -0400

----------------------------------------------------------------------
 .../gremlin/structure/util/star/StarGraph.java        | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d2d285ed/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
index 9541cdf..06d2059 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
@@ -49,6 +49,11 @@ import java.util.NoSuchElementException;
 import java.util.stream.Stream;
 
 /**
+ * A {@code StarGraph} is a form of {@link Attachable} (though the {@link Graph} implementation does not implement
+ * that interface itself).  It is a very limited {@link Graph} implementation that holds a single {@link Vertex}
+ * and its related properties and edges (and their properties).  It is designed to be an efficient memory
+ * representation of this data structure, thus making it good for network and disk-based serialization.
+ *
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
 public final class StarGraph implements Graph, Serializable {
@@ -67,6 +72,9 @@ public final class StarGraph implements Graph, Serializable {
     private StarGraph() {
     }
 
+    /**
+     * Gets the {@link Vertex} representative of the {@link StarGraph}.
+     */
     public StarVertex getStarVertex() {
         return this.starVertex;
     }
@@ -172,10 +180,16 @@ public final class StarGraph implements Graph, Serializable {
         return StringFactory.graphString(this, "starOf:" + this.starVertex);
     }
 
+    /**
+     * Creates an empty {@link StarGraph}.
+     */
     public static StarGraph open() {
         return new StarGraph();
     }
 
+    /**
+     * Creates a new {@link StarGraph} from a {@link Vertex}.
+     */
     public static StarGraph of(final Vertex vertex) {
         if (vertex instanceof StarVertex) return (StarGraph) vertex.graph();
         // else convert to a star graph


[2/2] incubator-tinkerpop git commit: Fix bug that prevented null binding values being passed to the ScriptEngine.

Posted by sp...@apache.org.
Fix bug that prevented null binding values being passed to the ScriptEngine.


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

Branch: refs/heads/tp30
Commit: d747d0acd27a8072757b13a34ebc568c241f7c3e
Parents: d2d285e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sat Jul 18 07:00:02 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Sat Jul 18 07:00:02 2015 -0400

----------------------------------------------------------------------
 .../groovy/jsr223/GremlinGroovyScriptEngine.java | 10 ++++++----
 .../jsr223/GremlinGroovyScriptEngineTest.java    | 19 ++++++++++++++++++-
 2 files changed, 24 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d747d0ac/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
index dae19e5..5affa0c 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
@@ -439,10 +439,12 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl implements
     private void registerBindingTypes(final ScriptContext context) {
         final Map<String,ClassNode> variableTypes = new HashMap<>();
         clearVarTypes();
-        context.getBindings(ScriptContext.ENGINE_SCOPE).forEach((k, v) -> {
-            final Class clazz = v.getClass();
-            variableTypes.put(k, ClassHelper.make(clazz));
-        });
+
+        // use null for the classtype if the binding value itself is null - not fully sure if that is
+        // a sound way to deal with that.  didn't see a class type for null - maybe it should just be
+        // unknown and be "Object".  at least null is properly being accounted for now.
+        context.getBindings(ScriptContext.ENGINE_SCOPE).forEach((k, v) ->
+            variableTypes.put(k, null == v ? null : ClassHelper.make(v.getClass())));
 
         COMPILE_OPTIONS.get().put(COMPILE_OPTIONS_VAR_TYPES, variableTypes);
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d747d0ac/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
index 5ca078a..9e74686 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
@@ -28,6 +28,7 @@ import javax.script.Bindings;
 import javax.script.ScriptContext;
 import javax.script.ScriptEngine;
 import javax.script.ScriptException;
+import javax.script.SimpleBindings;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
@@ -62,12 +63,28 @@ public class GremlinGroovyScriptEngineTest {
     }
 
     @Test
-    public void shouldEvalSimple() throws Exception {
+    public void shouldEvalWithNoBindings() throws Exception {
         final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
         assertEquals(3, engine.eval("1+2"));
     }
 
     @Test
+    public void shouldEvalWithBindings() throws Exception {
+        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
+        final Bindings b = new SimpleBindings();
+        b.put("x", 2);
+        assertEquals(3, engine.eval("1+x", b));
+    }
+
+    @Test
+    public void shouldEvalWithNullInBindings() throws Exception {
+        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
+        final Bindings b = new SimpleBindings();
+        b.put("x", null);
+        assertNull(engine.eval("x", b));
+    }
+
+    @Test
     public void shouldEvalSuccessfulAssert() throws Exception {
         final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
         assertNull(engine.eval("assert 1==1"));