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/27 18:51:41 UTC

incubator-tinkerpop git commit: Update all the sample init scripts to return Map.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/tp30 8b48e4178 -> 97a9d00a8


Update all the sample init scripts to return Map.

Returning Map represents the revised model for promoting bindings.


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

Branch: refs/heads/tp30
Commit: 97a9d00a88d82f72d64e9d7e42df0b2d33a1e5df
Parents: 8b48e41
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 27 12:50:59 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jul 27 12:50:59 2015 -0400

----------------------------------------------------------------------
 gremlin-server/scripts/empty-sample.groovy      | 24 +++++++++---------
 gremlin-server/scripts/generate-classic.groovy  | 18 +++++++-------
 .../scripts/generate-modern-readonly.groovy     | 26 ++++++++++----------
 gremlin-server/scripts/generate-modern.groovy   | 26 ++++++++++----------
 gremlin-server/scripts/load-sample.groovy       | 26 ++++++++++----------
 ...-shouldRebindTraversalSourceVariables.groovy |  8 +++---
 6 files changed, 64 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97a9d00a/gremlin-server/scripts/empty-sample.groovy
----------------------------------------------------------------------
diff --git a/gremlin-server/scripts/empty-sample.groovy b/gremlin-server/scripts/empty-sample.groovy
index 7e3b905..3465577 100644
--- a/gremlin-server/scripts/empty-sample.groovy
+++ b/gremlin-server/scripts/empty-sample.groovy
@@ -17,22 +17,24 @@
  * under the License.
  */
 
+// An example of an initialization script that can be configured to run in Gremlin Server.
+// Functions defined here will go into global cache and will not be removed from there
+// unless there is a reset of the ScriptEngine.
+def addItUp(x, y) { x + y }
+
+// an init script that returns a Map allows explicit setting of global bindings.
+def globals = [:]
+
 // defines a sample LifeCycleHook that prints some output to the Gremlin Server console.
-// it is important that the hook be assigned to a variable (in this case "hook").
-// the exact name of this variable is unimportant.
-hook = [
+// note that the name of the key in the "global" map is unimportant.
+globals << [hook : [
   onStartUp: { ctx ->
     ctx.logger.info("Executed once at startup of Gremlin Server.")
   },
   onShutDown: { ctx ->
     ctx.logger.info("Executed once at shutdown of Gremlin Server.")
   }
-] as LifeCycleHook
+] as LifeCycleHook]
 
-// define the default TraversalSource to bind queries to.
-g = graph.traversal()
-
-// An example of an initialization script that can be configured to run in Gremlin Server.
-// Functions defined here will go into global cache and will not be removed from there
-// unless there is a reset of the ScriptEngine.
-def addItUp(x, y) { x + y }
\ No newline at end of file
+// define the default TraversalSource to bind queries to - this one will be named "g".
+globals << [g : graph.traversal()]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97a9d00a/gremlin-server/scripts/generate-classic.groovy
----------------------------------------------------------------------
diff --git a/gremlin-server/scripts/generate-classic.groovy b/gremlin-server/scripts/generate-classic.groovy
index e6d3fb1..4c73e74 100644
--- a/gremlin-server/scripts/generate-classic.groovy
+++ b/gremlin-server/scripts/generate-classic.groovy
@@ -17,17 +17,17 @@
  * under the License.
  */
 
-// Generates the classic graph into an "empty" TinkerGraph via LifeCycleHook
-// it is important that the hook be assigned to a variable (in this case "hook").
-// the exact name of this variable is unimportant.
-hook = [
+// an init script that returns a Map allows explicit setting of global bindings.
+def globals = [:]
+
+// Generates the classic graph into an "empty" TinkerGraph via LifeCycleHook.
+// Note that the name of the key in the "global" map is unimportant.
+globals << [hook : [
   onStartUp: { ctx ->
     ctx.logger.info("Loading 'classic' graph data.")
     TinkerFactory.generateClassic(graph)
   }
-] as LifeCycleHook
+] as LifeCycleHook]
 
-// Define the default TraversalSource to bind queries to. Code outside of the "hook"
-// will execute for each instantiated ScriptEngine instance. Use this part of the
-// script to initialize functions that are meant to be re-usable.
-g = graph.traversal()
\ No newline at end of file
+// define the default TraversalSource to bind queries to - this one will be named "g".
+globals << [g : graph.traversal()]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97a9d00a/gremlin-server/scripts/generate-modern-readonly.groovy
----------------------------------------------------------------------
diff --git a/gremlin-server/scripts/generate-modern-readonly.groovy b/gremlin-server/scripts/generate-modern-readonly.groovy
index 6e4dc89..1cef3aa 100644
--- a/gremlin-server/scripts/generate-modern-readonly.groovy
+++ b/gremlin-server/scripts/generate-modern-readonly.groovy
@@ -17,17 +17,17 @@
  * under the License.
  */
 
-// Generates the modern graph into an "empty" TinkerGraph via LifeCycleHook
-// it is important that the hook be assigned to a variable (in this case "hook").
-// the exact name of this variable is unimportant.
-hook = [
-  onStartUp: { ctx ->
-    ctx.logger.info("Loading 'modern' graph data.")
-    TinkerFactory.generateModern(graph)
-  }
-] as LifeCycleHook
+// an init script that returns a Map allows explicit setting of global bindings.
+def globals = [:]
 
-// Define the default TraversalSource to bind queries to. Code outside of the "hook"
-// will execute for each instantiated ScriptEngine instance. Use this part of the
-// script to initialize functions that are meant to be re-usable.
-g = graph.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()))
\ No newline at end of file
+// Generates the modern graph into an "empty" TinkerGraph via LifeCycleHook.
+// Note that the name of the key in the "global" map is unimportant.
+globals << [hook : [
+        onStartUp: { ctx ->
+          ctx.logger.info("Loading 'modern' graph data.")
+          TinkerFactory.generateClassic(graph)
+        }
+] as LifeCycleHook]
+
+// define the default TraversalSource to bind queries to - this one will be named "g".
+globals << [g : graph.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()))]

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97a9d00a/gremlin-server/scripts/generate-modern.groovy
----------------------------------------------------------------------
diff --git a/gremlin-server/scripts/generate-modern.groovy b/gremlin-server/scripts/generate-modern.groovy
index 2d32848..d0f5489 100644
--- a/gremlin-server/scripts/generate-modern.groovy
+++ b/gremlin-server/scripts/generate-modern.groovy
@@ -17,17 +17,17 @@
  * under the License.
  */
 
-// Generates the modern graph into an "empty" TinkerGraph via LifeCycleHook
-// it is important that the hook be assigned to a variable (in this case "hook").
-// the exact name of this variable is unimportant.
-hook = [
-  onStartUp: { ctx ->
-    ctx.logger.info("Loading 'modern' graph data.")
-    TinkerFactory.generateModern(graph)
-  }
-] as LifeCycleHook
+// an init script that returns a Map allows explicit setting of global bindings.
+def globals = [:]
 
-// Define the default TraversalSource to bind queries to. Code outside of the "hook"
-// will execute for each instantiated ScriptEngine instance. Use this part of the
-// script to initialize functions that are meant to be re-usable.
-g = graph.traversal()
\ No newline at end of file
+// Generates the modern graph into an "empty" TinkerGraph via LifeCycleHook.
+// Note that the name of the key in the "global" map is unimportant.
+globals << [hook : [
+        onStartUp: { ctx ->
+          ctx.logger.info("Loading 'modern' graph data.")
+          TinkerFactory.generateClassic(graph)
+        }
+] as LifeCycleHook]
+
+// define the default TraversalSource to bind queries to - this one will be named "g".
+globals << [g : graph.traversal()]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97a9d00a/gremlin-server/scripts/load-sample.groovy
----------------------------------------------------------------------
diff --git a/gremlin-server/scripts/load-sample.groovy b/gremlin-server/scripts/load-sample.groovy
index da36168..81241a0 100644
--- a/gremlin-server/scripts/load-sample.groovy
+++ b/gremlin-server/scripts/load-sample.groovy
@@ -17,23 +17,23 @@
  * under the License.
  */
 
-// Generates the modern graph into an "empty" TinkerGraph via LifeCycleHook
-// it is important that the hook be assigned to a variable (in this case "hook").
-// the exact name of this variable is unimportant.
-hook = [
+// Functions defined here will go into global cache and will not be removed from there
+// unless there is a reset of the ScriptEngine.
+def addItUp(x, y) { x + y }
+
+// an init script that returns a Map allows explicit setting of global bindings.
+def globals = [:]
+
+// defines a sample LifeCycleHook that prints some output to the Gremlin Server console.
+// note that the name of the key in the "global" map is unimportant.
+globals << [hook : [
   onStartUp: { ctx ->
     ctx.logger.info("Loading graph data from data/sample.kryo.")
 
     // An example of an initialization script that can be configured to run in Gremlin Server.
     graph.io(GryoIo.build()).readGraph('data/sample.kryo')
   }
-] as LifeCycleHook
+] as LifeCycleHook]
 
-// define the default TraversalSource to bind queries to. Code outside of the "hook"
-// will execute for each instantiated ScriptEngine instance. Use this part of the
-// script to initialize functions that are meant to be re-usable.
-g = graph.traversal()
-
-// Functions defined here will go into global cache and will not be removed from there
-// unless there is a reset of the ScriptEngine.
-def addItUp(x, y) { x + y }
\ No newline at end of file
+// define the default TraversalSource to bind queries to - this one will be named "g".
+globals << [g : graph.traversal()]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97a9d00a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/generate-shouldRebindTraversalSourceVariables.groovy
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/generate-shouldRebindTraversalSourceVariables.groovy b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/generate-shouldRebindTraversalSourceVariables.groovy
index 668c440..909cd69 100644
--- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/generate-shouldRebindTraversalSourceVariables.groovy
+++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/generate-shouldRebindTraversalSourceVariables.groovy
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-// Define the default TraversalSource to bind queries to. Code outside of the "hook"
-// will execute for each instantiated ScriptEngine instance. Use this part of the
-// script to initialize functions that are meant to be re-usable.
-g = graph.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()))
-g1 = graph.traversal()
\ No newline at end of file
+def globals = [:]
+globals << [g : graph.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()))]
+globals << [g1 : graph.traversal()]
\ No newline at end of file