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 2018/10/05 12:37:09 UTC

[08/10] tinkerpop git commit: Test added to Client to confirm correct handling of non JS native types. Changed script submission to accept GraphSON v2. Reverted TraversalSource template to original. Removed configuration of standardOp Processor. Updated

Test added to Client to confirm correct handling of non JS native types.
Changed script submission to accept GraphSON v2.
Reverted TraversalSource template to original.
Removed configuration of standardOp Processor.
Updated CHANGELOG and upgrade documentation.


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

Branch: refs/heads/TINKERPOP-1959
Commit: cbedb32642ef739aa6478735499866a1cfaa88e9
Parents: 12e8350
Author: Matthew Allen <ma...@runbox.com>
Authored: Thu Oct 4 20:57:57 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Oct 4 20:57:57 2018 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  2 +
 .../upgrade/release-3.2.x-incubating.asciidoc   | 41 ++++++++++++++++++++
 gremlin-javascript/glv/TraversalSource.template |  4 +-
 .../gremlin-javascript/lib/driver/client.js     |  4 +-
 .../test/integration/client-tests.js            | 16 +++++++-
 .../server/gremlin-server-integration.yaml      |  2 +-
 6 files changed, 62 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cbedb326/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index f12c4ad..f37f6a1 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -52,6 +52,8 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 * Fixed a bug in JavaScript GLV where DriverRemoteConnection close() method didn't returned a Promise instance.
 * Bumped to Jackson 2.9.6.
 * Sasl Plain Text Authentication added to Gremlin Javascript.
+* Ability to send scripts to server added to Gremlin Javascript.
+* Translator class added to Gremlin Javascript to translate bytecode to script clientside.
 
 [[release-3-2-9]]
 === TinkerPop 3.2.9 (Release Date: May 8, 2018)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cbedb326/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 6f2aff8..689c30e 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -74,6 +74,47 @@ packaged dataset that needed to be loaded through the various IO options availab
 benefit of `TinkerFactory` to help get them bootstrapped. For 3.2.10, Grateful Dead is now more conveniently loaded
 via that same method as the other toy graphs with `TinkerFactory.createGratefulDead()`.
 
+==== Gremlin Javascript Script Submission
+
+Gremlin Javascript can now submit script, with optional bindings, using the Client class:
+[source,javascript]
+----
+const gremlin = require('gremlin');
+const connection = new gremlin.driver.Client('ws://localhost:8182/gremlin', { traversalSource: 'g' });
+
+connection.submit('g.V().tail()')
+    .then(response => {
+        console.log(response.traversers.length);
+        console.log(response.traversers[0]);
+    });
+
+connection.submit('g.V(vid)', {vid: 1})
+    .then(response => {
+        console.log(response.traversers.length);
+        console.log(response.traversers[0]);
+    });
+----
+
+and you can also translate bytecode steps into script
+
+[source,javascript]
+----
+const gremlin = require('gremlin');
+const graph = new gremlin.process.Graph();
+const connection = new gremlin.driver.Client('ws://localhost:8182/gremlin', { traversalSource: 'g' });
+const translator = new gremlin.process.Translator('g');
+
+const g = graph.traversal();
+g.V().tail();
+const script = translator.translate(g.getBytecode());
+
+connection.submit(script)
+    .then(response => {
+        console.log(response.traversers.length);
+        console.log(response.traversers[0]);
+    });
+----
+
 === Upgrading for Providers
 
 ==== Graph Database Providers

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cbedb326/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index f3c7795..6965110 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -85,11 +85,9 @@ class Traversal {
   _getNext() {
     while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
       let traverser = this.traversers[this._traversersIteratorIndex];
-      if (traverser.bulk && traverser.bulk > 0) {
+      if (traverser.bulk > 0) {
         traverser.bulk--;
         return { value: traverser.object, done: false };
-      } else if (traverser.bulk === undefined) {
-        return { value: traverser, done: true }
       }
       this._traversersIteratorIndex++;
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cbedb326/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/client.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/client.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/client.js
index 91a4dfb..d91ce20 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/client.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/client.js
@@ -60,9 +60,9 @@ class Client {
     if (typeof message === 'string' || message instanceof String) {
       const args = {
         'gremlin': message,
-        'bindings': bindings,
+        'bindings': bindings, 
         'language': 'gremlin-groovy',
-        'accept': 'application/json',
+        'accept': 'application/vnd.gremlin-v2.0+json',
         'aliases': { 'g': this._options.traversalSource || 'g' }
       };
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cbedb326/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js
index 83f4baa..6fcb892 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js
@@ -23,6 +23,7 @@ const assert = require('assert');
 const Bytecode = require('../../lib/process/bytecode');
 const graphModule = require('../../lib/structure/graph');
 const helper = require('../helper');
+const t = require('../../lib/process/traversal');
 
 let connection;
 
@@ -54,12 +55,25 @@ describe('Client', function () {
         });
     });
     it('should send and parse a script with bindings', function () {
-      return connection.submit('x + x', {x: 3})
+      return connection.submit('x + x', { x: 3 })
         .then(function (response) {
           assert.ok(response);
           assert.ok(response.traversers);
           assert.strictEqual(response.traversers[0], 6);
         });
     });
+    it('should send and parse a script with non-native javascript bindings', function () {
+      /*return connection.submit('card.toString()', { card: t.cardinality.set })
+        .then(function (response) {
+          console.log(response);
+          assert.ok(response);
+          assert.ok(response.traversers);
+        });*/
+      return connection.submit('g.addV().property(card, nm, val)', { card: t.cardinality.set, nm: 'test', val: 12 } )
+        .then(function (response) {
+          assert.ok(response);
+          assert.ok(response.traversers);
+        });
+    });
   });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cbedb326/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
index 20680fc..ac360a0 100644
--- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
+++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
@@ -41,7 +41,7 @@ serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0] }}
 processors:
   - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
-  - { className: org.apache.tinkerpop.gremlin.server.op.standard.StandardOpProcessor, config: { maxParameters: 64 }}
+  - { className: org.apache.tinkerpop.gremlin.server.op.standard.StandardOpProcessor, config: {}}
 metrics: {
   slf4jReporter: {enabled: true, interval: 180000}}
 strictTransactionManagement: false