From commits-return-32918-archive-asf-public=cust-asf.ponee.io@tinkerpop.apache.org Mon Oct 8 21:02:09 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 6AF0D1807AC for ; Mon, 8 Oct 2018 21:02:07 +0200 (CEST) Received: (qmail 41063 invoked by uid 500); 8 Oct 2018 19:02:06 -0000 Mailing-List: contact commits-help@tinkerpop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.apache.org Delivered-To: mailing list commits@tinkerpop.apache.org Received: (qmail 40988 invoked by uid 99); 8 Oct 2018 19:02:06 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Oct 2018 19:02:06 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 3230682C95; Mon, 8 Oct 2018 19:02:05 +0000 (UTC) Date: Mon, 08 Oct 2018 19:02:12 +0000 To: "commits@tinkerpop.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. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: spmallette@apache.org In-Reply-To: <153902532482.18441.5724402075294112878@gitbox.apache.org> References: <153902532482.18441.5724402075294112878@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: tinkerpop X-Git-Refname: refs/heads/TINKERPOP-1959-tp33 X-Git-Reftype: branch X-Git-Rev: d12f117cdd9fbdaa2232936fe89c93273c011200 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20181008190205.3230682C95@gitbox.apache.org> 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 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