tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [tinkerpop] 08/12: 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.
Date Mon, 08 Oct 2018 19:02:12 GMT
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-1959-tp33
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit d12f117cdd9fbdaa2232936fe89c93273c011200
Author: Matthew Allen <matt.allen@runbox.com>
AuthorDate: Thu Oct 4 20:57:57 2018 +0100

    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.
---
 CHANGELOG.asciidoc                                 |  2 ++
 docs/src/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 ++++++++-
 .../gremlin/server/gremlin-server-integration.yaml |  2 +-
 6 files changed, 62 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 0a76cc0..21880af 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -413,6 +413,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)
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 46f5780..26a2552 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -105,6 +105,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
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++;
     }
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' }
       };
 
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
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 f4d508a..ddaaa95 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
@@ -42,7 +42,7 @@ serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0, config:
{ ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0]
}}
 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


Mime
View raw message