You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by jo...@apache.org on 2018/01/25 11:00:59 UTC
[01/47] tinkerpop git commit: Javascript GLV
Repository: tinkerpop
Updated Branches:
refs/heads/master 74479dd80 -> 1fae5d014
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
new file mode 100644
index 0000000..e44ef90
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTestCases() {
+ "use strict";
+
+ var helper = loadModule.call(this, './helper.js');
+ var assert = helper.assert;
+ var graph = helper.loadLibModule.call(this, 'structure/graph.js');
+ var t = helper.loadLibModule.call(this, 'process/traversal.js');
+ var gs = helper.loadLibModule.call(this, 'structure/io/graph-serializer.js');
+ var GraphSONReader = gs.GraphSONReader;
+ var GraphSONWriter = gs.GraphSONWriter;
+ var P = t.P;
+
+ [
+ function testReadNumbers() {
+ var reader = new GraphSONReader();
+ [
+ [{
+ "@type": "g:Int32",
+ "@value": 31
+ }, 31],
+ [{
+ "@type": "g:Float",
+ "@value": 31.3
+ }, 31.3],
+ [{
+ "@type": "g:Double",
+ "@value": 31.2
+ }, 31.2]
+ ].forEach(function (item) {
+ var result = reader.read(item[0]);
+ assert.strictEqual(result, item[1]);
+ assert.strictEqual(typeof result, 'number');
+ });
+ },
+ function testReadGraph() {
+ var obj = {"@type":"g:Vertex", "@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","outE":{"created":[{"id":{"@type":"g:Int32","@value":9}, "inV":{"@type":"g:Int32","@value":3},"properties":{"weight":{"@type":"g:Double","@value":0.4}}}],"knows":[{"id":{"@type":"g:Int32","@value":7},"inV":{"@type":"g:Int32","@value":2},"properties":{"weight":{"@type":"g:Double","@value":0.5}}},{"id":{"@type":"g:Int32","@value":8},"inV":{"@type":"g:Int32","@value":4},"properties":{"weight":{"@type":"g:Double","@value":1.0}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"marko"}],"age":[{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29}}]}}};
+ var reader = new GraphSONReader(obj);
+ var result = reader.read(obj);
+ assert.ok(result instanceof graph.Vertex);
+ assert.strictEqual(result.label, 'person');
+ assert.strictEqual(typeof result.id, 'number');
+ },
+ function testReadPath() {
+ var obj = {"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[
+ {"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},"value":"marko","label":"name"}}],"age":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29},"label":"age"}}]}}},
+ {"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":3},"label":"software","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":4},"value":"lop","label":"name"}}],"lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},"value":"java","label":"lang"}}]}}},
+ "lop"]}};
+ var reader = new GraphSONReader(obj);
+ var result = reader.read(obj);
+ assert.ok(result);
+ assert.ok(result.objects);
+ assert.ok(result.labels);
+ assert.strictEqual(result.objects[2], 'lop');
+ assert.ok(result.objects[0] instanceof graph.Vertex);
+ assert.ok(result.objects[1] instanceof graph.Vertex);
+ assert.strictEqual(result.objects[0].label, 'person');
+ assert.strictEqual(result.objects[1].label, 'software');
+ },
+ function testWriteNumber() {
+ var writer = new GraphSONWriter();
+ assert.strictEqual(writer.write(2), '2');
+ },
+ function testWriteBoolean() {
+ var writer = new GraphSONWriter();
+ assert.strictEqual(writer.write(true), 'true');
+ assert.strictEqual(writer.write(false), 'false');
+ },
+ function testWriteNumber() {
+ var writer = new GraphSONWriter();
+ var expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[{"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},{"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},{"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}});
+ assert.strictEqual(writer.write(P.lt("b").or(P.gt("c")).and(P.neq("d"))), expected);
+ }
+ ].forEach(function (testCase) {
+ testCase.call(null);
+ });
+
+ function loadModule(moduleName) {
+ if (typeof require !== 'undefined') {
+ return require(moduleName);
+ }
+ if (typeof load !== 'undefined') {
+ return load(__DIR__ + moduleName);
+ }
+ throw new Error('No module loader was found');
+ }
+}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
new file mode 100644
index 0000000..477df91
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTestCases() {
+ "use strict";
+
+ var helper = loadModule.call(this, './helper.js');
+ var assert = helper.assert;
+ var graph = helper.loadLibModule.call(this, 'structure/graph.js');
+
+ [
+ function testBytecode() {
+ var g = new graph.Graph().traversal();
+ var bytecode = g.V().out('created').getBytecode();
+ assert.ok(bytecode);
+ assert.strictEqual(bytecode.sourceInstructions.length, 0);
+ assert.strictEqual(bytecode.stepInstructions.length, 2);
+ assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
+ assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
+ assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
+ }
+ ].forEach(function (testCase) {
+ testCase.call(null);
+ });
+
+ function loadModule(moduleName) {
+ if (typeof require !== 'undefined') {
+ return require(moduleName);
+ }
+ if (typeof load !== 'undefined') {
+ return load(__DIR__ + moduleName);
+ }
+ throw new Error('No module loader was found');
+ }
+}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 075c89f..9603d76 100644
--- a/pom.xml
+++ b/pom.xml
@@ -120,6 +120,7 @@ limitations under the License.
<module>gremlin-groovy</module>
<module>gremlin-groovy-test</module>
<module>tinkergraph-gremlin</module>
+ <module>gremlin-javascript</module>
<module>gremlin-python</module>
<module>gremlin-dotnet</module>
<module>hadoop-gremlin</module>
[44/47] tinkerpop git commit: Travis: Use mvn install before running
GLV tests
Posted by jo...@apache.org.
Travis: Use mvn install before running GLV tests
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/328c936d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/328c936d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/328c936d
Branch: refs/heads/master
Commit: 328c936d30186f015c799589806d4bf47638daee
Parents: d37a3d8
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Jan 22 16:15:39 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Mon Jan 22 16:41:34 2018 +0100
----------------------------------------------------------------------
.travis.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/328c936d/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 442de5e..9069cec 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -26,5 +26,5 @@ before_install:
jobs:
include:
- script: "mvn clean install -Dci"
- - script: "touch gremlin-dotnet/src/.glv && touch gremlin-dotnet/test/.glv && mvn clean install -pl :gremlin-dotnet,:gremlin-dotnet-tests -P gremlin-dotnet -DskipIntegrationTests=false"
- - script: "mvn clean install -pl :gremlin-javascript -DskipIntegrationTests=false"
+ - script: "touch gremlin-dotnet/src/.glv && touch gremlin-dotnet/test/.glv && mvn clean install -q -DskipTests && mvn verify -pl :gremlin-dotnet,:gremlin-dotnet-tests -P gremlin-dotnet -DskipIntegrationTests=false"
+ - script: "mvn clean install -q -DskipTests && mvn verify -pl :gremlin-javascript -DskipIntegrationTests=false"
[40/47] tinkerpop git commit: Include T deserializer
Posted by jo...@apache.org.
Include T deserializer
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f2f9729c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f2f9729c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f2f9729c
Branch: refs/heads/master
Commit: f2f9729cd5ca295bcaa3d445878f0cbdd7b5ee6c
Parents: 3553ea9
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Jan 17 16:52:05 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:18 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/glv/TraversalSource.template | 4 ++++
.../javascript/gremlin-javascript/lib/process/traversal.js | 4 ++++
.../gremlin-javascript/lib/structure/io/graph-serializer.js | 3 ++-
.../gremlin-javascript/lib/structure/io/type-serializers.js | 7 +++++++
4 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f2f9729c/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index d707a42..3f289e4 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -182,6 +182,10 @@ class EnumValue {
this.typeName = typeName;
this.elementName = elementName;
}
+
+ toString() {
+ return this.elementName;
+ }
}
module.exports = {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f2f9729c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index 2877f02..a8d066a 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -242,6 +242,10 @@ class EnumValue {
this.typeName = typeName;
this.elementName = elementName;
}
+
+ toString() {
+ return this.elementName;
+ }
}
module.exports = {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f2f9729c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
index 3dbd340..df05659 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
@@ -159,7 +159,8 @@ const deserializers = {
'g:Edge': typeSerializers.EdgeSerializer,
'g:VertexProperty': typeSerializers.VertexPropertySerializer,
'g:Property': typeSerializers.PropertySerializer,
- 'g:Path': typeSerializers.PathSerializer
+ 'g:Path': typeSerializers.PathSerializer,
+ 'g:T': typeSerializers.TSerializer
};
const serializers = [
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f2f9729c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
index d6f131c..304888f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
@@ -270,6 +270,12 @@ class PathSerializer extends TypeSerializer {
}
}
+class TSerializer extends TypeSerializer {
+ deserialize(obj) {
+ return t.t[obj[valueKey]];
+ }
+}
+
module.exports = {
BytecodeSerializer,
EdgeSerializer,
@@ -280,6 +286,7 @@ module.exports = {
PathSerializer,
PropertySerializer,
PSerializer,
+ TSerializer,
TraverserSerializer,
typeKey,
valueKey,
[19/47] tinkerpop git commit: TINKERPOP-1489 Bump to 3.2.7-SNAPSHOT
for gremlin-javascript
Posted by jo...@apache.org.
TINKERPOP-1489 Bump to 3.2.7-SNAPSHOT for gremlin-javascript
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/80e1c7ea
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/80e1c7ea
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/80e1c7ea
Branch: refs/heads/master
Commit: 80e1c7ea3c02d3e872ac99324a854348d5e6f854
Parents: 98dc52c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 5 10:15:11 2017 -0400
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:15 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/80e1c7ea/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 203e59e..919c87e 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
<parent>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>tinkerpop</artifactId>
- <version>3.2.6-SNAPSHOT</version>
+ <version>3.2.7-SNAPSHOT</version>
</parent>
<artifactId>gremlin-javascript</artifactId>
<name>Apache TinkerPop :: Gremlin Javascript</name>
[10/47] tinkerpop git commit: Use null as empty result
Posted by jo...@apache.org.
Use null as empty result
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/84a11a1b
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/84a11a1b
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/84a11a1b
Branch: refs/heads/master
Commit: 84a11a1b10ddbb06558663a062dc1ae3a1062c68
Parents: 44e6535
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Nov 3 14:34:28 2016 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:14 2018 +0100
----------------------------------------------------------------------
.../tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy | 2 +-
.../src/main/javascript/gremlin-javascript/process/traversal.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/84a11a1b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
index 46f65a4..d5899f0 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -87,7 +87,7 @@ class TraversalSourceGenerator {
/** @param {Function} callback */
Traversal.prototype.one = function (callback) {
this.list(function (err, result) {
- callback(err, result ? result[0] : null);
+ callback(err, result && result.length > 0 ? result[0] : null);
});
};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/84a11a1b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index a7a9bb7..f585161 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -50,7 +50,7 @@
/** @param {Function} callback */
Traversal.prototype.one = function (callback) {
this.list(function (err, result) {
- callback(err, result ? result[0] : null);
+ callback(err, result && result.length > 0 ? result[0] : null);
});
};
[18/47] tinkerpop git commit: Bump to 3.2.6 in gremlin-javascript
Posted by jo...@apache.org.
Bump to 3.2.6 in gremlin-javascript
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f5c90496
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f5c90496
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f5c90496
Branch: refs/heads/master
Commit: f5c904969ff0f14129f9bbc0e6402f35ebf77fcf
Parents: 2b4e8e3
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Aug 17 13:35:47 2017 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:15 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/pom.xml | 2 +-
.../src/main/javascript/gremlin-javascript/package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f5c90496/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 1c9ffcc..452e183 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
<parent>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>tinkerpop</artifactId>
- <version>3.2.5-SNAPSHOT</version>
+ <version>3.2.6-SNAPSHOT</version>
</parent>
<artifactId>gremlin-javascript</artifactId>
<name>Apache TinkerPop :: Gremlin Javascript</name>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f5c90496/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index 0976f31..db6d3fe 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -1,6 +1,6 @@
{
"name": "gremlin-javascript",
- "version": "3.2.5-alpha1",
+ "version": "3.2.6-alpha1",
"description": "JavaScript Gremlin Language Variant",
"author": "Apache TinkerPop team",
"keywords": [
[28/47] tinkerpop git commit: Fix Bytecode cloning
Posted by jo...@apache.org.
Fix Bytecode cloning
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b9ca2ca9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b9ca2ca9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b9ca2ca9
Branch: refs/heads/master
Commit: b9ca2ca933989840a2aa6da24af4d7311acdcbc6
Parents: 9339a83
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Nov 28 11:02:10 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:16 2018 +0100
----------------------------------------------------------------------
.../src/main/javascript/gremlin-javascript/lib/process/bytecode.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b9ca2ca9/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
index 9256e6a..2909718 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
@@ -34,7 +34,7 @@ function Bytecode(toClone) {
}
else {
this.sourceInstructions = toClone.sourceInstructions.slice(0);
- this.stepInstructions = toClone.sourceInstructions.slice(0);
+ this.stepInstructions = toClone.stepInstructions.slice(0);
}
}
[14/47] tinkerpop git commit: Parse Edge and VertexProperty properties
Posted by jo...@apache.org.
Parse Edge and VertexProperty properties
To follow the decision around TINKERPOP-1474 for the GLV to parse properties.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/598b9911
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/598b9911
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/598b9911
Branch: refs/heads/master
Commit: 598b991154d8e05354a526967b7dab2067a24ebe
Parents: 84a11a1
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 16 13:41:46 2016 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:14 2018 +0100
----------------------------------------------------------------------
.../javascript/gremlin-javascript/structure/graph.js | 15 +++++++++++++--
.../structure/io/graph-serializer.js | 13 +++++++++++--
2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/598b9911/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
index 7c48819..cd408ae 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
@@ -68,10 +68,20 @@
inherits(Vertex, Element);
- function Edge(id, outV, label, inV) {
+ function Edge(id, outV, label, inV, properties) {
Element.call(this, id, label);
this.outV = outV;
this.inV = inV;
+ this.properties = {};
+ (function adaptProperties(self) {
+ if (properties) {
+ var keys = Object.keys(properties);
+ for (var i = 0; i < keys.length; i++) {
+ var k = keys[i];
+ self.properties[k] = properties[k].value;
+ }
+ }
+ })(this);
}
inherits(Edge, Element);
@@ -80,10 +90,11 @@
return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
};
- function VertexProperty(id, label, value) {
+ function VertexProperty(id, label, value, properties) {
Element.call(this, id, label);
this.value = value;
this.key = this.label;
+ this.properties = properties;
}
inherits(VertexProperty, Element);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/598b9911/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
index 2dde340..31652da 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
@@ -155,6 +155,9 @@
}
GraphSONReader.prototype.read = function (obj) {
+ if (obj === undefined) {
+ return undefined;
+ }
if (Array.isArray(obj)) {
return obj.map(function mapEach(item) {
return this.read(item);
@@ -340,7 +343,12 @@
VertexPropertySerializer.prototype.deserialize = function (obj) {
var value = obj[valueKey];
- return new g.VertexProperty(this.reader.read(value['id']), value['label'], this.reader.read(value['value']));
+ return new g.VertexProperty(
+ this.reader.read(value['id']),
+ value['label'],
+ this.reader.read(value['value']),
+ this.reader.read(value['properties'])
+ );
};
function PropertySerializer() {
@@ -364,7 +372,8 @@
this.reader.read(value['id']),
this.reader.read(value['outV']),
value['label'],
- this.reader.read(value['inV'])
+ this.reader.read(value['inV']),
+ this.reader.read(value['properties'])
);
};
[29/47] tinkerpop git commit: Path assertions and feature step fixes
Posted by jo...@apache.org.
Path assertions and feature step fixes
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b8eb6c0b
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b8eb6c0b
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b8eb6c0b
Branch: refs/heads/master
Commit: b8eb6c0b850af830d5c639de306b75aa4a1893ba
Parents: e95b8ea
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Nov 28 12:51:59 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:16 2018 +0100
----------------------------------------------------------------------
.../test/cucumber/feature-steps.js | 48 ++++++++++++++++----
1 file changed, 40 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b8eb6c0b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 8ec2bdc..99e2ec8 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -80,9 +80,8 @@ defineSupportCode(function(methods) {
if (this.graphName === 'empty') {
p = this.loadEmptyGraphData();
}
- const self = this;
return p.then(() => {
- self.parameters[paramName] = parseValue.call(self, stringValue);
+ this.parameters[paramName] = parseValue.call(this, stringValue);
}).catch(err => {
if (err instanceof IgnoreError) {
return 'skipped';
@@ -96,7 +95,13 @@ defineSupportCode(function(methods) {
});
methods.When('iterated next', function () {
- return this.traversal.next().then(it => this.result = it.value);
+ return this.traversal.next().then(it => {
+ this.result = it.value;
+ if (this.result instanceof Path) {
+ // Compare using the objects array
+ this.result = this.result.objects;
+ }
+ });
});
methods.Then(/^the result should be (\w+)$/, function assertResult(characterizedAs, resultTable) {
@@ -110,13 +115,14 @@ defineSupportCode(function(methods) {
const expectedResult = resultTable.rows().map(row => parseRow.call(this, row));
switch (characterizedAs) {
case 'ordered':
- expect(this.result).to.have.deep.ordered.members(expectedResult);
+ expect(toCompare(this.result)).to.have.deep.ordered.members(expectedResult);
break;
case 'unordered':
- expect(this.result).to.have.deep.members(expectedResult);
+ expect(toCompare(this.result)).to.have.deep.members(expectedResult);
break;
case 'of':
- expect(this.result).to.include.deep.members(expectedResult);
+ // result is a subset of the expected
+ expect(expectedResult).to.include.deep.members(toCompare(this.result));
break;
}
});
@@ -156,7 +162,11 @@ function getSandbox(g, parameters) {
__: __,
Cardinality: traversalModule.cardinality,
Column: traversalModule.column,
- Direction: traversalModule.direction,
+ Direction: {
+ BOTH: traversalModule.direction.both,
+ IN: traversalModule.direction.in,
+ OUT: traversalModule.direction.out
+ },
Order: traversalModule.order,
P: traversalModule.P,
Pick: traversalModule.pick,
@@ -172,6 +182,8 @@ function getSandbox(g, parameters) {
function translate(traversalText) {
// Remove escaped chars
traversalText = traversalText.replace(/\\"/g, '"');
+ // Remove long suffix
+ traversalText = traversalText.replace(/\b(\d+)l\b/gi, '$1');
// Change according to naming convention
traversalText = traversalText.replace(/\.in\(/g, '.in_(');
traversalText = traversalText.replace(/\.from\(/g, '.from_(');
@@ -231,7 +243,7 @@ function toEdgeIdString(name) {
function toPath(value) {
const parts = value.split(',');
- return new Path(parts.map(_ => new Array(0)), parts.map(x => parseValue.call(this, x)));
+ return new Path(new Array(0), parts.map(x => parseValue.call(this, x)));
}
function toArray(stringList) {
@@ -273,6 +285,26 @@ function toLambda() {
throw new IgnoreError(IgnoreError.reason.lambdaNotSupported);
}
+/**
+ * Adapts the object to be compared, removing labels property of the Path.
+ */
+function toCompare(obj) {
+ if (!obj) {
+ return obj;
+ }
+ if (typeof obj !== 'object') {
+ return obj;
+ }
+ if (Array.isArray(obj)) {
+ return obj.map(toCompare);
+ }
+ if (obj instanceof Path) {
+ // labels are ignored
+ obj.labels = new Array(0);
+ }
+ return obj;
+}
+
function IgnoreError(reason) {
Error.call(this, reason);
Error.captureStackTrace(this, IgnoreError);
[39/47] tinkerpop git commit: Include information of Js development
env and release
Posted by jo...@apache.org.
Include information of Js development env and release
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/8d722a94
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/8d722a94
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/8d722a94
Branch: refs/heads/master
Commit: 8d722a94d3a280f031658d8e647b52740589cffa
Parents: 2afd971
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Jan 8 12:13:36 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:17 2018 +0100
----------------------------------------------------------------------
.../dev/developer/development-environment.asciidoc | 15 +++++++++++++++
gremlin-javascript/pom.xml | 10 ++++++++++
2 files changed, 25 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8d722a94/docs/src/dev/developer/development-environment.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/dev/developer/development-environment.asciidoc b/docs/src/dev/developer/development-environment.asciidoc
index 52542f8..b3b7706 100644
--- a/docs/src/dev/developer/development-environment.asciidoc
+++ b/docs/src/dev/developer/development-environment.asciidoc
@@ -131,6 +131,17 @@ This should update `~/.config/NuGet/NuGet.Config` a file with an entry containin
See release documentation for more information on configuration for release.
+
+[[nodejs-environment]]
+=== JavaScript Environment
+When building `gremlin-javascript`, mvn command will include a local copy of Node.js runtime and npm inside your project
+using `com.github.eirslett:frontend-maven-plugin` plugin. This copy of the Node.js runtime will not affect any
+other existing Node.js runtime instances in your machine.
+
+The release manager should have the authentication token set, for more information see the Release Environment
+section below.
+
+
[[release-environment]]
=== Release Environment
@@ -166,6 +177,10 @@ password =
The release manager shall use the project's pypi credentials, which are available in the PMC repository.
The `password` should be left blank so the deployment process in Maven will prompt for it at deployment time.
+To deploy `gremlin-javascript` on the link:https://www.npmjs.com[npm registry], the release manager must set the
+authentication information on the ~/.npmrc file. The easiest way to do that is to use the `npm adduser` command. This
+must be done only once, as the auth token doesn't have an expiration date and it's stored on your file system.
+
[[building-testing]]
== Building and Testing
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8d722a94/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 0825ba6..e55bc1e 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -246,6 +246,16 @@ limitations under the License.
<nodeVersion>v4.8.3</nodeVersion>
</configuration>
</plugin>
+ <!--
+ there is no point to deploying the jvm stuff - there is no java source really - just poms
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
</plugins>
</build>
<profiles>
[15/47] tinkerpop git commit: Use new server start groovy scripts
Posted by jo...@apache.org.
Use new server start groovy scripts
- Use new server start/stop groovy scripts
- Support different traversal sources at connection level
- Avoid destructuring syntax (not support on Node.js v4)
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9bf65000
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9bf65000
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9bf65000
Branch: refs/heads/master
Commit: 9bf6500026d10ceaaa64cc2b46dc8ce335f3d0d0
Parents: 56ddcb0
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Nov 23 10:20:19 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:15 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/glv/PackageJson.template | 4 +-
gremlin-javascript/pom.xml | 67 +++++++++++---------
.../lib/driver/driver-remote-connection.js | 6 +-
.../javascript/gremlin-javascript/package.json | 4 +-
.../test/cucumber/feature-steps.js | 29 +++++----
.../gremlin-javascript/test/cucumber/world.js | 12 +++-
.../gremlin-javascript/test/helper.js | 29 +++++++++
.../test/integration/remote-connection-tests.js | 18 ++----
.../test/integration/traversal-test.js | 16 ++---
9 files changed, 111 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf65000/gremlin-javascript/glv/PackageJson.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template
index 3ff17af..52d2c1d 100644
--- a/gremlin-javascript/glv/PackageJson.template
+++ b/gremlin-javascript/glv/PackageJson.template
@@ -47,8 +47,8 @@
"url": "https://issues.apache.org/jira/browse/TINKERPOP"
},
"scripts": {
- "test": "./node_modules/.bin/mocha test --recursive -t 5000",
- "features": "./node_modules/.bin/cucumber.js ../../../../../gremlin-test/features/",
+ "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
+ "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/Count.feature",
"unit-test": "./node_modules/.bin/mocha test/unit"
},
"engines": {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf65000/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 871fd7a..830052b 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -202,26 +202,30 @@ packageJsonFile.newWriter().withWriter{ it << packageJsonTemplate }
<goal>execute</goal>
</goals>
<configuration>
+ <properties>
+ <property>
+ <name>skipTests</name>
+ <value>${skipTests}</value>
+ </property>
+ <property>
+ <name>python</name>
+ <value>false</value>
+ </property>
+ <property>
+ <name>gremlinServerDir</name>
+ <value>${gremlin.server.dir}</value>
+ </property>
+ <property>
+ <name>settingsFile</name>
+ <value>${gremlin.server.dir}/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml</value>
+ </property>
+ <property>
+ <name>executionName</name>
+ <value>${project.name}</value>
+ </property>
+ </properties>
<scripts>
- <script>
- <![CDATA[
-import org.apache.tinkerpop.gremlin.server.GremlinServer
-import org.apache.tinkerpop.gremlin.server.Settings
-import org.apache.tinkerpop.gremlin.server.Settings.ScriptEngineSettings
-import org.apache.tinkerpop.gremlin.server.op.session.Session
-
-if (${skipIntegrationTests}) return
-log.info("Starting Gremlin Server instances for native testing of gremlin-javascript")
-def settings = Settings.read("${gremlin.server.dir}/conf/gremlin-server-modern.yaml")
-settings.graphs.graph = "${gremlin.server.dir}/conf/tinkergraph-empty.properties"
-settings.scriptEngines["gremlin-groovy"].scripts = ["${gremlin.server.dir}/scripts/generate-modern.groovy"]
-settings.port = 45950
-def server = new GremlinServer(settings)
-server.start().join()
-project.setContextValue("gremlin.javascript.server", server)
-log.info("Gremlin Server started on port 45950")
-]]>
- </script>
+ <script>${gremlin.server.dir}/src/test/scripts/test-server-start.groovy</script>
</scripts>
</configuration>
</execution>
@@ -232,19 +236,18 @@ log.info("Gremlin Server started on port 45950")
<goal>execute</goal>
</goals>
<configuration>
+ <properties>
+ <property>
+ <name>skipTests</name>
+ <value>${skipTests}</value>
+ </property>
+ <property>
+ <name>executionName</name>
+ <value>${project.name}</value>
+ </property>
+ </properties>
<scripts>
- <script>
- <![CDATA[
-import org.apache.tinkerpop.gremlin.server.GremlinServer
-import org.apache.tinkerpop.gremlin.server.op.session.Session
-
-if (${skipIntegrationTests}) return
-log.info("Tests for native gremlin-javascript complete")
-def server = project.getContextValue("gremlin.javascript.server")
-log.info("Shutting down $server")
-server.stop().join()
-]]>
- </script>
+ <script>${gremlin.server.dir}/src/test/scripts/test-server-stop.groovy</script>
</scripts>
</configuration>
</execution>
@@ -292,6 +295,7 @@ server.stop().join()
</goals>
<configuration>
<arguments>test</arguments>
+ <failOnError>true</failOnError>
</configuration>
</execution>
<execution>
@@ -302,6 +306,7 @@ server.stop().join()
</goals>
<configuration>
<arguments>run-script features</arguments>
+ <failOnError>true</failOnError>
</configuration>
</execution>
</executions>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf65000/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index 0d6d507..18c551c 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -41,6 +41,7 @@ var responseStatusCode = {
* Creates a new instance of DriverRemoteConnection.
* @param {String} url The resource uri.
* @param {Object} [options] The connection options.
+ * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
* @param {Array} [options.ca] Trusted certificates.
* @param {String|Array|Buffer} [options.cert] The certificate key.
* @param {String|Buffer} [options.pfx] The private key, certificate, and CA certs.
@@ -71,6 +72,7 @@ function DriverRemoteConnection(url, options) {
this._responseHandlers = {};
this._reader = options.reader || new serializer.GraphSONReader();
this._writer = options.writer || new serializer.GraphSONWriter();
+ this._traversalSource = options.traversalSource || 'g';
this._openPromise = null;
this._openCallback = null;
this._closePromise = null;
@@ -125,7 +127,7 @@ DriverRemoteConnection.prototype._getRequest = function (id, bytecode) {
'processor': 'traversal',
'args': {
'gremlin': this._writer.adaptObject(bytecode),
- 'aliases': { 'g': 'g'}
+ 'aliases': { 'g': this._traversalSource }
}
});
};
@@ -193,7 +195,7 @@ function getUuid() {
hex.substr(20, 12));
}
-var bufferFromString = Buffer.from || function newBuffer(text) {
+const bufferFromString = (Int8Array.from !== Buffer.from && Buffer.from) || function newBuffer(text) {
return new Buffer(text, 'utf8');
};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf65000/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index dfbaff2..43cf35f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -28,8 +28,8 @@
"url": "https://issues.apache.org/jira/browse/TINKERPOP"
},
"scripts": {
- "test": "./node_modules/.bin/mocha test --recursive -t 5000",
- "features": "./node_modules/.bin/cucumber.js ../../../../../gremlin-test/features/",
+ "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
+ "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/Count.feature",
"unit-test": "./node_modules/.bin/mocha test/unit"
},
"engines": {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf65000/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 10680b7..bea7321 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -22,34 +22,37 @@
*/
'use strict';
-const {defineSupportCode} = require('cucumber');
+const defineSupportCode = require('cucumber').defineSupportCode;
const vm = require('vm');
-defineSupportCode(function({Given, When, Then}) {
- Given(/^the (.+) graph$/, function (graphName) {
+defineSupportCode(function(methods) {
+ methods.Given(/^the (.+) graph$/, function (graphName) {
//TODO: Set context g
});
- // Given('the graph initializer of');
- Given('an unsupported test', () => {});
+ methods.Given('the graph initializer of', function () {
+ //TODO
+ });
+
+ methods.Given('an unsupported test', () => {});
- Given('the traversal of', function (traversalText) {
+ methods.Given('the traversal of', function (traversalText) {
//TODO: make traversal
});
- Given(/^$/, function (paramName, stringValue) {
+ methods.Given(/^$/, function (paramName, stringValue) {
//TODO: Add parameter
});
- When('iterated to list', function () {
+ methods.When('iterated to list', function () {
//TODO
});
- When('iterated next', function () {
+ methods.When('iterated next', function () {
//TODO
});
- Then(/^the result should be (\w+)$/, function (characterizedAs, resultTable) {
+ methods.Then(/^the result should be (\w+)$/, function (characterizedAs, resultTable) {
//TODO
//console.log('--resultTable', resultTable.rows());
if (typeof resultTable === 'function'){
@@ -57,13 +60,13 @@ defineSupportCode(function({Given, When, Then}) {
}
});
- Then(/^the graph should return (\d+) for count of (.+)$/, function (stringCount, traversalString) {
+ methods.Then(/^the graph should return (\d+) for count of (.+)$/, function (stringCount, traversalString) {
});
- Then(/^the result should have a count of (\d+)$/, function (stringCount) {
+ methods.Then(/^the result should have a count of (\d+)$/, function (stringCount) {
});
- Then('nothing should happen because', () => {});
+ methods.Then('nothing should happen because', () => {});
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf65000/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
index f1cd7a6..2e4f6e1 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -22,12 +22,18 @@
*/
'use strict';
-const {defineSupportCode} = require('cucumber');
+const defineSupportCode = require('cucumber').defineSupportCode;
-defineSupportCode(function ({setWorldConstructor}) {
+defineSupportCode(function (methods) {
function TinkerPopWorld(){
this.g = null;
this.traversal = null;
}
- setWorldConstructor(TinkerPopWorld);
+ methods.setWorldConstructor(TinkerPopWorld);
+ methods.BeforeAll(function () {
+ // load all traversals
+ });
+ methods.Before(function () {
+
+ });
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf65000/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
new file mode 100644
index 0000000..546840e
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+const DriverRemoteConnection = require('../lib/driver/driver-remote-connection');
+
+exports.getConnection = function getConnection(traversalSource) {
+ return new DriverRemoteConnection('ws://localhost:45940/gremlin', { traversalSource: traversalSource });
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf65000/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
index df813ad..268773c 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
@@ -22,16 +22,16 @@
*/
'use strict';
-var assert = require('assert');
-var Bytecode = require('../../lib/process/bytecode');
-var DriverRemoteConnection = require('../../lib/driver/driver-remote-connection');
-var graphModule = require('../../lib/structure/graph');
+const assert = require('assert');
+const Bytecode = require('../../lib/process/bytecode');
+const graphModule = require('../../lib/structure/graph');
+const helper = require('../helper');
var connection;
describe('DriverRemoteConnection', function () {
before(function () {
- connection = new DriverRemoteConnection('ws://localhost:45950/gremlin');
+ connection = helper.getConnection();
return connection.open();
});
after(function () {
@@ -55,10 +55,4 @@ describe('DriverRemoteConnection', function () {
});
});
});
-});
-
-function delay(ms) {
- return new Promise(function (resolve) {
- setTimeout(resolve, ms);
- });
-}
\ No newline at end of file
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf65000/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
index 90afced..96de7c7 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
@@ -22,20 +22,18 @@
*/
'use strict';
-var assert = require('assert');
-var graphModule = require('../../lib/structure/graph');
-var Graph = graphModule.Graph;
-var Vertex = graphModule.Vertex;
-var utils = require('../../lib/utils');
-var t = require('../../lib/process/traversal');
-var TraversalStrategies = require('../../lib/process/traversal-strategy').TraversalStrategies;
-var DriverRemoteConnection = require('../../lib/driver/driver-remote-connection');
+const assert = require('assert');
+const graphModule = require('../../lib/structure/graph');
+const Graph = graphModule.Graph;
+const Vertex = graphModule.Vertex;
+const utils = require('../../lib/utils');
+const helper = require('../helper');
var connection;
describe('Traversal', function () {
before(function () {
- connection = new DriverRemoteConnection('ws://localhost:45950/gremlin');
+ connection = helper.getConnection();
return connection.open();
});
after(function () {
[24/47] tinkerpop git commit: Support bulk
Posted by jo...@apache.org.
Support bulk
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/53a7f279
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/53a7f279
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/53a7f279
Branch: refs/heads/master
Commit: 53a7f2798209de4c2a8449d3676ca00785360858
Parents: 15c8679
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Nov 27 12:13:28 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:16 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/glv/TraversalSource.template | 48 +++++++------
.../gremlin-javascript/lib/process/traversal.js | 48 +++++++------
.../test/unit/traversal-test.js | 71 ++++++++++++++++++--
3 files changed, 119 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/53a7f279/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index dbb7bc4..f75765f 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -22,15 +22,15 @@
*/
'use strict';
-var utils = require('../utils');
-var parseArgs = utils.parseArgs;
-var itemDone = Object.freeze({ value: null, done: true });
-var emptyArray = Object.freeze([]);
+const utils = require('../utils');
+const parseArgs = utils.parseArgs;
+const itemDone = Object.freeze({ value: null, done: true });
function Traversal(graph, traversalStrategies, bytecode) {
this.graph = graph;
this.traversalStrategies = traversalStrategies;
this.bytecode = bytecode;
+ /** @type {Array<Traverser>} */
this.traversers = null;
this.sideEffects = null;
this._traversalStrategiesPromise = null;
@@ -47,17 +47,13 @@ Traversal.prototype.getBytecode = function () {
* @returns {Promise.<Array>}
*/
Traversal.prototype.toList = function () {
- var self = this;
- return this._applyStrategies().then(function () {
- if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
- return emptyArray;
+ return this._applyStrategies().then(() => {
+ const result = [];
+ let it;
+ while ((it = this._getNext()) && !it.done) {
+ result.push(it.value);
}
- var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
- for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
- arr[i] = self.traversers[i].object;
- }
- self._traversersIteratorIndex = self.traversers.length;
- return arr;
+ return result;
});
};
@@ -67,13 +63,23 @@ Traversal.prototype.toList = function () {
* @returns {Promise.<{value, done}>}
*/
Traversal.prototype.next = function () {
- var self = this;
- return this._applyStrategies().then(function () {
- if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
- return itemDone;
+ return this._applyStrategies().then(() => this._getNext());
+};
+
+/**
+ * Synchronous iterator of traversers including
+ * @private
+ */
+Traversal.prototype._getNext = function () {
+ while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
+ let traverser = this.traversers[this._traversersIteratorIndex];
+ if (traverser.bulk > 0) {
+ traverser.bulk--;
+ return { value: traverser.object, done: false };
}
- return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
- });
+ this._traversersIteratorIndex++;
+ }
+ return itemDone;
};
Traversal.prototype._applyStrategies = function () {
@@ -133,7 +139,7 @@ P.prototype.or = function (arg) {
function Traverser(object, bulk) {
this.object = object;
- this.bulk = bulk == undefined ? 1 : bulk;
+ this.bulk = bulk || 1;
}
function TraversalSideEffects() {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/53a7f279/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index 49c6aef..ebf8755 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -22,15 +22,15 @@
*/
'use strict';
-var utils = require('../utils');
-var parseArgs = utils.parseArgs;
-var itemDone = Object.freeze({ value: null, done: true });
-var emptyArray = Object.freeze([]);
+const utils = require('../utils');
+const parseArgs = utils.parseArgs;
+const itemDone = Object.freeze({ value: null, done: true });
function Traversal(graph, traversalStrategies, bytecode) {
this.graph = graph;
this.traversalStrategies = traversalStrategies;
this.bytecode = bytecode;
+ /** @type {Array<Traverser>} */
this.traversers = null;
this.sideEffects = null;
this._traversalStrategiesPromise = null;
@@ -47,17 +47,13 @@ Traversal.prototype.getBytecode = function () {
* @returns {Promise.<Array>}
*/
Traversal.prototype.toList = function () {
- var self = this;
- return this._applyStrategies().then(function () {
- if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
- return emptyArray;
+ return this._applyStrategies().then(() => {
+ const result = [];
+ let it;
+ while ((it = this._getNext()) && !it.done) {
+ result.push(it.value);
}
- var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
- for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
- arr[i] = self.traversers[i].object;
- }
- self._traversersIteratorIndex = self.traversers.length;
- return arr;
+ return result;
});
};
@@ -67,13 +63,23 @@ Traversal.prototype.toList = function () {
* @returns {Promise.<{value, done}>}
*/
Traversal.prototype.next = function () {
- var self = this;
- return this._applyStrategies().then(function () {
- if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
- return itemDone;
+ return this._applyStrategies().then(() => this._getNext());
+};
+
+/**
+ * Synchronous iterator of traversers including
+ * @private
+ */
+Traversal.prototype._getNext = function () {
+ while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
+ let traverser = this.traversers[this._traversersIteratorIndex];
+ if (traverser.bulk > 0) {
+ traverser.bulk--;
+ return { value: traverser.object, done: false };
}
- return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
- });
+ this._traversersIteratorIndex++;
+ }
+ return itemDone;
};
Traversal.prototype._applyStrategies = function () {
@@ -193,7 +199,7 @@ P.prototype.or = function (arg) {
function Traverser(object, bulk) {
this.object = object;
- this.bulk = bulk == undefined ? 1 : bulk;
+ this.bulk = bulk || 1;
}
function TraversalSideEffects() {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/53a7f279/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
index c5271c9..635c7e8 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
@@ -22,14 +22,17 @@
*/
'use strict';
-var assert = require('assert');
-var graph = require('../../lib/structure/graph');
-var utils = require('../../lib/utils');
-var t = require('../../lib/process/traversal');
-var TraversalStrategies = require('../../lib/process/traversal-strategy').TraversalStrategies;
+const assert = require('assert');
+const expect = require('chai').expect;
+const graph = require('../../lib/structure/graph');
+const utils = require('../../lib/utils');
+const t = require('../../lib/process/traversal');
+const TraversalStrategies = require('../../lib/process/traversal-strategy').TraversalStrategies;
describe('Traversal', function () {
+
describe('#getByteCode()', function () {
+
it('should add steps for with a string parameter', function () {
var g = new graph.Graph().traversal();
var bytecode = g.V().out('created').getBytecode();
@@ -40,6 +43,7 @@ describe('Traversal', function () {
assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
});
+
it('should add steps with an enum value', function () {
var g = new graph.Graph().traversal();
var bytecode = g.V().order().by('age', t.order.decr).getBytecode();
@@ -55,7 +59,9 @@ describe('Traversal', function () {
assert.strictEqual(bytecode.stepInstructions[2][2].elementName, 'decr');
});
});
+
describe('#next()', function () {
+
it('should apply the strategies and return a Promise with the iterator item', function () {
var strategyMock = {
apply: function (traversal) {
@@ -83,8 +89,43 @@ describe('Traversal', function () {
return traversal.next();
});
});
+
+ it('should support bulk', function () {
+ const strategyMock = {
+ apply: function (traversal) {
+ traversal.traversers = [ new t.Traverser(1, 2), new t.Traverser(2, 1) ];
+ return utils.resolvedPromise();
+ }
+ };
+ const strategies = new TraversalStrategies();
+ strategies.addStrategy(strategyMock);
+ const traversal = new t.Traversal(null, strategies, null);
+ return traversal.next()
+ .then(function (item) {
+ assert.strictEqual(item.value, 1);
+ assert.strictEqual(item.done, false);
+ return traversal.next();
+ })
+ .then(function (item) {
+ assert.strictEqual(item.value, 1);
+ assert.strictEqual(item.done, false);
+ return traversal.next();
+ })
+ .then(function (item) {
+ assert.strictEqual(item.value, 2);
+ assert.strictEqual(item.done, false);
+ return traversal.next();
+ })
+ .then(function (item) {
+ assert.strictEqual(item.value, null);
+ assert.strictEqual(item.done, true);
+ return traversal.next();
+ });
+ });
});
+
describe('#toList()', function () {
+
it('should apply the strategies and return a Promise with an array', function () {
var strategyMock = {
apply: function (traversal) {
@@ -100,6 +141,7 @@ describe('Traversal', function () {
assert.deepEqual(list, [ 'a', 'b' ]);
});
});
+
it('should return an empty array when traversers is empty', function () {
var strategyMock = {
apply: function (traversal) {
@@ -114,6 +156,23 @@ describe('Traversal', function () {
assert.ok(Array.isArray(list));
assert.strictEqual(list.length, 0);
});
- })
+ });
+
+ it('should support bulk', function () {
+ const strategyMock = {
+ apply: function (traversal) {
+ traversal.traversers = [ new t.Traverser(1, 1), new t.Traverser(2, 3), new t.Traverser(3, 2),
+ new t.Traverser(4, 1) ];
+ return utils.resolvedPromise();
+ }
+ };
+ const strategies = new TraversalStrategies();
+ strategies.addStrategy(strategyMock);
+ const traversal = new t.Traversal(null, strategies, null);
+ return traversal.toList()
+ .then(list => {
+ expect(list).to.have.members([1, 2, 2, 2, 3, 3, 4]);
+ });
+ });
});
});
\ No newline at end of file
[02/47] tinkerpop git commit: Javascript GLV
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
new file mode 100644
index 0000000..d9803ba
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -0,0 +1,2025 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineGraphTraversalModule() {
+ "use strict";
+
+ var t = loadModule.call(this, './traversal.js');
+ var remote = loadModule.call(this, '../driver/remote-connection.js');
+ var Bytecode = t.Bytecode;
+ var inherits = t.inherits;
+ var parseArgs = t.parseArgs;
+
+ /**
+ *
+ * @param {Graph} graph
+ * @param {TraversalStrategies} traversalStrategies
+ * @param {Bytecode} [bytecode]
+ * @constructor
+ */
+ function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+ this._graph = graph;
+ this._traversalStrategies = traversalStrategies;
+ this._bytecode = bytecode || new Bytecode();
+ }
+
+ /**
+ * @param remoteConnection
+ * @returns {GraphTraversal}
+ */
+ GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+ var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+ traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+ return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+ };
+
+ /**
+ * Returns the string representation of the GraphTraversalSource.
+ * @returns {string}
+ */
+ GraphTraversalSource.prototype.toString = function () {
+ return 'graphtraversalsource[' + this._graph.toString() + ']';
+ };
+
+ /**
+ * withBulk GraphTraversalSource method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ GraphTraversalSource.prototype.withBulk = function (args) {
+ var b = new Bytecode(this._bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+
+ /**
+ * withComputer GraphTraversalSource method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ GraphTraversalSource.prototype.withComputer = function (args) {
+ var b = new Bytecode(this._bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+
+ /**
+ * withPath GraphTraversalSource method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ GraphTraversalSource.prototype.withPath = function (args) {
+ var b = new Bytecode(this._bytecode).addSource('withPath', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+
+ /**
+ * withSack GraphTraversalSource method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ GraphTraversalSource.prototype.withSack = function (args) {
+ var b = new Bytecode(this._bytecode).addSource('withSack', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+
+ /**
+ * withSideEffect GraphTraversalSource method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ GraphTraversalSource.prototype.withSideEffect = function (args) {
+ var b = new Bytecode(this._bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+
+ /**
+ * withStrategies GraphTraversalSource method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ GraphTraversalSource.prototype.withStrategies = function (args) {
+ var b = new Bytecode(this._bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+
+ /**
+ * withoutStrategies GraphTraversalSource method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ GraphTraversalSource.prototype.withoutStrategies = function (args) {
+ var b = new Bytecode(this._bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+
+ /**
+ * E GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversalSource.prototype.E = function (args) {
+ var b = new Bytecode(this._bytecode).addStep('E', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+
+ /**
+ * V GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversalSource.prototype.V = function (args) {
+ var b = new Bytecode(this._bytecode).addStep('V', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+
+ /**
+ * addV GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversalSource.prototype.addV = function (args) {
+ var b = new Bytecode(this._bytecode).addStep('addV', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+
+ /**
+ * inject GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversalSource.prototype.inject = function (args) {
+ var b = new Bytecode(this._bytecode).addStep('inject', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+
+ /**
+ * Represents a graph traversal.
+ * @constructor
+ */
+ function GraphTraversal(graph, traversalStrategies, bytecode) {
+ t.Traversal.call(this, graph, traversalStrategies, bytecode);
+ }
+
+ inherits(GraphTraversal, t.Traversal);
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.V = function (args) {
+ this._bytecode.addStep('V', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.addE = function (args) {
+ this._bytecode.addStep('addE', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.addInE = function (args) {
+ this._bytecode.addStep('addInE', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.addOutE = function (args) {
+ this._bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.addV = function (args) {
+ this._bytecode.addStep('addV', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.aggregate = function (args) {
+ this._bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.and = function (args) {
+ this._bytecode.addStep('and', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.as = function (args) {
+ this._bytecode.addStep('as', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.barrier = function (args) {
+ this._bytecode.addStep('barrier', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.both = function (args) {
+ this._bytecode.addStep('both', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.bothE = function (args) {
+ this._bytecode.addStep('bothE', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.bothV = function (args) {
+ this._bytecode.addStep('bothV', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.branch = function (args) {
+ this._bytecode.addStep('branch', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.by = function (args) {
+ this._bytecode.addStep('by', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.cap = function (args) {
+ this._bytecode.addStep('cap', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.choose = function (args) {
+ this._bytecode.addStep('choose', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.coalesce = function (args) {
+ this._bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.coin = function (args) {
+ this._bytecode.addStep('coin', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.constant = function (args) {
+ this._bytecode.addStep('constant', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.count = function (args) {
+ this._bytecode.addStep('count', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.cyclicPath = function (args) {
+ this._bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.dedup = function (args) {
+ this._bytecode.addStep('dedup', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.drop = function (args) {
+ this._bytecode.addStep('drop', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.emit = function (args) {
+ this._bytecode.addStep('emit', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.filter = function (args) {
+ this._bytecode.addStep('filter', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.flatMap = function (args) {
+ this._bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.fold = function (args) {
+ this._bytecode.addStep('fold', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.from_ = function (args) {
+ this._bytecode.addStep('from', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.group = function (args) {
+ this._bytecode.addStep('group', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.groupCount = function (args) {
+ this._bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.groupV3d0 = function (args) {
+ this._bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.has = function (args) {
+ this._bytecode.addStep('has', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.hasId = function (args) {
+ this._bytecode.addStep('hasId', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.hasKey = function (args) {
+ this._bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.hasLabel = function (args) {
+ this._bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.hasNot = function (args) {
+ this._bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.hasValue = function (args) {
+ this._bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.id = function (args) {
+ this._bytecode.addStep('id', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.identity = function (args) {
+ this._bytecode.addStep('identity', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.inE = function (args) {
+ this._bytecode.addStep('inE', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.inV = function (args) {
+ this._bytecode.addStep('inV', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.in_ = function (args) {
+ this._bytecode.addStep('in', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.inject = function (args) {
+ this._bytecode.addStep('inject', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.is = function (args) {
+ this._bytecode.addStep('is', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.key = function (args) {
+ this._bytecode.addStep('key', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.label = function (args) {
+ this._bytecode.addStep('label', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.limit = function (args) {
+ this._bytecode.addStep('limit', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.local = function (args) {
+ this._bytecode.addStep('local', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.loops = function (args) {
+ this._bytecode.addStep('loops', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.map = function (args) {
+ this._bytecode.addStep('map', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.mapKeys = function (args) {
+ this._bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.mapValues = function (args) {
+ this._bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.match = function (args) {
+ this._bytecode.addStep('match', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.max = function (args) {
+ this._bytecode.addStep('max', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.mean = function (args) {
+ this._bytecode.addStep('mean', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.min = function (args) {
+ this._bytecode.addStep('min', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.not = function (args) {
+ this._bytecode.addStep('not', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.option = function (args) {
+ this._bytecode.addStep('option', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.optional = function (args) {
+ this._bytecode.addStep('optional', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.or = function (args) {
+ this._bytecode.addStep('or', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.order = function (args) {
+ this._bytecode.addStep('order', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.otherV = function (args) {
+ this._bytecode.addStep('otherV', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.out = function (args) {
+ this._bytecode.addStep('out', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.outE = function (args) {
+ this._bytecode.addStep('outE', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.outV = function (args) {
+ this._bytecode.addStep('outV', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.pageRank = function (args) {
+ this._bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.path = function (args) {
+ this._bytecode.addStep('path', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.peerPressure = function (args) {
+ this._bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.profile = function (args) {
+ this._bytecode.addStep('profile', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.program = function (args) {
+ this._bytecode.addStep('program', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.project = function (args) {
+ this._bytecode.addStep('project', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.properties = function (args) {
+ this._bytecode.addStep('properties', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.property = function (args) {
+ this._bytecode.addStep('property', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.propertyMap = function (args) {
+ this._bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.range = function (args) {
+ this._bytecode.addStep('range', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.repeat = function (args) {
+ this._bytecode.addStep('repeat', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.sack = function (args) {
+ this._bytecode.addStep('sack', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.sample = function (args) {
+ this._bytecode.addStep('sample', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.select = function (args) {
+ this._bytecode.addStep('select', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.sideEffect = function (args) {
+ this._bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.simplePath = function (args) {
+ this._bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.store = function (args) {
+ this._bytecode.addStep('store', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.subgraph = function (args) {
+ this._bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.sum = function (args) {
+ this._bytecode.addStep('sum', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.tail = function (args) {
+ this._bytecode.addStep('tail', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.timeLimit = function (args) {
+ this._bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.times = function (args) {
+ this._bytecode.addStep('times', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.to = function (args) {
+ this._bytecode.addStep('to', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.toE = function (args) {
+ this._bytecode.addStep('toE', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.toV = function (args) {
+ this._bytecode.addStep('toV', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.tree = function (args) {
+ this._bytecode.addStep('tree', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.unfold = function (args) {
+ this._bytecode.addStep('unfold', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.union = function (args) {
+ this._bytecode.addStep('union', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.until = function (args) {
+ this._bytecode.addStep('until', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.value = function (args) {
+ this._bytecode.addStep('value', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.valueMap = function (args) {
+ this._bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.values = function (args) {
+ this._bytecode.addStep('values', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.where = function (args) {
+ this._bytecode.addStep('where', parseArgs.apply(null, arguments));
+ return this;
+ };
+
+ /**
+ * Contains the static method definitions
+ * @type {Object}
+ */
+ var statics = {};
+
+ /**
+ * V() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.V = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.V.apply(g, arguments);
+ };
+
+ /**
+ * __() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.__ = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.__.apply(g, arguments);
+ };
+
+ /**
+ * addE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.addE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.addE.apply(g, arguments);
+ };
+
+ /**
+ * addInE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.addInE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.addInE.apply(g, arguments);
+ };
+
+ /**
+ * addOutE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.addOutE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.addOutE.apply(g, arguments);
+ };
+
+ /**
+ * addV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.addV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.addV.apply(g, arguments);
+ };
+
+ /**
+ * aggregate() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.aggregate = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.aggregate.apply(g, arguments);
+ };
+
+ /**
+ * and() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.and = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.and.apply(g, arguments);
+ };
+
+ /**
+ * as() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.as = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.as.apply(g, arguments);
+ };
+
+ /**
+ * barrier() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.barrier = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.barrier.apply(g, arguments);
+ };
+
+ /**
+ * both() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.both = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.both.apply(g, arguments);
+ };
+
+ /**
+ * bothE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.bothE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.bothE.apply(g, arguments);
+ };
+
+ /**
+ * bothV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.bothV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.bothV.apply(g, arguments);
+ };
+
+ /**
+ * branch() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.branch = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.branch.apply(g, arguments);
+ };
+
+ /**
+ * cap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.cap = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.cap.apply(g, arguments);
+ };
+
+ /**
+ * choose() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.choose = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.choose.apply(g, arguments);
+ };
+
+ /**
+ * coalesce() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.coalesce = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.coalesce.apply(g, arguments);
+ };
+
+ /**
+ * coin() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.coin = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.coin.apply(g, arguments);
+ };
+
+ /**
+ * constant() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.constant = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.constant.apply(g, arguments);
+ };
+
+ /**
+ * count() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.count = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.count.apply(g, arguments);
+ };
+
+ /**
+ * cyclicPath() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.cyclicPath = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.cyclicPath.apply(g, arguments);
+ };
+
+ /**
+ * dedup() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.dedup = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.dedup.apply(g, arguments);
+ };
+
+ /**
+ * drop() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.drop = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.drop.apply(g, arguments);
+ };
+
+ /**
+ * emit() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.emit = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.emit.apply(g, arguments);
+ };
+
+ /**
+ * filter() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.filter = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.filter.apply(g, arguments);
+ };
+
+ /**
+ * flatMap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.flatMap = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.flatMap.apply(g, arguments);
+ };
+
+ /**
+ * fold() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.fold = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.fold.apply(g, arguments);
+ };
+
+ /**
+ * group() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.group = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.group.apply(g, arguments);
+ };
+
+ /**
+ * groupCount() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.groupCount = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.groupCount.apply(g, arguments);
+ };
+
+ /**
+ * groupV3d0() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.groupV3d0 = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.groupV3d0.apply(g, arguments);
+ };
+
+ /**
+ * has() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.has = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.has.apply(g, arguments);
+ };
+
+ /**
+ * hasId() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.hasId = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.hasId.apply(g, arguments);
+ };
+
+ /**
+ * hasKey() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.hasKey = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.hasKey.apply(g, arguments);
+ };
+
+ /**
+ * hasLabel() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.hasLabel = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.hasLabel.apply(g, arguments);
+ };
+
+ /**
+ * hasNot() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.hasNot = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.hasNot.apply(g, arguments);
+ };
+
+ /**
+ * hasValue() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.hasValue = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.hasValue.apply(g, arguments);
+ };
+
+ /**
+ * id() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.id = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.id.apply(g, arguments);
+ };
+
+ /**
+ * identity() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.identity = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.identity.apply(g, arguments);
+ };
+
+ /**
+ * inE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.inE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.inE.apply(g, arguments);
+ };
+
+ /**
+ * inV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.inV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.inV.apply(g, arguments);
+ };
+
+ /**
+ * in_() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.in_ = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.in_.apply(g, arguments);
+ };
+
+ /**
+ * inject() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.inject = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.inject.apply(g, arguments);
+ };
+
+ /**
+ * is() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.is = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.is.apply(g, arguments);
+ };
+
+ /**
+ * key() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.key = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.key.apply(g, arguments);
+ };
+
+ /**
+ * label() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.label = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.label.apply(g, arguments);
+ };
+
+ /**
+ * limit() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.limit = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.limit.apply(g, arguments);
+ };
+
+ /**
+ * local() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.local = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.local.apply(g, arguments);
+ };
+
+ /**
+ * loops() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.loops = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.loops.apply(g, arguments);
+ };
+
+ /**
+ * map() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.map = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.map.apply(g, arguments);
+ };
+
+ /**
+ * mapKeys() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.mapKeys = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.mapKeys.apply(g, arguments);
+ };
+
+ /**
+ * mapValues() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.mapValues = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.mapValues.apply(g, arguments);
+ };
+
+ /**
+ * match() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.match = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.match.apply(g, arguments);
+ };
+
+ /**
+ * max() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.max = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.max.apply(g, arguments);
+ };
+
+ /**
+ * mean() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.mean = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.mean.apply(g, arguments);
+ };
+
+ /**
+ * min() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.min = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.min.apply(g, arguments);
+ };
+
+ /**
+ * not() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.not = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.not.apply(g, arguments);
+ };
+
+ /**
+ * optional() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.optional = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.optional.apply(g, arguments);
+ };
+
+ /**
+ * or() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.or = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.or.apply(g, arguments);
+ };
+
+ /**
+ * order() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.order = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.order.apply(g, arguments);
+ };
+
+ /**
+ * otherV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.otherV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.otherV.apply(g, arguments);
+ };
+
+ /**
+ * out() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.out = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.out.apply(g, arguments);
+ };
+
+ /**
+ * outE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.outE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.outE.apply(g, arguments);
+ };
+
+ /**
+ * outV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.outV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.outV.apply(g, arguments);
+ };
+
+ /**
+ * path() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.path = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.path.apply(g, arguments);
+ };
+
+ /**
+ * project() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.project = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.project.apply(g, arguments);
+ };
+
+ /**
+ * properties() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.properties = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.properties.apply(g, arguments);
+ };
+
+ /**
+ * property() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.property = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.property.apply(g, arguments);
+ };
+
+ /**
+ * propertyMap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.propertyMap = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.propertyMap.apply(g, arguments);
+ };
+
+ /**
+ * range() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.range = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.range.apply(g, arguments);
+ };
+
+ /**
+ * repeat() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.repeat = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.repeat.apply(g, arguments);
+ };
+
+ /**
+ * sack() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.sack = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.sack.apply(g, arguments);
+ };
+
+ /**
+ * sample() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.sample = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.sample.apply(g, arguments);
+ };
+
+ /**
+ * select() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.select = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.select.apply(g, arguments);
+ };
+
+ /**
+ * sideEffect() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.sideEffect = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.sideEffect.apply(g, arguments);
+ };
+
+ /**
+ * simplePath() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.simplePath = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.simplePath.apply(g, arguments);
+ };
+
+ /**
+ * start() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.start = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.start.apply(g, arguments);
+ };
+
+ /**
+ * store() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.store = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.store.apply(g, arguments);
+ };
+
+ /**
+ * subgraph() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.subgraph = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.subgraph.apply(g, arguments);
+ };
+
+ /**
+ * sum() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.sum = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.sum.apply(g, arguments);
+ };
+
+ /**
+ * tail() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.tail = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.tail.apply(g, arguments);
+ };
+
+ /**
+ * timeLimit() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.timeLimit = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.timeLimit.apply(g, arguments);
+ };
+
+ /**
+ * times() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.times = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.times.apply(g, arguments);
+ };
+
+ /**
+ * to() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.to = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.to.apply(g, arguments);
+ };
+
+ /**
+ * toE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.toE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.toE.apply(g, arguments);
+ };
+
+ /**
+ * toV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.toV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.toV.apply(g, arguments);
+ };
+
+ /**
+ * tree() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.tree = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.tree.apply(g, arguments);
+ };
+
+ /**
+ * unfold() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.unfold = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.unfold.apply(g, arguments);
+ };
+
+ /**
+ * union() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.union = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.union.apply(g, arguments);
+ };
+
+ /**
+ * until() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.until = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.until.apply(g, arguments);
+ };
+
+ /**
+ * value() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.value = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.value.apply(g, arguments);
+ };
+
+ /**
+ * valueMap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.valueMap = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.valueMap.apply(g, arguments);
+ };
+
+ /**
+ * values() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.values = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.values.apply(g, arguments);
+ };
+
+ /**
+ * where() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.where = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.where.apply(g, arguments);
+ };
+
+ function loadModule(moduleName) {
+ if (typeof require !== 'undefined') {
+ return require(moduleName);
+ }
+ if (typeof load !== 'undefined') {
+ var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+ this.__dependencies = this.__dependencies || {};
+ return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+ }
+ throw new Error('No module loader was found');
+ }
+
+ var toExport = {
+ GraphTraversal: GraphTraversal,
+ GraphTraversalSource: GraphTraversalSource,
+ statics: statics
+ };
+ if (typeof module !== 'undefined') {
+ // CommonJS
+ module.exports = toExport;
+ return;
+ }
+ // Nashorn and rest
+ return toExport;
+}).call(this);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
new file mode 100644
index 0000000..5c9bf6c
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTraversalModule() {
+ "use strict";
+
+ function Traversal(graph, traversalStrategies, bytecode) {
+ this._graph = graph;
+ this._traversalStrategies = traversalStrategies;
+ this._bytecode = bytecode;
+ this.traversers = null;
+ this.sideEffects = null;
+ }
+
+ /** @returns {Bytecode} */
+ Traversal.prototype.getBytecode = function () {
+ return this._bytecode;
+ };
+
+ /** @param {Function} callback */
+ Traversal.prototype.list = function (callback) {
+ var self = this;
+ this._traversalStrategies.applyStrategies(this, function (err) {
+ if (err) {
+ return callback(err);
+ }
+ callback(err, self.traversers);
+ });
+ };
+
+ /** @param {Function} callback */
+ Traversal.prototype.one = function (callback) {
+ this.list(function (err, result) {
+ callback(err, result ? result[0] : null);
+ });
+ };
+
+ /**
+ * Returns the Bytecode JSON representation of the traversal
+ * @returns {String}
+ */
+ Traversal.prototype.toString = function () {
+ return this._bytecode.toString();
+ };
+
+ /**
+ * Represents an operation.
+ * @constructor
+ */
+ function P(operator, value, other) {
+ this.operator = operator;
+ this.value = value;
+ this.other = other;
+ }
+
+ /**
+ * Returns the string representation of the instance.
+ * @returns {string}
+ */
+ P.prototype.toString = function () {
+ if (this.other === undefined) {
+ return this.operator + '(' + this.value + ')';
+ }
+ return this.operator + '(' + this.value + ', ' + this.other + ')';
+ };
+
+ function createP(operator, args) {
+ args.unshift(null, operator);
+ return new (Function.prototype.bind.apply(P, args));
+ }
+
+ /** @param {...Object} args */
+ P.between = function (args) {
+ return createP('between', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.eq = function (args) {
+ return createP('eq', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.gt = function (args) {
+ return createP('gt', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.gte = function (args) {
+ return createP('gte', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.inside = function (args) {
+ return createP('inside', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.lt = function (args) {
+ return createP('lt', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.lte = function (args) {
+ return createP('lte', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.neq = function (args) {
+ return createP('neq', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.not = function (args) {
+ return createP('not', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.outside = function (args) {
+ return createP('outside', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.test = function (args) {
+ return createP('test', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.within = function (args) {
+ return createP('within', parseArgs.apply(null, arguments));
+ };
+
+ /** @param {...Object} args */
+ P.without = function (args) {
+ return createP('without', parseArgs.apply(null, arguments));
+ };
+
+ P.prototype.and = function (arg) {
+ return new P('and', this, arg);
+ };
+
+ P.prototype.or = function (arg) {
+ return new P('or', this, arg);
+ };
+
+ function Traverser(object, bulk) {
+ this.object = object;
+ this.bulk = bulk == undefined ? 1 : bulk;
+ }
+
+ function TraversalSideEffects() {
+
+ }
+
+ /**
+ * Creates a new instance of TraversalStrategies.
+ * @param {TraversalStrategies} [traversalStrategies]
+ * @constructor
+ */
+ function TraversalStrategies(traversalStrategies) {
+ /** @type {Array<TraversalStrategy>} */
+ this.strategies = traversalStrategies ? traversalStrategies.strategies : [];
+ }
+
+ /** @param {TraversalStrategy} strategy */
+ TraversalStrategies.prototype.addStrategy = function (strategy) {
+ this.strategies.push(strategy);
+ };
+
+ /** @param {Traversal} traversal */
+ TraversalStrategies.prototype.applyStrategies = function (traversal) {
+ this.strategies.forEach(function eachStrategy(s) {
+ s.apply(traversal);
+ });
+ };
+
+ /**
+ * @abstract
+ * @constructor
+ */
+ function TraversalStrategy() {
+
+ }
+
+ /**
+ * @abstract
+ * @param {Traversal} traversal
+ */
+ TraversalStrategy.prototype.apply = function (traversal) {
+
+ };
+
+ /**
+ * Creates a new instance of Bytecode
+ * @param {Bytecode} [toClone]
+ * @constructor
+ */
+ function Bytecode(toClone) {
+ this._bindings = {};
+ if (!toClone) {
+ this.sourceInstructions = [];
+ this.stepInstructions = [];
+ }
+ else {
+ this.sourceInstructions = toClone.sourceInstructions.slice(0);
+ this.stepInstructions = toClone.sourceInstructions.slice(0);
+ }
+ }
+
+ /**
+ * Adds a new source instructions
+ * @param {String} name
+ * @param {Array} values
+ * @returns {Bytecode}
+ */
+ Bytecode.prototype.addSource = function (name, values) {
+ if (name === undefined) {
+ throw new Error('Name is not defined');
+ }
+ var instruction = new Array(values.length + 1);
+ instruction[0] = name;
+ for (var i = 0; i < values.length; ++i) {
+ instruction[i + 1] = this._convertToArgument(values[i]);
+ }
+ this.sourceInstructions.push(this._generateInstruction(name, values));
+ return this;
+ };
+
+ /**
+ * Adds a new step instructions
+ * @param {String} name
+ * @param {Array} values
+ * @returns {Bytecode}
+ */
+ Bytecode.prototype.addStep = function (name, values) {
+ if (name === undefined) {
+ throw new Error('Name is not defined');
+ }
+ this.stepInstructions.push(this._generateInstruction(name, values));
+ return this;
+ };
+
+ Bytecode.prototype._generateInstruction = function (name, values) {
+ var instruction = new Array(values.length + 1);
+ instruction[0] = name;
+ for (var i = 0; i < values.length; ++i) {
+ instruction[i + 1] = this._convertToArgument(values[i]);
+ }
+ return instruction;
+ };
+
+ /**
+ * Returns the JSON representation of the source and step instructions
+ * @returns {String}
+ */
+ Bytecode.prototype.toString = function () {
+ return (
+ (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
+ (this.stepInstructions.length > 0 ? JSON.stringify(this.stepInstructions) : '')
+ );
+ };
+
+ Bytecode.prototype._convertToArgument = function (value) {
+ return value;
+ };
+
+ function toEnum(typeName, keys) {
+ var result = {};
+ keys.split(' ').forEach(function (k) {
+ if (k === k.toUpperCase()) {
+ k = k.toLowerCase();
+ }
+ result[k] = new EnumValue(typeName, k);
+ });
+ return result;
+ }
+
+ function EnumValue(typeName, elementName) {
+ this.typeName = typeName;
+ this.elementName = elementName;
+ }
+
+ /**
+ * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
+ */
+ var enums = {};
+ enums.barrier = toEnum('Barrier', 'normSack');
+ enums.cardinality = toEnum('Cardinality', 'list set single');
+ enums.column = toEnum('Column', 'keys values');
+ enums.direction = toEnum('Direction', 'BOTH IN OUT');
+ enums.operator = toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong');
+ enums.order = toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr');
+ enums.pop = toEnum('Pop', 'all first last');
+ enums.scope = toEnum('Scope', 'global local');
+ enums.t = toEnum('T', 'id key label value');
+
+ // Utility functions
+ /** @returns {Array} */
+ function parseArgs() {
+ return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
+ }
+
+ /**
+ * @param {Array} arr
+ * @param {Function} fn
+ * @param {Function} [callback]
+ */
+ function eachSeries(arr, fn, callback) {
+ if (!Array.isArray(arr)) {
+ throw new TypeError('First parameter is not an Array');
+ }
+ callback = callback || noop;
+ var length = arr.length;
+ if (length === 0) {
+ return callback();
+ }
+ var sync;
+ var index = 1;
+ fn(arr[0], next);
+ if (sync === undefined) {
+ sync = false;
+ }
+
+ function next(err) {
+ if (err) {
+ return callback(err);
+ }
+ if (index >= length) {
+ return callback();
+ }
+ if (sync === undefined) {
+ sync = true;
+ }
+ if (sync) {
+ return process.nextTick(function () {
+ fn(arr[index++], next);
+ });
+ }
+ fn(arr[index++], next);
+ }
+ }
+
+ function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ }
+
+ var toExport = {
+ Bytecode: Bytecode,
+ EnumValue: EnumValue,
+ inherits: inherits,
+ P: P,
+ parseArgs: parseArgs,
+ Traversal: Traversal,
+ TraversalSideEffects: TraversalSideEffects,
+ TraversalStrategies: TraversalStrategies,
+ TraversalStrategy: TraversalStrategy,
+ Traverser: Traverser
+ };
+ Object.keys(enums).forEach(function (k) {
+ toExport[k] = enums[k];
+ });
+ if (typeof module !== 'undefined') {
+ // CommonJS
+ module.exports = toExport;
+ return;
+ }
+ // Nashorn and rest
+ return toExport;
+}).call(this);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
new file mode 100644
index 0000000..7c48819
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineGraphModule() {
+ "use strict";
+
+ var gt = loadModule.call(this, '../process/graph-traversal.js');
+ var t = loadModule.call(this, '../process/traversal.js');
+ var inherits = t.inherits;
+
+ function Graph() {
+
+ }
+
+ /**
+ * Returns the graph traversal source.
+ * @returns {GraphTraversalSource}
+ */
+ Graph.prototype.traversal = function () {
+ return new gt.GraphTraversalSource(this, new t.TraversalStrategies());
+ };
+
+ Graph.prototype.toString = function () {
+ return 'graph[empty]';
+ };
+
+ function Element(id, label) {
+ this.id = id;
+ this.label = label;
+ }
+
+ /**
+ * Compares this instance to another and determines if they can be considered as equal.
+ * @param {Element} other
+ * @returns {boolean}
+ */
+ Element.prototype.equals = function (other) {
+ return (other instanceof Element) && this.id === other.id;
+ };
+
+ function Vertex(id, label, properties) {
+ Element.call(this, id, label);
+ this.properties = properties;
+ }
+
+ Vertex.prototype.toString = function () {
+ return 'v[' + this.id + ']';
+ };
+
+ inherits(Vertex, Element);
+
+ function Edge(id, outV, label, inV) {
+ Element.call(this, id, label);
+ this.outV = outV;
+ this.inV = inV;
+ }
+
+ inherits(Edge, Element);
+
+ Edge.prototype.toString = function () {
+ return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
+ };
+
+ function VertexProperty(id, label, value) {
+ Element.call(this, id, label);
+ this.value = value;
+ this.key = this.label;
+ }
+
+ inherits(VertexProperty, Element);
+
+ VertexProperty.prototype.toString = function () {
+ return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']';
+ };
+
+ function Property(key, value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ Property.prototype.toString = function () {
+ return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']';
+ };
+
+ Property.prototype.equals = function (other) {
+ return (other instanceof Property) && this.key === other.key && this.value === other.value;
+ };
+
+ /**
+ * Represents a walk through a graph as defined by a traversal.
+ * @param {Array} labels
+ * @param {Array} objects
+ * @constructor
+ */
+ function Path(labels, objects) {
+ this.labels = labels;
+ this.objects = objects;
+ }
+
+ function loadModule(moduleName) {
+ if (typeof require !== 'undefined') {
+ return require(moduleName);
+ }
+ if (typeof load !== 'undefined') {
+ var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+ this.__dependencies = this.__dependencies || {};
+ return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+ }
+ throw new Error('No module loader was found');
+ }
+
+ var toExport = {
+ Edge: Edge,
+ Graph: Graph,
+ Path: Path,
+ Property: Property,
+ Vertex: Vertex,
+ VertexProperty: VertexProperty
+ };
+ if (typeof module !== 'undefined') {
+ // CommonJS
+ module.exports = toExport;
+ return;
+ }
+ // Nashorn and rest
+ return toExport;
+}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
new file mode 100644
index 0000000..2dde340
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
@@ -0,0 +1,406 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function graphSerializerModule() {
+ "use strict";
+
+ var t = loadModule.call(this, '../../process/traversal.js');
+ var g = loadModule.call(this, '../graph.js');
+
+ /**
+ * A type serializer
+ * @typedef {Object} Serializer
+ * @property {Function} serialize
+ * @property {Function} deserialize
+ * @property {Function} [canBeUsedFor]
+ */
+
+ /**
+ * @const
+ * @private
+ */
+ var valueKey = '@value';
+
+ /**
+ * @const
+ * @private
+ */
+ var typeKey = '@type';
+
+ var deserializers = {
+ 'g:Traverser': TraverserSerializer,
+ 'g:Int32': NumberSerializer,
+ 'g:Int64': NumberSerializer,
+ 'g:Float': NumberSerializer,
+ 'g:Double': NumberSerializer,
+ 'g:Vertex': VertexSerializer,
+ 'g:Edge': EdgeSerializer,
+ 'g:VertexProperty': VertexPropertySerializer,
+ 'g:Property': PropertySerializer,
+ 'g:Path': PathSerializer
+ };
+
+ var serializers = [
+ NumberSerializer,
+ BytecodeSerializer,
+ TraverserSerializer,
+ PSerializer,
+ LambdaSerializer,
+ EnumSerializer
+ ];
+
+ /**
+ * GraphSON Writer
+ * @param {Object} [options]
+ * @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and
+ * serializer instances as values, ie: { 'g:Int64': longSerializer }.
+ * @constructor
+ */
+ function GraphSONWriter(options) {
+ this._options = options || {};
+ // Create instance of the default serializers
+ this._serializers = serializers.map(function (serializerConstructor) {
+ var s = new serializerConstructor();
+ s.writer = this;
+ return s;
+ }, this);
+ var customSerializers = this._options.serializers || {};
+ Object.keys(customSerializers).forEach(function (key) {
+ var s = customSerializers[key];
+ if (!s.serialize) {
+ return;
+ }
+ s.writer = this;
+ // Insert custom serializers first
+ this._serializers.unshift(s);
+ }, this);
+ }
+
+ GraphSONWriter.prototype.adaptObject = function (value) {
+ var s;
+ if (Array.isArray(value)) {
+ return value.map(function (item) {
+ return this.adaptObject(item);
+ }, this);
+ }
+ for (var i = 0; i < this._serializers.length; i++) {
+ var currentSerializer = this._serializers[i];
+ if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) {
+ s = currentSerializer;
+ break;
+ }
+ }
+ if (s) {
+ return s.serialize(value);
+ }
+ // Default (strings / objects / ...)
+ return value;
+ };
+
+ /**
+ * Returns the GraphSON representation of the provided object instance.
+ * @param {Object} obj
+ * @returns {String}
+ */
+ GraphSONWriter.prototype.write = function (obj) {
+ return JSON.stringify(this.adaptObject(obj));
+ };
+
+ /**
+ * GraphSON Reader
+ * @param {Object} [options]
+ * @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and
+ * deserializer instances as values, ie: { 'g:Int64': longSerializer }.
+ * @constructor
+ */
+ function GraphSONReader(options) {
+ this._options = options || {};
+ this._deserializers = {};
+ Object.keys(deserializers).forEach(function (typeName) {
+ var serializerConstructor = deserializers[typeName];
+ var s = new serializerConstructor();
+ s.reader = this;
+ this._deserializers[typeName] = s;
+ }, this);
+ if (this._options.serializers) {
+ var customSerializers = this._options.serializers || {};
+ Object.keys(customSerializers).forEach(function (key) {
+ var s = customSerializers[key];
+ if (!s.deserialize) {
+ return;
+ }
+ s.reader = this;
+ this._deserializers[key] = s;
+ }, this);
+ }
+ }
+
+ GraphSONReader.prototype.read = function (obj) {
+ if (Array.isArray(obj)) {
+ return obj.map(function mapEach(item) {
+ return this.read(item);
+ }, this);
+ }
+ var type = obj[typeKey];
+ if (type) {
+ var d = this._deserializers[type];
+ if (d) {
+ // Use type serializer
+ return d.deserialize(obj);
+ }
+ return obj[valueKey];
+ }
+ if (obj && typeof obj === 'object' && obj.constructor === Object) {
+ return this._deserializeObject(obj);
+ }
+ // Default (for boolean, number and other scalars)
+ return obj;
+ };
+
+ GraphSONReader.prototype._deserializeObject = function (obj) {
+ var keys = Object.keys(obj);
+ var result = {};
+ for (var i = 0; i < keys.length; i++) {
+ result[keys[i]] = this.read(obj[keys[i]]);
+ }
+ return result;
+ };
+
+ function NumberSerializer() {
+
+ }
+
+ NumberSerializer.prototype.serialize = function (item) {
+ return item;
+ };
+
+ NumberSerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return parseFloat(value);
+ };
+
+ NumberSerializer.prototype.canBeUsedFor = function (value) {
+ return (typeof value === 'number');
+ };
+
+ function BytecodeSerializer() {
+
+ }
+
+ BytecodeSerializer.prototype.serialize = function (item) {
+ var bytecode = item;
+ if (item instanceof t.Traversal) {
+ bytecode = item.getBytecode();
+ }
+ var result = {};
+ result[typeKey] = 'g:Bytecode';
+ var resultValue = result[valueKey] = {};
+ var sources = this._serializeInstructions(bytecode.sourceInstructions);
+ if (sources) {
+ resultValue['source'] = sources;
+ }
+ var steps = this._serializeInstructions(bytecode.stepInstructions);
+ if (steps) {
+ resultValue['step'] = steps;
+ }
+ return result;
+ };
+
+ BytecodeSerializer.prototype._serializeInstructions = function (instructions) {
+ if (instructions.length === 0) {
+ return null;
+ }
+ var result = new Array(instructions.length);
+ result[0] = instructions[0];
+ for (var i = 1; i < instructions.length; i++) {
+ result[i] = this.writer.adaptObject(instructions[i]);
+ }
+ return result;
+ };
+
+ BytecodeSerializer.prototype.canBeUsedFor = function (value) {
+ return (value instanceof t.Bytecode) || (value instanceof t.Traversal);
+ };
+
+ function PSerializer() {
+
+ }
+
+ /** @param {P} item */
+ PSerializer.prototype.serialize = function (item) {
+ var result = {};
+ result[typeKey] = 'g:P';
+ var resultValue = result[valueKey] = {
+ 'predicate': item.operator
+ };
+ if (item.other == undefined) {
+ resultValue['value'] = this.writer.adaptObject(item.value);
+ }
+ else {
+ resultValue['value'] = [ this.writer.adaptObject(item.value), this.writer.adaptObject(item.other) ];
+ }
+ return result;
+ };
+
+ PSerializer.prototype.canBeUsedFor = function (value) {
+ return (value instanceof t.P);
+ };
+
+ function LambdaSerializer() {
+
+ }
+
+ /** @param {Function} item */
+ LambdaSerializer.prototype.serialize = function (item) {
+ var result = {};
+ result[typeKey] = 'g:Lambda';
+ result[valueKey] = {
+ 'arguments': item.length,
+ 'language': 'gremlin-javascript',
+ 'script': item.toString()
+ };
+ return result;
+ };
+
+ LambdaSerializer.prototype.canBeUsedFor = function (value) {
+ return (typeof value === 'function');
+ };
+
+ function EnumSerializer() {
+
+ }
+
+ /** @param {EnumValue} item */
+ EnumSerializer.prototype.serialize = function (item) {
+ var result = {};
+ result[typeKey] = 'g:' + item.typeName;
+ result[valueKey] = item.elementName;
+ return result;
+ };
+
+ EnumSerializer.prototype.canBeUsedFor = function (value) {
+ return value && value.typeName && value instanceof t.EnumValue;
+ };
+
+ function TraverserSerializer() {
+
+ }
+
+ /** @param {Traverser} item */
+ TraverserSerializer.prototype.serialize = function (item) {
+ var result = {};
+ result[typeKey] = 'g:Traverser';
+ result[valueKey] = {
+ 'value': this.writer.adaptObject(item.object),
+ 'bulk': this.writer.adaptObject(item.bulk)
+ };
+ return result;
+ };
+
+ TraverserSerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return new t.Traverser(this.reader.read(value['value']), this.reader.read(value['bulk']));
+ };
+
+ TraverserSerializer.prototype.canBeUsedFor = function (value) {
+ return (value instanceof t.Traverser);
+ };
+
+ function VertexSerializer() {
+
+ }
+
+ VertexSerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
+ };
+
+ function VertexPropertySerializer() {
+
+ }
+
+ VertexPropertySerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return new g.VertexProperty(this.reader.read(value['id']), value['label'], this.reader.read(value['value']));
+ };
+
+ function PropertySerializer() {
+
+ }
+
+ PropertySerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return new g.Property(
+ value['key'],
+ this.reader.read(value['value']));
+ };
+
+ function EdgeSerializer() {
+
+ }
+
+ EdgeSerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return new g.Edge(
+ this.reader.read(value['id']),
+ this.reader.read(value['outV']),
+ value['label'],
+ this.reader.read(value['inV'])
+ );
+ };
+
+ function PathSerializer() {
+
+ }
+
+ PathSerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ var objects = value['objects'].map(function objectMapItem(o) {
+ return this.reader.read(o);
+ }, this);
+ return new g.Path(this.reader.read(value['labels']), objects);
+ };
+
+ function loadModule(moduleName) {
+ if (typeof require !== 'undefined') {
+ return require(moduleName);
+ }
+ if (typeof load !== 'undefined') {
+ var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+ this.__dependencies = this.__dependencies || {};
+ return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+ }
+ throw new Error('No module loader was found');
+ }
+
+ var toExport = {
+ GraphSONWriter: GraphSONWriter,
+ GraphSONReader: GraphSONReader
+ };
+ if (typeof module !== 'undefined') {
+ // CommonJS
+ module.exports = toExport;
+ return;
+ }
+ // Nashorn and rest
+ return toExport;
+}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
new file mode 100644
index 0000000..858ed06
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineHelperModule() {
+ "use strict";
+
+ var assert = {
+ ok: function (condition, message) {
+ if (!condition) {
+ throw new AssertError(message || (condition + ' == true'));
+ }
+ },
+ strictEqual: function (val1, val2, message) {
+ if (val1 !== val2) {
+ throw new AssertError(message || (val1 + ' === ' + val2));
+ }
+ }
+ };
+
+ function loadLibModule(moduleName) {
+ if (typeof require !== 'undefined') {
+ moduleName = '../lib/' + moduleName;
+ return require(moduleName);
+ }
+ if (typeof load !== 'undefined' && typeof java !== 'undefined') {
+ moduleName = __DIR__ + '../../../main/javascript/gremlin-javascript/' + moduleName;
+ var path = new java.io.File(moduleName).getCanonicalPath();
+ this.__dependencies = this.__dependencies || {};
+ return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+ }
+ throw new Error('No module loader was found');
+ }
+
+ function AssertError(message) {
+ Error.call(this, message);
+ this.stack = (new Error(message)).stack;
+ if (typeof print !== 'undefined') {
+ print(this.stack);
+ }
+ }
+
+ inherits(AssertError, Error);
+
+ function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ }
+ var toExport = {
+ assert: assert,
+ loadLibModule: loadLibModule
+ };
+ if (typeof module !== 'undefined') {
+ // CommonJS
+ module.exports = toExport;
+ return;
+ }
+ return toExport;
+}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
new file mode 100644
index 0000000..6edb323
--- /dev/null
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTestCases() {
+ "use strict";
+
+ var helper = loadModule.call(this, './helper.js');
+ var assert = helper.assert;
+ var glvModule = helper.loadLibModule.call(this, './index.js');
+
+ [
+ function testExports() {
+ assert.ok(glvModule);
+
+ assert.ok(glvModule.process);
+ assert.strictEqual(typeof glvModule.process.Bytecode, 'function');
+ assert.strictEqual(typeof glvModule.process.EnumValue, 'function');
+ assert.strictEqual(typeof glvModule.process.inherits, 'function');
+ assert.strictEqual(typeof glvModule.process.P, 'function');
+ assert.strictEqual(typeof glvModule.process.parseArgs, 'function');
+ assert.strictEqual(typeof glvModule.process.Traversal, 'function');
+ assert.strictEqual(typeof glvModule.process.TraversalSideEffects, 'function');
+ assert.strictEqual(typeof glvModule.process.TraversalStrategies, 'function');
+ assert.strictEqual(typeof glvModule.process.TraversalStrategy, 'function');
+ assert.strictEqual(typeof glvModule.process.Traverser, 'function');
+ assert.strictEqual(typeof glvModule.process.GraphTraversal, 'function');
+ assert.strictEqual(typeof glvModule.process.GraphTraversalSource, 'function');
+ assert.ok(glvModule.process.statics);
+
+ assert.ok(glvModule.structure);
+ assert.ok(glvModule.structure.io);
+ assert.strictEqual(typeof glvModule.structure.io.GraphSONReader, 'function');
+ assert.strictEqual(typeof glvModule.structure.io.GraphSONWriter, 'function');
+ assert.strictEqual(typeof glvModule.structure.Edge, 'function');
+ assert.strictEqual(typeof glvModule.structure.Graph, 'function');
+ assert.strictEqual(typeof glvModule.structure.Path, 'function');
+ assert.strictEqual(typeof glvModule.structure.Property, 'function');
+ assert.strictEqual(typeof glvModule.structure.Vertex, 'function');
+ assert.strictEqual(typeof glvModule.structure.VertexProperty, 'function');
+
+ assert.ok(glvModule.driver);
+ assert.strictEqual(typeof glvModule.driver.RemoteConnection, 'function');
+ assert.strictEqual(typeof glvModule.driver.RemoteStrategy, 'function');
+ assert.strictEqual(typeof glvModule.driver.RemoteTraversal, 'function');
+ }
+ ].forEach(function (testCase) {
+ testCase.call(null);
+ });
+
+ function loadModule(moduleName) {
+ if (typeof require !== 'undefined') {
+ return require(moduleName);
+ }
+ if (typeof load !== 'undefined') {
+ return load(__DIR__ + moduleName);
+ }
+ throw new Error('No module loader was found');
+ }
+}).call(this)
\ No newline at end of file
[03/47] tinkerpop git commit: Javascript GLV
Posted by jo...@apache.org.
Javascript GLV
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2d850565
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2d850565
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2d850565
Branch: refs/heads/master
Commit: 2d8505656d69a2ba542f543234e56d3320984ade
Parents: 231bbb6
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Oct 5 16:14:46 2016 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:13 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/pom.xml | 132 ++
.../GraphTraversalSourceGenerator.groovy | 247 +++
.../javascript/TraversalSourceGenerator.groovy | 398 ++++
.../javascript/GenerateGremlinJavascript.java | 32 +
.../gremlin/javascript/jsr223/SymbolHelper.java | 59 +
.../driver/remote-connection.js | 107 +
.../main/javascript/gremlin-javascript/index.js | 85 +
.../process/graph-traversal.js | 2025 ++++++++++++++++++
.../gremlin-javascript/process/traversal.js | 395 ++++
.../gremlin-javascript/structure/graph.js | 146 ++
.../structure/io/graph-serializer.js | 406 ++++
.../javascript/gremlin-javascript/helper.js | 84 +
.../gremlin-javascript/test-exports.js | 78 +
.../gremlin-javascript/test-graphson.js | 108 +
.../gremlin-javascript/test-traversal.js | 54 +
pom.xml | 1 +
16 files changed, 4357 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
new file mode 100644
index 0000000..387e628
--- /dev/null
+++ b/gremlin-javascript/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>tinkerpop</artifactId>
+ <version>3.2.3-SNAPSHOT</version>
+ </parent>
+ <artifactId>gremlin-javascript</artifactId>
+ <name>Apache TinkerPop :: Gremlin Javascript</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy</artifactId>
+ <version>${groovy.version}</version>
+ <classifier>indy</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>tinkergraph-gremlin</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-test</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-server</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <properties>
+ <!-- provides a way to convert maven.test.skip value to skipTests for use in skipping python tests -->
+ <maven.test.skip>false</maven.test.skip>
+ <skipTests>${maven.test.skip}</skipTests>
+ <gremlin.server.dir>${project.parent.basedir}/gremlin-server</gremlin.server.dir>
+ </properties>
+ <build>
+ <directory>${basedir}/target</directory>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <executions>
+ <execution>
+ <id>generate-javascript</id>
+ <phase>generate-test-resources</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>org.apache.tinkerpop.gremlin.javascript.GenerateGremlinJavascript</mainClass>
+ <arguments>
+ <argument>${basedir}/src/main/javascript/gremlin-javascript/process/traversal.js</argument>
+ <argument>${basedir}/src/main/javascript/gremlin-javascript/process/graph-traversal.js</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>js-tests</id>
+ <phase>test</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>jjs</executable>
+ <arguments>
+ <argument>${basedir}/src/test/javascript/gremlin-javascript/test-exports.js</argument>
+ <argument>${basedir}/src/test/javascript/gremlin-javascript/test-graphson.js</argument>
+ <argument>${basedir}/src/test/javascript/gremlin-javascript/test-traversal.js</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.gmavenplus</groupId>
+ <artifactId>gmavenplus-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
new file mode 100644
index 0000000..81c38dc
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -0,0 +1,247 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript
+
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
+import org.apache.tinkerpop.gremlin.javascript.jsr223.SymbolHelper
+
+import java.lang.reflect.Modifier
+
+/**
+ * @author Jorge Bay Gondra
+ */
+class GraphTraversalSourceGenerator {
+
+ public static void create(final String graphTraversalSourceFile) {
+
+ final StringBuilder moduleOutput = new StringBuilder()
+
+ moduleOutput.append("""/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ """)
+
+//////////////////////////
+// GraphTraversalSource //
+//////////////////////////
+ moduleOutput.append("""
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineGraphTraversalModule() {
+ "use strict";
+
+ var t = loadModule.call(this, './traversal.js');
+ var remote = loadModule.call(this, '../driver/remote-connection.js');
+ var Bytecode = t.Bytecode;
+ var inherits = t.inherits;
+ var parseArgs = t.parseArgs;
+
+ /**
+ *
+ * @param {Graph} graph
+ * @param {TraversalStrategies} traversalStrategies
+ * @param {Bytecode} [bytecode]
+ * @constructor
+ */
+ function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+ this._graph = graph;
+ this._traversalStrategies = traversalStrategies;
+ this._bytecode = bytecode || new Bytecode();
+ }
+
+ /**
+ * @param remoteConnection
+ * @returns {GraphTraversal}
+ */
+ GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+ var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+ traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+ return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+ };
+
+ /**
+ * Returns the string representation of the GraphTraversalSource.
+ * @returns {string}
+ */
+ GraphTraversalSource.prototype.toString = function () {
+ return 'graphtraversalsource[' + this._graph.toString() + ']';
+ };
+""")
+ GraphTraversalSource.getMethods(). // SOURCE STEPS
+ findAll { GraphTraversalSource.class.equals(it.returnType) }.
+ findAll {
+ !it.name.equals("clone") &&
+ !it.name.equals(TraversalSource.Symbols.withBindings) &&
+ !it.name.equals(TraversalSource.Symbols.withRemote)
+ }.
+ collect { SymbolHelper.toJs(it.name) }.
+ unique().
+ sort { a, b -> a <=> b }.
+ forEach { method ->
+ moduleOutput.append(
+ """
+ /**
+ * ${method} GraphTraversalSource method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ GraphTraversalSource.prototype.${method} = function (args) {
+ var b = new Bytecode(this._bytecode).addSource('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+""")
+ }
+ GraphTraversalSource.getMethods(). // SPAWN STEPS
+ findAll { GraphTraversal.class.equals(it.returnType) }.
+ collect { SymbolHelper.toJs(it.name) }.
+ unique().
+ sort { a, b -> a <=> b }.
+ forEach { method ->
+ moduleOutput.append(
+ """
+ /**
+ * ${method} GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversalSource.prototype.${method} = function (args) {
+ var b = new Bytecode(this._bytecode).addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ };
+""")
+ }
+////////////////////
+// GraphTraversal //
+////////////////////
+ moduleOutput.append(
+ """
+ /**
+ * Represents a graph traversal.
+ * @constructor
+ */
+ function GraphTraversal(graph, traversalStrategies, bytecode) {
+ t.Traversal.call(this, graph, traversalStrategies, bytecode);
+ }
+
+ inherits(GraphTraversal, t.Traversal);
+""")
+ GraphTraversal.getMethods().
+ findAll { GraphTraversal.class.equals(it.returnType) }.
+ findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
+ collect { SymbolHelper.toJs(it.name) }.
+ unique().
+ sort { a, b -> a <=> b }.
+ forEach { method ->
+ moduleOutput.append(
+ """
+ /**
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ GraphTraversal.prototype.${method} = function (args) {
+ this._bytecode.addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+ return this;
+ };
+""")
+ };
+
+////////////////////////
+// AnonymousTraversal //
+////////////////////////
+ moduleOutput.append("""
+ /**
+ * Contains the static method definitions
+ * @type {Object}
+ */
+ var statics = {};
+""");
+ __.class.getMethods().
+ findAll { GraphTraversal.class.equals(it.returnType) }.
+ findAll { Modifier.isStatic(it.getModifiers()) }.
+ collect { SymbolHelper.toJs(it.name) }.
+ unique().
+ sort { a, b -> a <=> b }.
+ forEach { method ->
+ moduleOutput.append(
+ """
+ /**
+ * ${method}() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ statics.${method} = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.${method}.apply(g, arguments);
+ };
+""")
+ };
+
+ moduleOutput.append("""
+ function loadModule(moduleName) {
+ if (typeof require !== 'undefined') {
+ return require(moduleName);
+ }
+ if (typeof load !== 'undefined') {
+ var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+ this.__dependencies = this.__dependencies || {};
+ return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+ }
+ throw new Error('No module loader was found');
+ }
+
+ var toExport = {
+ GraphTraversal: GraphTraversal,
+ GraphTraversalSource: GraphTraversalSource,
+ statics: statics
+ };
+ if (typeof module !== 'undefined') {
+ // CommonJS
+ module.exports = toExport;
+ return;
+ }
+ // Nashorn and rest
+ return toExport;
+}).call(this);""")
+
+ // save to file
+ final File file = new File(graphTraversalSourceFile);
+ file.delete()
+ moduleOutput.eachLine { file.append(it + "\n") }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
new file mode 100644
index 0000000..efcb826
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -0,0 +1,398 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript
+
+import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.util.CoreImports
+import org.apache.tinkerpop.gremlin.javascript.jsr223.SymbolHelper
+
+import java.lang.reflect.Modifier
+
+/**
+ * @author Jorge Bay Gondra
+ */
+class TraversalSourceGenerator {
+
+ public static void create(final String traversalSourceFile) {
+
+ final StringBuilder moduleOutput = new StringBuilder()
+
+ moduleOutput.append("""/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+""")
+ moduleOutput.append("""
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineTraversalModule() {
+ "use strict";
+
+ function Traversal(graph, traversalStrategies, bytecode) {
+ this._graph = graph;
+ this._traversalStrategies = traversalStrategies;
+ this._bytecode = bytecode;
+ this.traversers = null;
+ this.sideEffects = null;
+ }
+
+ /** @returns {Bytecode} */
+ Traversal.prototype.getBytecode = function () {
+ return this._bytecode;
+ };
+
+ /** @param {Function} callback */
+ Traversal.prototype.list = function (callback) {
+ var self = this;
+ this._traversalStrategies.applyStrategies(this, function (err) {
+ if (err) {
+ return callback(err);
+ }
+ callback(err, self.traversers);
+ });
+ };
+
+ /** @param {Function} callback */
+ Traversal.prototype.one = function (callback) {
+ this.list(function (err, result) {
+ callback(err, result ? result[0] : null);
+ });
+ };
+
+ /**
+ * Returns the Bytecode JSON representation of the traversal
+ * @returns {String}
+ */
+ Traversal.prototype.toString = function () {
+ return this._bytecode.toString();
+ };
+ """);
+
+ moduleOutput.append("""
+ /**
+ * Represents an operation.
+ * @constructor
+ */
+ function P(operator, value, other) {
+ this.operator = operator;
+ this.value = value;
+ this.other = other;
+ }
+
+ /**
+ * Returns the string representation of the instance.
+ * @returns {string}
+ */
+ P.prototype.toString = function () {
+ if (this.other === undefined) {
+ return this.operator + '(' + this.value + ')';
+ }
+ return this.operator + '(' + this.value + ', ' + this.other + ')';
+ };
+
+ function createP(operator, args) {
+ args.unshift(null, operator);
+ return new (Function.prototype.bind.apply(P, args));
+ }
+""")
+ P.class.getMethods().
+ findAll { Modifier.isStatic(it.getModifiers()) }.
+ findAll { P.class.isAssignableFrom(it.returnType) }.
+ collect { SymbolHelper.toJs(it.name) }.
+ unique().
+ sort { a, b -> a <=> b }.
+ each { method ->
+ moduleOutput.append(
+ """
+ /** @param {...Object} args */
+ P.${method} = function (args) {
+ return createP('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+ };
+""")
+ };
+ moduleOutput.append("""
+ P.prototype.and = function (arg) {
+ return new P('and', this, arg);
+ };
+
+ P.prototype.or = function (arg) {
+ return new P('or', this, arg);
+ };
+""")
+
+ moduleOutput.append("""
+ function Traverser(object, bulk) {
+ this.object = object;
+ this.bulk = bulk == undefined ? 1 : bulk;
+ }
+
+ function TraversalSideEffects() {
+
+ }
+
+ /**
+ * Creates a new instance of TraversalStrategies.
+ * @param {TraversalStrategies} [traversalStrategies]
+ * @constructor
+ */
+ function TraversalStrategies(traversalStrategies) {
+ /** @type {Array<TraversalStrategy>} */
+ this.strategies = traversalStrategies ? traversalStrategies.strategies : [];
+ }
+
+ /** @param {TraversalStrategy} strategy */
+ TraversalStrategies.prototype.addStrategy = function (strategy) {
+ this.strategies.push(strategy);
+ };
+
+ /** @param {Traversal} traversal */
+ TraversalStrategies.prototype.applyStrategies = function (traversal) {
+ this.strategies.forEach(function eachStrategy(s) {
+ s.apply(traversal);
+ });
+ };
+
+ /**
+ * @abstract
+ * @constructor
+ */
+ function TraversalStrategy() {
+
+ }
+
+ /**
+ * @abstract
+ * @param {Traversal} traversal
+ */
+ TraversalStrategy.prototype.apply = function (traversal) {
+
+ };
+
+ /**
+ * Creates a new instance of Bytecode
+ * @param {Bytecode} [toClone]
+ * @constructor
+ */
+ function Bytecode(toClone) {
+ this._bindings = {};
+ if (!toClone) {
+ this.sourceInstructions = [];
+ this.stepInstructions = [];
+ }
+ else {
+ this.sourceInstructions = toClone.sourceInstructions.slice(0);
+ this.stepInstructions = toClone.sourceInstructions.slice(0);
+ }
+ }
+
+ /**
+ * Adds a new source instructions
+ * @param {String} name
+ * @param {Array} values
+ * @returns {Bytecode}
+ */
+ Bytecode.prototype.addSource = function (name, values) {
+ if (name === undefined) {
+ throw new Error('Name is not defined');
+ }
+ var instruction = new Array(values.length + 1);
+ instruction[0] = name;
+ for (var i = 0; i < values.length; ++i) {
+ instruction[i + 1] = this._convertToArgument(values[i]);
+ }
+ this.sourceInstructions.push(this._generateInstruction(name, values));
+ return this;
+ };
+
+ /**
+ * Adds a new step instructions
+ * @param {String} name
+ * @param {Array} values
+ * @returns {Bytecode}
+ */
+ Bytecode.prototype.addStep = function (name, values) {
+ if (name === undefined) {
+ throw new Error('Name is not defined');
+ }
+ this.stepInstructions.push(this._generateInstruction(name, values));
+ return this;
+ };
+
+ Bytecode.prototype._generateInstruction = function (name, values) {
+ var instruction = new Array(values.length + 1);
+ instruction[0] = name;
+ for (var i = 0; i < values.length; ++i) {
+ instruction[i + 1] = this._convertToArgument(values[i]);
+ }
+ return instruction;
+ };
+
+ /**
+ * Returns the JSON representation of the source and step instructions
+ * @returns {String}
+ */
+ Bytecode.prototype.toString = function () {
+ return (
+ (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
+ (this.stepInstructions.length > 0 ? JSON.stringify(this.stepInstructions) : '')
+ );
+ };
+
+ Bytecode.prototype._convertToArgument = function (value) {
+ return value;
+ };
+
+ function toEnum(typeName, keys) {
+ var result = {};
+ keys.split(' ').forEach(function (k) {
+ if (k === k.toUpperCase()) {
+ k = k.toLowerCase();
+ }
+ result[k] = new EnumValue(typeName, k);
+ });
+ return result;
+ }
+
+ function EnumValue(typeName, elementName) {
+ this.typeName = typeName;
+ this.elementName = elementName;
+ }
+
+ /**
+ * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
+ */
+ var enums = {};\n""")
+
+ for (final Class<? extends Enum> enumClass : CoreImports.getClassImports()
+ .findAll { Enum.class.isAssignableFrom(it) }
+ .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }
+ .collect()) {
+ moduleOutput.append(" enums.${SymbolHelper.decapitalize(enumClass.getSimpleName())} = " +
+ "toEnum('${SymbolHelper.toJs(enumClass.getSimpleName())}', '");
+ enumClass.getEnumConstants()
+ .sort { a, b -> a.name() <=> b.name() }
+ .each { value -> moduleOutput.append("${SymbolHelper.toJs(value.name())} "); }
+ moduleOutput.deleteCharAt(moduleOutput.length() - 1).append("');\n")
+ }
+
+ moduleOutput.append("""
+ // Utility functions
+ /** @returns {Array} */
+ function parseArgs() {
+ return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
+ }
+
+ /**
+ * @param {Array} arr
+ * @param {Function} fn
+ * @param {Function} [callback]
+ */
+ function eachSeries(arr, fn, callback) {
+ if (!Array.isArray(arr)) {
+ throw new TypeError('First parameter is not an Array');
+ }
+ callback = callback || noop;
+ var length = arr.length;
+ if (length === 0) {
+ return callback();
+ }
+ var sync;
+ var index = 1;
+ fn(arr[0], next);
+ if (sync === undefined) {
+ sync = false;
+ }
+
+ function next(err) {
+ if (err) {
+ return callback(err);
+ }
+ if (index >= length) {
+ return callback();
+ }
+ if (sync === undefined) {
+ sync = true;
+ }
+ if (sync) {
+ return process.nextTick(function () {
+ fn(arr[index++], next);
+ });
+ }
+ fn(arr[index++], next);
+ }
+ }
+
+ function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ }
+
+ var toExport = {
+ Bytecode: Bytecode,
+ EnumValue: EnumValue,
+ inherits: inherits,
+ P: P,
+ parseArgs: parseArgs,
+ Traversal: Traversal,
+ TraversalSideEffects: TraversalSideEffects,
+ TraversalStrategies: TraversalStrategies,
+ TraversalStrategy: TraversalStrategy,
+ Traverser: Traverser
+ };
+ Object.keys(enums).forEach(function (k) {
+ toExport[k] = enums[k];
+ });
+ if (typeof module !== 'undefined') {
+ // CommonJS
+ module.exports = toExport;
+ return;
+ }
+ // Nashorn and rest
+ return toExport;
+}).call(this);""")
+
+ // save to a file
+ final File file = new File(traversalSourceFile);
+ file.delete()
+ moduleOutput.eachLine { file.append(it + "\n") }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
new file mode 100644
index 0000000..1656db4
--- /dev/null
+++ b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript;
+
+public class GenerateGremlinJavascript {
+
+ private GenerateGremlinJavascript() {
+ // just need the main method
+ }
+
+ public static void main(String[] args) {
+ TraversalSourceGenerator.create(args[0]);
+ GraphTraversalSourceGenerator.create(args[1]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
new file mode 100644
index 0000000..535de44
--- /dev/null
+++ b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript.jsr223;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Jorge Bay Gondra
+ */
+public final class SymbolHelper {
+
+ private final static Map<String, String> TO_JS_MAP = new HashMap<>();
+ private final static Map<String, String> FROM_JS_MAP = new HashMap<>();
+
+ static {
+ TO_JS_MAP.put("in", "in_");
+ TO_JS_MAP.put("from", "from_");
+ TO_JS_MAP.forEach((k, v) -> FROM_JS_MAP.put(v, k));
+ }
+
+ private SymbolHelper() {
+ // static methods only, do not instantiate
+ }
+
+ public static String toJs(final String symbol) {
+ return TO_JS_MAP.getOrDefault(symbol, symbol);
+ }
+
+ public static String toJava(final String symbol) {
+ return FROM_JS_MAP.getOrDefault(symbol, symbol);
+ }
+
+ public static String decapitalize(String string) {
+ if (string == null || string.length() == 0) {
+ return string;
+ }
+ char c[] = string.toCharArray();
+ c[0] = Character.toLowerCase(c[0]);
+ return new String(c);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
new file mode 100644
index 0000000..99b177f
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function defineRemoteConnectionModule() {
+ "use strict";
+
+ var t = loadModule.call(this, '../process/traversal.js');
+ var inherits = t.inherits;
+
+ function RemoteConnection(url, traversalSource) {
+ this.url = url;
+ this.traversalSource = traversalSource;
+ }
+
+ /**
+ * @abstract
+ * @param {Bytecode} bytecode
+ * @param {Function} callback
+ */
+ RemoteConnection.prototype.submit = function (bytecode, callback) {
+ throw new Error('submit() needs to be implemented');
+ };
+
+ /**
+ * @extends {Traversal}
+ * @constructor
+ */
+ function RemoteTraversal(traversers, sideEffects) {
+ t.Traversal.call(this, null, null, null);
+ this.traversers = traversers;
+ this.sideEffects = sideEffects;
+ }
+
+ inherits(RemoteTraversal, t.Traversal);
+
+ /**
+ *
+ * @param {RemoteConnection} connection
+ * @extends {TraversalStrategy}
+ * @constructor
+ */
+ function RemoteStrategy(connection) {
+ t.TraversalStrategy.call(this);
+ this.connection = connection;
+ }
+
+ inherits(RemoteStrategy, t.TraversalStrategy);
+
+ /** @override */
+ RemoteStrategy.prototype.apply = function (traversal, callback) {
+ if (traversal.traversers) {
+ return;
+ }
+ this.connection.submit(traversal.getBytecode(), function (err, remoteTraversal) {
+ if (err) {
+ return callback(err);
+ }
+ traversal.sideEffects = remoteTraversal.sideEffects;
+ traversal.traversers = remoteTraversal.traversers;
+ callback();
+ });
+ };
+
+ function loadModule(moduleName) {
+ if (typeof require !== 'undefined') {
+ return require(moduleName);
+ }
+ if (typeof load !== 'undefined') {
+ var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+ this.__dependencies = this.__dependencies || {};
+ return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+ }
+ throw new Error('No module loader was found');
+ }
+
+ var toExport = {
+ RemoteConnection: RemoteConnection,
+ RemoteStrategy: RemoteStrategy,
+ RemoteTraversal: RemoteTraversal
+ };
+ if (typeof module !== 'undefined') {
+ // CommonJS
+ module.exports = toExport;
+ return;
+ }
+ // Nashorn and rest
+ return toExport;
+}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d850565/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
new file mode 100644
index 0000000..cda8200
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+(function exportModule() {
+ "use strict";
+
+ function loadModule(moduleName) {
+ if (typeof require !== 'undefined') {
+ return require(moduleName);
+ }
+ if (typeof load !== 'undefined') {
+ var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
+ this.__dependencies = this.__dependencies || {};
+ return this.__dependencies[path] = (this.__dependencies[path] || load(path));
+ }
+ throw new Error('No module loader was found');
+ }
+
+ var t = loadModule.call(this, './process/traversal.js');
+ var gt = loadModule.call(this, './process/graph-traversal.js');
+ var graph = loadModule.call(this, './structure/graph.js');
+ var gs = loadModule.call(this, './structure/io/graph-serializer.js');
+ var rc = loadModule.call(this, './driver/remote-connection.js');
+ var toExport = {
+ driver: {
+ RemoteConnection: rc.RemoteConnection,
+ RemoteStrategy: rc.RemoteStrategy,
+ RemoteTraversal: rc.RemoteTraversal
+ },
+ process: {
+ Bytecode: t.Bytecode,
+ EnumValue: t.EnumValue,
+ inherits: t.inherits,
+ P: t.P,
+ parseArgs: t.parseArgs,
+ Traversal: t.Traversal,
+ TraversalSideEffects: t.TraversalSideEffects,
+ TraversalStrategies: t.TraversalStrategies,
+ TraversalStrategy: t.TraversalStrategy,
+ Traverser: t.Traverser,
+ GraphTraversal: gt.GraphTraversal,
+ GraphTraversalSource: gt.GraphTraversalSource,
+ statics: gt.statics
+ },
+ structure: {
+ io: {
+ GraphSONReader: gs.GraphSONReader,
+ GraphSONWriter: gs.GraphSONWriter
+ },
+ Edge: graph.Edge,
+ Graph: graph.Graph,
+ Path: graph.Path,
+ Property: graph.Property,
+ Vertex: graph.Vertex,
+ VertexProperty: graph.VertexProperty
+ }
+ };
+
+
+ if (typeof module !== 'undefined') {
+ // CommonJS
+ module.exports = toExport;
+ return;
+ }
+ return toExport;
+}).call(this);
\ No newline at end of file
[38/47] tinkerpop git commit: Make Travis use a newer version of
Maven.
Posted by jo...@apache.org.
Make Travis use a newer version of Maven.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/397393d2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/397393d2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/397393d2
Branch: refs/heads/master
Commit: 397393d27786e0366991215c36e7ea903fba3d67
Parents: 8d722a9
Author: Lukas Krejci <lk...@redhat.com>
Authored: Tue Nov 15 11:21:34 2016 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:17 2018 +0100
----------------------------------------------------------------------
.travis.install-maven.sh | 19 +++++++++++++++++++
.travis.yml | 13 ++++++++++++-
pom.xml | 1 +
3 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/397393d2/.travis.install-maven.sh
----------------------------------------------------------------------
diff --git a/.travis.install-maven.sh b/.travis.install-maven.sh
new file mode 100644
index 0000000..66affe6
--- /dev/null
+++ b/.travis.install-maven.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -xe
+
+MVN_VERSION="$1"
+MVN_INSTALL_DIR="$2"
+
+if [ ! -f "${MVN_INSTALL_DIR}/lib/maven-artifact-${MVN_VERSION}.jar" ]; then
+ rm -Rf "${MVN_INSTALL_DIR}"
+ mkdir -p "${MVN_INSTALL_DIR}"
+
+ APACHE_MIRROR="$(curl -sL https://www.apache.org/dyn/closer.cgi?asjson=1 | python -c 'import sys, json; print json.load(sys.stdin)["preferred"]')"
+ curl -o "${HOME}/apache-maven-$MVN_VERSION-bin.tar.gz" "$APACHE_MIRROR/maven/maven-3/$MVN_VERSION/binaries/apache-maven-$MVN_VERSION-bin.tar.gz"
+ cd "${MVN_INSTALL_DIR}"
+ tar -xzf "${HOME}/apache-maven-$MVN_VERSION-bin.tar.gz" --strip 1
+ chmod +x "${MVN_INSTALL_DIR}/bin/mvn"
+else
+ echo "Using cached Maven ${MVN_VERSION}"
+fi
+${MVN_INSTALL_DIR}/bin/mvn -version
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/397393d2/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 2c86de3..442de5e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,17 @@ jdk:
- oraclejdk8
sudo: required
dist: trusty
+cache:
+ directories:
+ - $HOME/mvn-home
+
+install:
+ # install maven 3.3.9 if it is not in cache already
+ - bash .travis.install-maven.sh "3.3.9" "${HOME}/mvn-home"
+ - export M2_HOME=${HOME}/mvn-home
+ - export PATH=${HOME}/mvn-home/bin:${PATH}
+ # visual check that we have the correct maven version installed
+ - mvn -version
before_install:
- sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
@@ -16,4 +27,4 @@ jobs:
include:
- script: "mvn clean install -Dci"
- script: "touch gremlin-dotnet/src/.glv && touch gremlin-dotnet/test/.glv && mvn clean install -pl :gremlin-dotnet,:gremlin-dotnet-tests -P gremlin-dotnet -DskipIntegrationTests=false"
- - script: "mvn clean install -pl :gremlin-javascript -DskipIntegrationTests=false"
\ No newline at end of file
+ - script: "mvn clean install -pl :gremlin-javascript -DskipIntegrationTests=false"
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/397393d2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 157b9bf..259f16a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -287,6 +287,7 @@ limitations under the License.
<excludeSubProjects>false</excludeSubProjects>
<excludes>
<exclude>.travis.yml</exclude>
+ <exclude>.travis.*.sh</exclude>
<exclude>.dockerignore</exclude>
<exclude>**/.classpath</exclude>
<exclude>**/.project</exclude>
[46/47] tinkerpop git commit: Merge branch 'tp32'
Posted by jo...@apache.org.
Merge branch 'tp32'
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6923a6a4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6923a6a4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6923a6a4
Branch: refs/heads/master
Commit: 6923a6a431b0fac83f33f753a5dda3f1dbace216
Parents: 74479dd 0bcab7f
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Jan 25 11:33:59 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Thu Jan 25 11:33:59 2018 +0100
----------------------------------------------------------------------
.travis.yml | 14 +-
.../developer/development-environment.asciidoc | 15 +
docs/src/reference/gremlin-variants.asciidoc | 75 +-
.../glv/GraphTraversalSource.template | 126 ++
gremlin-javascript/glv/PackageJson.template | 59 +
gremlin-javascript/glv/TraversalSource.template | 201 +++
gremlin-javascript/glv/generate.groovy | 107 ++
gremlin-javascript/pom.xml | 301 +++++
.../javascript/gremlin-javascript/.gitignore | 5 +
.../javascript/gremlin-javascript/.npmignore | 26 +
.../javascript/gremlin-javascript/README.md | 39 +
.../main/javascript/gremlin-javascript/index.js | 75 ++
.../lib/driver/driver-remote-connection.js | 194 +++
.../lib/driver/remote-connection.js | 77 ++
.../gremlin-javascript/lib/process/bytecode.js | 98 ++
.../lib/process/graph-traversal.js | 1264 ++++++++++++++++++
.../lib/process/traversal-strategy.js | 75 ++
.../gremlin-javascript/lib/process/traversal.js | 268 ++++
.../gremlin-javascript/lib/structure/graph.js | 168 +++
.../lib/structure/io/graph-serializer.js | 181 +++
.../lib/structure/io/type-serializers.js | 295 ++++
.../javascript/gremlin-javascript/lib/utils.js | 35 +
.../javascript/gremlin-javascript/package.json | 40 +
.../test/cucumber/feature-steps.js | 327 +++++
.../gremlin-javascript/test/cucumber/world.js | 126 ++
.../gremlin-javascript/test/helper.js | 29 +
.../test/integration/remote-connection-tests.js | 58 +
.../test/integration/traversal-test.js | 69 +
.../test/unit/exports-test.js | 73 +
.../test/unit/graphson-test.js | 112 ++
.../test/unit/traversal-test.js | 194 +++
pom.xml | 5 +
32 files changed, 4727 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6923a6a4/docs/src/dev/developer/development-environment.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6923a6a4/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6923a6a4/pom.xml
----------------------------------------------------------------------
diff --cc pom.xml
index 8ea0a5a,259f16a..aafa895
--- a/pom.xml
+++ b/pom.xml
@@@ -116,8 -116,11 +116,9 @@@ limitations under the License
<module>gremlin-shaded</module>
<module>gremlin-core</module>
<module>gremlin-test</module>
- <module>gremlin-benchmark</module>
<module>gremlin-groovy</module>
- <module>gremlin-groovy-test</module>
<module>tinkergraph-gremlin</module>
+ <module>gremlin-javascript</module>
<module>gremlin-python</module>
<module>gremlin-dotnet</module>
<module>hadoop-gremlin</module>
[07/47] tinkerpop git commit: Update Javascript GLV
Posted by jo...@apache.org.
Update Javascript GLV
Address feedback and provide maven integration:
- Reorganize gremlin-javascript into node.js project
- Simplify javascript code generators
- Generate package.json to match project version
- Introduce Promise factory for third-party promise library integration (ie: bluebird)
- Use toList() and next() traversal methods
- Include Remote connection implementation
- Fix enum casing
- Use Maven nodejs plugin
- .gitignore and .npmignore at gremlin-javascript level
- Run integration tests using a gremlin-server instance
- Add gremlin-javascript doc in gremlin-variants.asciidoc
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2b4e8e3b
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2b4e8e3b
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2b4e8e3b
Branch: refs/heads/master
Commit: 2b4e8e3b517098dd29b3cfd1ed48f066eb120d66
Parents: e94d415
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Jun 6 15:05:14 2017 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:14 2018 +0100
----------------------------------------------------------------------
docs/src/reference/gremlin-variants.asciidoc | 75 +-
gremlin-javascript/pom.xml | 171 +-
.../javascript/GenerateGremlinJavascript.groovy | 36 +
.../GraphTraversalSourceGenerator.groovy | 226 +-
.../javascript/PackageJsonGenerator.groovy | 72 +
.../gremlin/javascript/SymbolHelper.groovy | 50 +
.../javascript/TraversalSourceGenerator.groovy | 437 ++--
.../javascript/GenerateGremlinJavascript.java | 32 -
.../gremlin/javascript/jsr223/SymbolHelper.java | 59 -
.../javascript/gremlin-javascript/.gitignore | 5 +
.../javascript/gremlin-javascript/.npmignore | 26 +
.../javascript/gremlin-javascript/README.md | 39 +
.../driver/remote-connection.js | 107 -
.../main/javascript/gremlin-javascript/index.js | 113 +-
.../lib/driver/driver-remote-connection.js | 200 ++
.../lib/driver/remote-connection.js | 84 +
.../gremlin-javascript/lib/process/bytecode.js | 99 +
.../lib/process/graph-traversal.js | 2095 ++++++++++++++++++
.../lib/process/traversal-strategy.js | 88 +
.../gremlin-javascript/lib/process/traversal.js | 236 ++
.../gremlin-javascript/lib/structure/graph.js | 138 ++
.../lib/structure/io/graph-serializer.js | 398 ++++
.../javascript/gremlin-javascript/lib/utils.js | 62 +
.../javascript/gremlin-javascript/package.json | 36 +
.../process/graph-traversal.js | 2016 -----------------
.../gremlin-javascript/process/traversal.js | 392 ----
.../gremlin-javascript/structure/graph.js | 157 --
.../structure/io/graph-serializer.js | 415 ----
.../test/integration/remote-connection-tests.js | 64 +
.../test/integration/traversal-test.js | 71 +
.../test/unit/exports-test.js | 73 +
.../test/unit/graphson-test.js | 112 +
.../test/unit/traversal-test.js | 119 +
.../javascript/gremlin-javascript/helper.js | 84 -
.../gremlin-javascript/test-exports.js | 87 -
.../gremlin-javascript/test-graphson.js | 108 -
.../gremlin-javascript/test-traversal.js | 69 -
pom.xml | 4 +
38 files changed, 4624 insertions(+), 4031 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index 0c48c97..76952eb 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -392,8 +392,8 @@ g.V().Repeat(Out()).Times(2).Values("name").Fold().ToList()
=== Bindings
-When a traversal bytecode is sent over a `IRemoteConnection` (e.g. Gremlin Server), it will be translated, compiled,
-and then executed. If the same traversal is sent again, translation and compilation can be skipped as the previously
+When a traversal bytecode is sent over a `IRemoteConnection` (e.g. Gremlin Server), it will be translated, compiled,
+and then executed. If the same traversal is sent again, translation and compilation can be skipped as the previously
compiled version should be cached. Many traversals are unique up to some parameterization. For instance,
`g.V(1).Out("created").Values("name")` is considered different from `g.V(4).Out("created").Values("Name")`
as they have different script "string" representations. However, `g.V(x).Out("created").Values("name")` with bindings of
@@ -422,7 +422,7 @@ g = g.WithoutStrategies(typeof(SubgraphStrategy));
names = g.V().Values("name").ToList(); // names: [marko, vadas, lop, josh, ripple, peter]
var edgeValueMaps = g.V().OutE().ValueMap(true).ToList();
-// edgeValueMaps: [[label:created, id:9, weight:0.4], [label:knows, id:7, weight:0.5], [label:knows, id:8, weight:1.0],
+// edgeValueMaps: [[label:created, id:9, weight:0.4], [label:knows, id:7, weight:0.5], [label:knows, id:8, weight:1.0],
// [label:created, id:10, weight:1.0], [label:created, id:11, weight:0.4], [label:created, id:12, weight:0.2]]
g = g.WithComputer(workers: 2, vertices: Has("name", "marko"));
@@ -435,3 +435,72 @@ edgeValueMaps = g.V().OutE().ValueMap(true).ToList();
NOTE: Many of the TraversalStrategy classes in Gremlin.Net are proxies to the respective strategy on Apache TinkerPop’s
JVM-based Gremlin traversal machine. As such, their `Apply(ITraversal)` method does nothing. However, the strategy is
encoded in the Gremlin.Net bytecode and transmitted to the Gremlin traversal machine for re-construction machine-side.
+
+[[gremlin-javascript]]
+== Gremlin-JavaScript
+
+
+Apache TinkerPop's Gremlin-JavaScript implements Gremlin within the JavaScript language. It targets Node.js runtime
+and can be used on different operating systems on any Node.js 4 or above. Since the JavaScript naming conventions are
+very similar to that of Java, it should be very easy to switch between Gremlin-Java and Gremlin-JavaScript.
+
+[source,bash]
+npm install gremlin-javascript
+
+In Gremlin-JavaScript there exists `GraphTraversalSource`, `GraphTraversal`, and `__` which mirror the respective classes
+in Gremlin-Java. The `GraphTraversalSource` requires a RemoteConnection implementation in order to communicate with
+<<gremlin-server,GremlinServer>>.
+
+A traversal source can be spawned with `RemoteStrategy` from an empty `Graph`.
+
+[source,javascript]
+----
+const graph = new Graph();
+const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'));
+----
+
+When a traversal from the `GraphTraversalSource` is iterated, the traversal’s `Bytecode` is sent over the wire via
+the registered `RemoteConnection`. The bytecode is used to construct the equivalent traversal at the remote
+traversal source.
+
+Since Gremlin-JavaScript currently doesn't support lambda expressions, all traversals can be translated to
+Gremlin-Java on the remote location (e.g. Gremlin Server).
+
+IMPORTANT: Gremlin-JavaScript’s `Traversal` base class supports the standard Gremlin methods such as `next()` and
+`toList()` Such "terminal" methods trigger the evaluation of the traversal.
+
+=== RemoteConnection Submission
+
+Very similar to Gremlin-Python and Gremlin-Java, there are various ways to submit a traversal to a
+`RemoteConnection` using terminal/action methods off of `Traversal`.
+
+* `Traversal.next()`
+* `Traversal.toList()`
+
+=== Static Enums and Methods
+
+Gremlin has various tokens (e.g. `t`, `P`, `order`, `direction`, etc.) that are represented in Gremlin-JavaScript as
+objects.
+
+These can be used analogously to how they are used in Gremlin-Java.
+
+[source,javascript]
+g.V().hasLabel("person").has("age",P.gt(30)).Order().By("age", order.decr).toList()
+
+These objects must be required manually from the `process` namespace:
+
+[source,javascript]
+----
+const gremlin = require('gremlin-javascript');
+const P = gremlin.process.P;
+----
+
+Finally, using static `__` anonymous traversals like `__.out()` can be expressed as below:
+
+[source,javascript]
+----
+const gremlin = require('gremlin-javascript');
+const __ = gremlin.process.statics;
+
+g.V().repeat(__.out()).times(2).values("name").fold().toList();
+----
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index b9b78cc..1c9ffcc 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -37,6 +37,7 @@ limitations under the License.
<version>${groovy.version}</version>
<classifier>indy</classifier>
</dependency>
+ <!-- TESTING -->
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>tinkergraph-gremlin</artifactId>
@@ -58,12 +59,10 @@ limitations under the License.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
- <!-- provides a way to convert maven.test.skip value to skipTests for use in skipping python tests -->
<maven.test.skip>false</maven.test.skip>
<skipTests>${maven.test.skip}</skipTests>
<gremlin.server.dir>${project.parent.basedir}/gremlin-server</gremlin.server.dir>
@@ -86,33 +85,92 @@ limitations under the License.
<configuration>
<mainClass>org.apache.tinkerpop.gremlin.javascript.GenerateGremlinJavascript</mainClass>
<arguments>
- <argument>${basedir}/src/main/javascript/gremlin-javascript/process/traversal.js</argument>
- <argument>${basedir}/src/main/javascript/gremlin-javascript/process/graph-traversal.js</argument>
+ <argument>${project.version}</argument>
+ <argument>${basedir}</argument>
</arguments>
</configuration>
</execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.gmavenplus</groupId>
+ <artifactId>gmavenplus-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.17</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-server</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-ant</artifactId>
+ <version>${groovy.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
<execution>
- <id>js-tests</id>
- <phase>test</phase>
+ <id>gremlin-server-start</id>
+ <phase>pre-integration-test</phase>
<goals>
- <goal>exec</goal>
+ <goal>execute</goal>
</goals>
<configuration>
- <executable>jjs</executable>
- <arguments>
- <argument>${basedir}/src/test/javascript/gremlin-javascript/test-exports.js</argument>
- <argument>${basedir}/src/test/javascript/gremlin-javascript/test-graphson.js</argument>
- <argument>${basedir}/src/test/javascript/gremlin-javascript/test-traversal.js</argument>
- </arguments>
+ <scripts>
+ <script>
+ <![CDATA[
+import org.apache.tinkerpop.gremlin.server.GremlinServer
+import org.apache.tinkerpop.gremlin.server.Settings
+import org.apache.tinkerpop.gremlin.server.Settings.ScriptEngineSettings
+import org.apache.tinkerpop.gremlin.server.op.session.Session
+
+if (${skipIntegrationTests}) return
+log.info("Starting Gremlin Server instances for native testing of gremlin-javascript")
+def settings = Settings.read("${gremlin.server.dir}/conf/gremlin-server-modern.yaml")
+settings.graphs.graph = "${gremlin.server.dir}/conf/tinkergraph-empty.properties"
+settings.scriptEngines["gremlin-groovy"].scripts = ["${gremlin.server.dir}/scripts/generate-modern.groovy"]
+settings.port = 45950
+def server = new GremlinServer(settings)
+server.start().join()
+project.setContextValue("gremlin.javascript.server", server)
+log.info("Gremlin Server started on port 45950")
+]]>
+ </script>
+ </scripts>
+ </configuration>
+ </execution>
+ <execution>
+ <id>gremlin-server-stop</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <scripts>
+ <script>
+ <![CDATA[
+import org.apache.tinkerpop.gremlin.server.GremlinServer
+import org.apache.tinkerpop.gremlin.server.op.session.Session
+
+if (${skipIntegrationTests}) return
+log.info("Tests for native gremlin-javascript complete")
+def server = project.getContextValue("gremlin.javascript.server")
+log.info("Shutting down $server")
+server.stop().join()
+]]>
+ </script>
+ </scripts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
- <groupId>org.codehaus.gmavenplus</groupId>
- <artifactId>gmavenplus-plugin</artifactId>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
@@ -124,6 +182,85 @@ limitations under the License.
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <version>1.4</version>
+ <executions>
+ <execution>
+ <id>install node and npm</id>
+ <goals>
+ <goal>install-node-and-npm</goal>
+ </goals>
+ <phase>generate-test-resources</phase>
+ </execution>
+ <execution>
+ <id>npm install</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <phase>generate-test-resources</phase>
+ <configuration>
+ <arguments>install</arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>npm test</id>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <phase>integration-test</phase>
+ <configuration>
+ <arguments>test</arguments>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <skip>${skipIntegrationTests}</skip>
+ <workingDirectory>src/main/javascript/gremlin-javascript</workingDirectory>
+ <nodeVersion>v4.8.3</nodeVersion>
+ </configuration>
+ </plugin>
</plugins>
</build>
+ <profiles>
+ <!--
+ Provides a way to deploy the gremlin-javascript GLV to npm. This cannot be part of the standard maven execution
+ because npm does not have a staging environment like sonatype for releases. As soon as the release is
+ published it is public. In our release workflow, deploy occurs prior to vote on the release and we can't
+ make this stuff public until the vote is over.
+ -->
+ <profile>
+ <id>glv-javascript-deploy</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <version>1.4</version>
+ <executions>
+ <execution>
+ <id>npm publish</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <configuration>
+ <arguments>publish</arguments>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <skip>${skipIntegrationTests}</skip>
+ <workingDirectory>src/main/javascript/gremlin-javascript</workingDirectory>
+ <nodeVersion>v4.8.3</nodeVersion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
new file mode 100644
index 0000000..ab9eaf1
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript
+
+public class GenerateGremlinJavascript {
+ public static void main(String[] args) {
+ String projectVersion = args[0];
+ final String baseDir = args[1];
+ final String jsModuleDir = "${baseDir}/src/main/javascript/gremlin-javascript";
+ Integer versionSnapshotIndex = projectVersion.indexOf("-SNAPSHOT");
+ if (versionSnapshotIndex > 0) {
+ // Use a alpha version x.y.z-alpha1
+ projectVersion = projectVersion.substring(0, versionSnapshotIndex) + "-alpha1";
+ }
+ TraversalSourceGenerator.create("$jsModuleDir/lib/process/traversal.js");
+ GraphTraversalSourceGenerator.create("$jsModuleDir/lib/process/graph-traversal.js");
+ PackageJsonGenerator.create("$jsModuleDir/package.json", projectVersion);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
index 0ae6079..3227f2c 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -23,7 +23,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
-import org.apache.tinkerpop.gremlin.javascript.jsr223.SymbolHelper
+import org.apache.tinkerpop.gremlin.javascript.SymbolHelper
import java.lang.reflect.Modifier
@@ -63,45 +63,46 @@ class GraphTraversalSourceGenerator {
/**
* @author Jorge Bay Gondra
*/
-(function defineGraphTraversalModule() {
- "use strict";
-
- var t = loadModule.call(this, './traversal.js');
- var remote = loadModule.call(this, '../driver/remote-connection.js');
- var Bytecode = t.Bytecode;
- var inherits = t.inherits;
- var parseArgs = t.parseArgs;
-
- /**
- *
- * @param {Graph} graph
- * @param {TraversalStrategies} traversalStrategies
- * @param {Bytecode} [bytecode]
- * @constructor
- */
- function GraphTraversalSource(graph, traversalStrategies, bytecode) {
- this.graph = graph;
- this.traversalStrategies = traversalStrategies;
- this.bytecode = bytecode || new Bytecode();
- }
-
- /**
- * @param remoteConnection
- * @returns {GraphTraversalSource}
- */
- GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
- var traversalStrategy = new t.TraversalStrategies(this.traversalStrategies);
- traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
- return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
- };
-
- /**
- * Returns the string representation of the GraphTraversalSource.
- * @returns {string}
- */
- GraphTraversalSource.prototype.toString = function () {
- return 'graphtraversalsource[' + this.graph.toString() + ']';
- };
+'use strict';
+
+var t = require('./traversal.js');
+var remote = require('../driver/remote-connection');
+var utils = require('../utils');
+var Bytecode = require('./bytecode');
+var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
+var inherits = utils.inherits;
+var parseArgs = utils.parseArgs;
+
+/**
+ *
+ * @param {Graph} graph
+ * @param {TraversalStrategies} traversalStrategies
+ * @param {Bytecode} [bytecode]
+ * @constructor
+ */
+function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode || new Bytecode();
+}
+
+/**
+ * @param remoteConnection
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+ var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
+ traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+ return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
+};
+
+/**
+ * Returns the string representation of the GraphTraversalSource.
+ * @returns {string}
+ */
+GraphTraversalSource.prototype.toString = function () {
+ return 'graphtraversalsource[' + this.graph.toString() + ']';
+};
""")
GraphTraversalSource.getMethods(). // SOURCE STEPS
findAll { GraphTraversalSource.class.equals(it.returnType) }.
@@ -110,40 +111,40 @@ class GraphTraversalSourceGenerator {
!it.name.equals(TraversalSource.Symbols.withBindings) &&
!it.name.equals(TraversalSource.Symbols.withRemote)
}.
- collect { SymbolHelper.toJs(it.name) }.
+ collect { it.name }.
unique().
sort { a, b -> a <=> b }.
- forEach { method ->
+ forEach { methodName ->
moduleOutput.append(
"""
- /**
- * ${method} GraphTraversalSource method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
- GraphTraversalSource.prototype.${method} = function (args) {
- var b = new Bytecode(this.bytecode).addSource('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
+/**
+ * Graph Traversal Source ${methodName} method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
+ var b = new Bytecode(this.bytecode).addSource('$methodName', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
""")
}
- GraphTraversalSource.getMethods(). // SPAWN STEPS
+ GraphTraversalSource.getMethods().
findAll { GraphTraversal.class.equals(it.returnType) }.
- collect { SymbolHelper.toJs(it.name) }.
+ collect { it.name }.
unique().
sort { a, b -> a <=> b }.
- forEach { method ->
+ forEach { methodName ->
moduleOutput.append(
"""
- /**
- * ${method} GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversalSource.prototype.${method} = function (args) {
- var b = new Bytecode(this.bytecode).addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
- return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
+/**
+ * $methodName GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
+ var b = new Bytecode(this.bytecode).addStep('$methodName', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
""")
}
////////////////////
@@ -151,34 +152,35 @@ class GraphTraversalSourceGenerator {
////////////////////
moduleOutput.append(
"""
- /**
- * Represents a graph traversal.
- * @extends Traversal
- * @constructor
- */
- function GraphTraversal(graph, traversalStrategies, bytecode) {
- t.Traversal.call(this, graph, traversalStrategies, bytecode);
- }
-
- inherits(GraphTraversal, t.Traversal);
+/**
+ * Represents a graph traversal.
+ * @extends Traversal
+ * @constructor
+ */
+function GraphTraversal(graph, traversalStrategies, bytecode) {
+ t.Traversal.call(this, graph, traversalStrategies, bytecode);
+}
+
+inherits(GraphTraversal, t.Traversal);
""")
GraphTraversal.getMethods().
findAll { GraphTraversal.class.equals(it.returnType) }.
findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
- collect { SymbolHelper.toJs(it.name) }.
+ collect { it.name }.
unique().
sort { a, b -> a <=> b }.
- forEach { method ->
+ forEach { methodName ->
moduleOutput.append(
"""
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.${method} = function (args) {
- this.bytecode.addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
- return this;
- };
+/**
+ * Graph traversal $methodName method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
+ this.bytecode.addStep('$methodName', parseArgs.apply(null, arguments));
+ return this;
+};
""")
};
@@ -186,11 +188,11 @@ class GraphTraversalSourceGenerator {
// AnonymousTraversal //
////////////////////////
moduleOutput.append("""
- /**
- * Contains the static method definitions
- * @type {Object}
- */
- var statics = {};
+/**
+ * Contains the static method definitions
+ * @type {Object}
+ */
+var statics = {};
""");
__.class.getMethods().
findAll { GraphTraversal.class.equals(it.returnType) }.
@@ -202,44 +204,24 @@ class GraphTraversalSourceGenerator {
forEach { method ->
moduleOutput.append(
"""
- /**
- * ${method}() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.${method} = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.${method}.apply(g, arguments);
- };
+/**
+ * ${method}() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.${method} = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.${method}.apply(g, arguments);
+};
""")
};
moduleOutput.append("""
- function loadModule(moduleName) {
- if (typeof require !== 'undefined') {
- return require(moduleName);
- }
- if (typeof load !== 'undefined') {
- var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
- this.__dependencies = this.__dependencies || {};
- return this.__dependencies[path] = (this.__dependencies[path] || load(path));
- }
- throw new Error('No module loader was found');
- }
-
- var toExport = {
- GraphTraversal: GraphTraversal,
- GraphTraversalSource: GraphTraversalSource,
- statics: statics
- };
- if (typeof module !== 'undefined') {
- // CommonJS
- module.exports = toExport;
- return;
- }
- // Nashorn and rest
- return toExport;
-}).call(this);""")
+module.exports = {
+ GraphTraversal: GraphTraversal,
+ GraphTraversalSource: GraphTraversalSource,
+ statics: statics
+};""");
// save to file
final File file = new File(graphTraversalSourceFile);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
new file mode 100644
index 0000000..4b4d012
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript
+
+/**
+ * @author Jorge Bay Gondra
+ */
+class PackageJsonGenerator {
+
+ public static void create(final String traversalSourceFile, final String version) {
+
+ final StringBuilder moduleOutput = new StringBuilder();
+ moduleOutput.append("""{
+ "name": "gremlin-javascript",
+ "version": "${version}",
+ "description": "JavaScript Gremlin Language Variant",
+ "author": "Apache TinkerPop team",
+ "keywords": [
+ "graph",
+ "gremlin",
+ "tinkerpop",
+ "connection",
+ "glv",
+ "driver",
+ "graphdb"
+ ],
+ "license": "Apache-2.0",
+ "dependencies": {
+ "ws": "^3.0.0"
+ },
+ "devDependencies": {
+ "mocha": ">= 1.14.0"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/apache/tinkerpop.git"
+ },
+ "bugs": {
+ "url": "https://issues.apache.org/jira/browse/TINKERPOP"
+ },
+ "scripts": {
+ "test": "./node_modules/.bin/mocha test --recursive -t 5000",
+ "unit-test": "./node_modules/.bin/mocha test/unit"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+}""" );
+
+ // save to a file
+ final File file = new File(traversalSourceFile);
+ file.delete()
+ moduleOutput.eachLine { file.append(it + "\n") }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
new file mode 100644
index 0000000..ed45cdb
--- /dev/null
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.javascript
+
+/**
+ * @author Jorge Bay Gondra
+ */
+public final class SymbolHelper {
+
+ private final static Map<String, String> TO_JS_MAP = new HashMap<>();
+
+ static {
+ TO_JS_MAP.put("in", "in_");
+ TO_JS_MAP.put("from", "from_");
+ }
+
+ private SymbolHelper() {
+ // static methods only, do not instantiate
+ }
+
+ public static String toJs(final String symbol) {
+ return TO_JS_MAP.getOrDefault(symbol, symbol);
+ }
+
+ public static String decapitalize(String string) {
+ if (string == null || string.length() == 0) {
+ return string;
+ }
+ def c = string.toCharArray();
+ c[0] = Character.toLowerCase(c[0]);
+ return new String(c);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
index d5899f0..f3405c3 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -21,7 +21,6 @@ package org.apache.tinkerpop.gremlin.javascript
import org.apache.tinkerpop.gremlin.process.traversal.P
import org.apache.tinkerpop.gremlin.util.CoreImports
-import org.apache.tinkerpop.gremlin.javascript.jsr223.SymbolHelper
import java.lang.reflect.Modifier
@@ -57,334 +56,178 @@ class TraversalSourceGenerator {
/**
* @author Jorge Bay Gondra
*/
-(function defineTraversalModule() {
- "use strict";
-
- function Traversal(graph, traversalStrategies, bytecode) {
- this.graph = graph;
- this.traversalStrategies = traversalStrategies;
- this.bytecode = bytecode;
- this.traversers = null;
- this.sideEffects = null;
- }
+'use strict';
+
+var utils = require('../utils');
+var parseArgs = utils.parseArgs;
+var itemDone = Object.freeze({ value: null, done: true });
+var emptyArray = Object.freeze([]);
+
+function Traversal(graph, traversalStrategies, bytecode) {
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode;
+ this.traversers = null;
+ this.sideEffects = null;
+ this._traversalStrategiesPromise = null;
+ this._traversersIteratorIndex = 0;
+}
- /** @returns {Bytecode} */
- Traversal.prototype.getBytecode = function () {
- return this.bytecode;
- };
+/** @returns {Bytecode} */
+Traversal.prototype.getBytecode = function () {
+ return this.bytecode;
+};
- /** @param {Function} callback */
- Traversal.prototype.list = function (callback) {
- var self = this;
- this.traversalStrategies.applyStrategies(this, function (err) {
- if (err) {
- return callback(err);
- }
- callback(err, self.traversers);
- });
- };
+/**
+ * Returns an Array containing the traverser objects.
+ * @returns {Promise.<Array>}
+ */
+Traversal.prototype.toList = function () {
+ var self = this;
+ return this._applyStrategies().then(function () {
+ if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+ return emptyArray;
+ }
+ var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
+ for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
+ arr[i] = self.traversers[i].object;
+ }
+ self._traversersIteratorIndex = self.traversers.length;
+ return arr;
+ });
+};
- /** @param {Function} callback */
- Traversal.prototype.one = function (callback) {
- this.list(function (err, result) {
- callback(err, result && result.length > 0 ? result[0] : null);
- });
- };
+/**
+ * Async iterator method implementation.
+ * Returns a promise containing an iterator item.
+ * @returns {Promise.<{value, done}>}
+ */
+Traversal.prototype.next = function () {
+ var self = this;
+ return this._applyStrategies().then(function () {
+ if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+ return itemDone;
+ }
+ return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
+ });
+};
+
+Traversal.prototype._applyStrategies = function () {
+ if (this._traversalStrategiesPromise) {
+ // Apply strategies only once
+ return this._traversalStrategiesPromise;
+ }
+ return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
+};
- /**
- * Returns the Bytecode JSON representation of the traversal
- * @returns {String}
- */
- Traversal.prototype.toString = function () {
- return this.bytecode.toString();
- };
+/**
+ * Returns the Bytecode JSON representation of the traversal
+ * @returns {String}
+ */
+Traversal.prototype.toString = function () {
+ return this.bytecode.toString();
+};
""");
moduleOutput.append("""
- /**
- * Represents an operation.
- * @constructor
- */
- function P(operator, value, other) {
- this.operator = operator;
- this.value = value;
- this.other = other;
- }
-
- /**
- * Returns the string representation of the instance.
- * @returns {string}
- */
- P.prototype.toString = function () {
- if (this.other === undefined) {
- return this.operator + '(' + this.value + ')';
- }
- return this.operator + '(' + this.value + ', ' + this.other + ')';
- };
+/**
+ * Represents an operation.
+ * @constructor
+ */
+function P(operator, value, other) {
+ this.operator = operator;
+ this.value = value;
+ this.other = other;
+}
- function createP(operator, args) {
- args.unshift(null, operator);
- return new (Function.prototype.bind.apply(P, args));
+/**
+ * Returns the string representation of the instance.
+ * @returns {string}
+ */
+P.prototype.toString = function () {
+ if (this.other === undefined) {
+ return this.operator + '(' + this.value + ')';
}
+ return this.operator + '(' + this.value + ', ' + this.other + ')';
+};
+
+function createP(operator, args) {
+ args.unshift(null, operator);
+ return new (Function.prototype.bind.apply(P, args));
+}
""")
P.class.getMethods().
findAll { Modifier.isStatic(it.getModifiers()) }.
findAll { P.class.isAssignableFrom(it.returnType) }.
- collect { SymbolHelper.toJs(it.name) }.
+ collect { it.name }.
unique().
sort { a, b -> a <=> b }.
- each { method ->
+ each { methodName ->
moduleOutput.append(
"""
- /** @param {...Object} args */
- P.${method} = function (args) {
- return createP('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
- };
+/** @param {...Object} args */
+P.${SymbolHelper.toJs(methodName)} = function (args) {
+ return createP('$methodName', parseArgs.apply(null, arguments));
+};
""")
};
moduleOutput.append("""
- P.prototype.and = function (arg) {
- return new P('and', this, arg);
- };
+P.prototype.and = function (arg) {
+ return new P('and', this, arg);
+};
- P.prototype.or = function (arg) {
- return new P('or', this, arg);
- };
+P.prototype.or = function (arg) {
+ return new P('or', this, arg);
+};
""")
moduleOutput.append("""
- function Traverser(object, bulk) {
- this.object = object;
- this.bulk = bulk == undefined ? 1 : bulk;
- }
-
- function TraversalSideEffects() {
-
- }
-
- /**
- * Creates a new instance of TraversalStrategies.
- * @param {TraversalStrategies} [traversalStrategies]
- * @constructor
- */
- function TraversalStrategies(traversalStrategies) {
- /** @type {Array<TraversalStrategy>} */
- this.strategies = traversalStrategies ? traversalStrategies.strategies : [];
- }
-
- /** @param {TraversalStrategy} strategy */
- TraversalStrategies.prototype.addStrategy = function (strategy) {
- this.strategies.push(strategy);
- };
-
- /**
- * @param {Traversal} traversal
- * @param {Function} callback
- */
- TraversalStrategies.prototype.applyStrategies = function (traversal, callback) {
- eachSeries(this.strategies, function eachStrategy(s, next) {
- s.apply(traversal, next);
- }, callback);
- };
-
- /**
- * @abstract
- * @constructor
- */
- function TraversalStrategy() {
-
- }
-
- /**
- * @abstract
- * @param {Traversal} traversal
- * @param {Function} callback
- */
- TraversalStrategy.prototype.apply = function (traversal, callback) {
-
- };
-
- /**
- * Creates a new instance of Bytecode
- * @param {Bytecode} [toClone]
- * @constructor
- */
- function Bytecode(toClone) {
- this._bindings = {};
- if (!toClone) {
- this.sourceInstructions = [];
- this.stepInstructions = [];
- }
- else {
- this.sourceInstructions = toClone.sourceInstructions.slice(0);
- this.stepInstructions = toClone.sourceInstructions.slice(0);
- }
- }
-
- /**
- * Adds a new source instructions
- * @param {String} name
- * @param {Array} values
- * @returns {Bytecode}
- */
- Bytecode.prototype.addSource = function (name, values) {
- if (name === undefined) {
- throw new Error('Name is not defined');
- }
- var instruction = new Array(values.length + 1);
- instruction[0] = name;
- for (var i = 0; i < values.length; ++i) {
- instruction[i + 1] = this._convertToArgument(values[i]);
- }
- this.sourceInstructions.push(this._generateInstruction(name, values));
- return this;
- };
-
- /**
- * Adds a new step instructions
- * @param {String} name
- * @param {Array} values
- * @returns {Bytecode}
- */
- Bytecode.prototype.addStep = function (name, values) {
- if (name === undefined) {
- throw new Error('Name is not defined');
- }
- this.stepInstructions.push(this._generateInstruction(name, values));
- return this;
- };
-
- Bytecode.prototype._generateInstruction = function (name, values) {
- var instruction = new Array(values.length + 1);
- instruction[0] = name;
- for (var i = 0; i < values.length; ++i) {
- instruction[i + 1] = this._convertToArgument(values[i]);
- }
- return instruction;
- };
-
- /**
- * Returns the JSON representation of the source and step instructions
- * @returns {String}
- */
- Bytecode.prototype.toString = function () {
- return (
- (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
- (this.stepInstructions.length > 0 ? JSON.stringify(this.stepInstructions) : '')
- );
- };
-
- Bytecode.prototype._convertToArgument = function (value) {
- return value;
- };
-
- function toEnum(typeName, keys) {
- var result = {};
- keys.split(' ').forEach(function (k) {
- if (k === k.toUpperCase()) {
- k = k.toLowerCase();
- }
- result[k] = new EnumValue(typeName, k);
- });
- return result;
- }
-
- function EnumValue(typeName, elementName) {
- this.typeName = typeName;
- this.elementName = elementName;
- }
+function Traverser(object, bulk) {
+ this.object = object;
+ this.bulk = bulk == undefined ? 1 : bulk;
+}
- // Utility functions
- /** @returns {Array} */
- function parseArgs() {
- return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
- }
+function TraversalSideEffects() {
- /**
- * @param {Array} arr
- * @param {Function} fn
- * @param {Function} [callback]
- */
- function eachSeries(arr, fn, callback) {
- if (!Array.isArray(arr)) {
- throw new TypeError('First parameter is not an Array');
- }
- callback = callback || noop;
- var length = arr.length;
- if (length === 0) {
- return callback();
- }
- var sync;
- var index = 1;
- fn(arr[0], next);
- if (sync === undefined) {
- sync = false;
- }
+}
- function next(err) {
- if (err) {
- return callback(err);
- }
- if (index >= length) {
- return callback();
- }
- if (sync === undefined) {
- sync = true;
- }
- if (sync) {
- return process.nextTick(function () {
- fn(arr[index++], next);
- });
- }
- fn(arr[index++], next);
+function toEnum(typeName, keys) {
+ var result = {};
+ keys.split(' ').forEach(function (k) {
+ var jsKey = k;
+ if (jsKey === jsKey.toUpperCase()) {
+ jsKey = jsKey.toLowerCase();
}
- }
+ result[jsKey] = new EnumValue(typeName, k);
+ });
+ return result;
+}
- function inherits(ctor, superCtor) {
- ctor.super_ = superCtor;
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- }
+function EnumValue(typeName, elementName) {
+ this.typeName = typeName;
+ this.elementName = elementName;
+}
- var toExport = {
- Bytecode: Bytecode,
- EnumValue: EnumValue,
- inherits: inherits,
- P: P,
- parseArgs: parseArgs,
- Traversal: Traversal,
- TraversalSideEffects: TraversalSideEffects,
- TraversalStrategies: TraversalStrategies,
- TraversalStrategy: TraversalStrategy,
- Traverser: Traverser""")
- for (final Class<? extends Enum> enumClass : CoreImports.getClassImports()
- .findAll { Enum.class.isAssignableFrom(it) }
- .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }
- .collect()) {
- moduleOutput.append(",\n ${SymbolHelper.decapitalize(enumClass.getSimpleName())}: " +
- "toEnum('${SymbolHelper.toJs(enumClass.getSimpleName())}', '");
- enumClass.getEnumConstants()
- .sort { a, b -> a.name() <=> b.name() }
- .each { value -> moduleOutput.append("${SymbolHelper.toJs(value.name())} "); }
- moduleOutput.deleteCharAt(moduleOutput.length() - 1).append("')")
+module.exports = {
+ EnumValue: EnumValue,
+ P: P,
+ Traversal: Traversal,
+ TraversalSideEffects: TraversalSideEffects,
+ Traverser: Traverser""")
+ for (final Class<? extends Enum> enumClass : CoreImports.getClassImports().
+ findAll { Enum.class.isAssignableFrom(it) }.
+ sort { a, b -> a.simpleName <=> b.simpleName }) {
+ moduleOutput.append(",\n ${SymbolHelper.decapitalize(enumClass.simpleName)}: " +
+ "toEnum('${SymbolHelper.toJs(enumClass.simpleName)}', '");
+ moduleOutput.append(
+ enumClass.getEnumConstants().
+ sort { a, b -> a.name() <=> b.name() }.
+ collect { SymbolHelper.toJs(it.name()) }.
+ join(' '));
+ moduleOutput.append("\')");
}
- moduleOutput.append("""
- };
- if (typeof module !== 'undefined') {
- // CommonJS
- module.exports = toExport;
- return;
- }
- // Nashorn and rest
- return toExport;
-}).call(this);""")
+ moduleOutput.append("""\n};""");
// save to a file
final File file = new File(traversalSourceFile);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
deleted file mode 100644
index 1656db4..0000000
--- a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript;
-
-public class GenerateGremlinJavascript {
-
- private GenerateGremlinJavascript() {
- // just need the main method
- }
-
- public static void main(String[] args) {
- TraversalSourceGenerator.create(args[0]);
- GraphTraversalSourceGenerator.create(args[1]);
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java b/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
deleted file mode 100644
index 535de44..0000000
--- a/gremlin-javascript/src/main/java/org/apache/tinkerpop/gremlin/javascript/jsr223/SymbolHelper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript.jsr223;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Jorge Bay Gondra
- */
-public final class SymbolHelper {
-
- private final static Map<String, String> TO_JS_MAP = new HashMap<>();
- private final static Map<String, String> FROM_JS_MAP = new HashMap<>();
-
- static {
- TO_JS_MAP.put("in", "in_");
- TO_JS_MAP.put("from", "from_");
- TO_JS_MAP.forEach((k, v) -> FROM_JS_MAP.put(v, k));
- }
-
- private SymbolHelper() {
- // static methods only, do not instantiate
- }
-
- public static String toJs(final String symbol) {
- return TO_JS_MAP.getOrDefault(symbol, symbol);
- }
-
- public static String toJava(final String symbol) {
- return FROM_JS_MAP.getOrDefault(symbol, symbol);
- }
-
- public static String decapitalize(String string) {
- if (string == null || string.length() == 0) {
- return string;
- }
- char c[] = string.toCharArray();
- c[0] = Character.toLowerCase(c[0]);
- return new String(c);
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/.gitignore
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/.gitignore b/gremlin-javascript/src/main/javascript/gremlin-javascript/.gitignore
new file mode 100644
index 0000000..4c7120c
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/.gitignore
@@ -0,0 +1,5 @@
+node_modules/
+.idea/
+npm-debug.log
+# maven plugin com.github.eirslett frontend-maven-plugin installs node.js runtime in "node" folder
+node/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/.npmignore
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/.npmignore b/gremlin-javascript/src/main/javascript/gremlin-javascript/.npmignore
new file mode 100644
index 0000000..82943d0
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/.npmignore
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+*.gz
+*.tgz
+test/
+.DS_Store
+.idea
+node_modules/
+npm-debug.log
+# maven plugin com.github.eirslett frontend-maven-plugin installs node.js runtime in "node" folder
+node/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/README.md
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/README.md b/gremlin-javascript/src/main/javascript/gremlin-javascript/README.md
new file mode 100644
index 0000000..388e175
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/README.md
@@ -0,0 +1,39 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+# JavaScript Gremlin Language Variant
+
+[Apache TinkerPopâ„¢][tk] is a graph computing framework for both graph databases (OLTP) and graph analytic systems
+(OLAP). [Gremlin][gremlin] is the graph traversal language of TinkerPop. It can be described as a functional,
+data-flow language that enables users to succinctly express complex traversals on (or queries of) their application's
+property graph.
+
+Gremlin-Javascript implements Gremlin within the JavaScript language and can be used on Node.js.
+
+```bash
+npm install gremlin-javascript
+```
+
+Please see the [reference documentation][docs] at Apache TinkerPop for more information.
+
+[tk]: http://tinkerpop.apache.org
+[gremlin]: http://tinkerpop.apache.org/gremlin.html
+[docs]: http://tinkerpop.apache.org/docs/current/reference/#gremlin-javascript
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
deleted file mode 100644
index e19b537..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineRemoteConnectionModule() {
- "use strict";
-
- var t = loadModule.call(this, '../process/traversal.js');
- var inherits = t.inherits;
-
- function RemoteConnection(url, traversalSource) {
- this.url = url;
- this.traversalSource = traversalSource;
- }
-
- /**
- * @abstract
- * @param {Bytecode} bytecode
- * @param {Function} callback
- */
- RemoteConnection.prototype.submit = function (bytecode, callback) {
- throw new Error('submit() needs to be implemented');
- };
-
- /**
- * @extends {Traversal}
- * @constructor
- */
- function RemoteTraversal(traversers, sideEffects) {
- t.Traversal.call(this, null, null, null);
- this.traversers = traversers;
- this.sideEffects = sideEffects;
- }
-
- inherits(RemoteTraversal, t.Traversal);
-
- /**
- *
- * @param {RemoteConnection} connection
- * @extends {TraversalStrategy}
- * @constructor
- */
- function RemoteStrategy(connection) {
- t.TraversalStrategy.call(this);
- this.connection = connection;
- }
-
- inherits(RemoteStrategy, t.TraversalStrategy);
-
- /** @override */
- RemoteStrategy.prototype.apply = function (traversal, callback) {
- if (traversal.traversers) {
- return callback();
- }
- this.connection.submit(traversal.getBytecode(), function (err, remoteTraversal) {
- if (err) {
- return callback(err);
- }
- traversal.sideEffects = remoteTraversal.sideEffects;
- traversal.traversers = remoteTraversal.traversers;
- callback();
- });
- };
-
- function loadModule(moduleName) {
- if (typeof require !== 'undefined') {
- return require(moduleName);
- }
- if (typeof load !== 'undefined') {
- var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
- this.__dependencies = this.__dependencies || {};
- return this.__dependencies[path] = (this.__dependencies[path] || load(path));
- }
- throw new Error('No module loader was found');
- }
-
- var toExport = {
- RemoteConnection: RemoteConnection,
- RemoteStrategy: RemoteStrategy,
- RemoteTraversal: RemoteTraversal
- };
- if (typeof module !== 'undefined') {
- // CommonJS
- module.exports = toExport;
- return;
- }
- // Nashorn and rest
- return toExport;
-}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index ddcdac2..600ac53 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -20,73 +20,54 @@
/**
* @author Jorge Bay Gondra
*/
-(function exportModule() {
- "use strict";
+'use strict';
- function loadModule(moduleName) {
- if (typeof require !== 'undefined') {
- return require(moduleName);
- }
- if (typeof load !== 'undefined') {
- var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
- this.__dependencies = this.__dependencies || {};
- return this.__dependencies[path] = (this.__dependencies[path] || load(path));
- }
- throw new Error('No module loader was found');
- }
+var t = require('./lib/process/traversal');
+var gt = require('./lib/process/graph-traversal');
+var strategiesModule = require('./lib/process/traversal-strategy');
+var graph = require('./lib/structure/graph');
+var gs = require('./lib/structure/io/graph-serializer');
+var rc = require('./lib/driver/remote-connection');
+var Bytecode = require('./lib/process/bytecode');
- var t = loadModule.call(this, './process/traversal.js');
- var gt = loadModule.call(this, './process/graph-traversal.js');
- var graph = loadModule.call(this, './structure/graph.js');
- var gs = loadModule.call(this, './structure/io/graph-serializer.js');
- var rc = loadModule.call(this, './driver/remote-connection.js');
- var toExport = {
- driver: {
- RemoteConnection: rc.RemoteConnection,
- RemoteStrategy: rc.RemoteStrategy,
- RemoteTraversal: rc.RemoteTraversal
- },
- process: {
- Bytecode: t.Bytecode,
- EnumValue: t.EnumValue,
- P: t.P,
- Traversal: t.Traversal,
- TraversalSideEffects: t.TraversalSideEffects,
- TraversalStrategies: t.TraversalStrategies,
- TraversalStrategy: t.TraversalStrategy,
- Traverser: t.Traverser,
- barrier: t.barrier,
- cardinality: t.cardinality,
- column: t.column,
- direction: t.direction,
- operator: t.operator,
- order: t.order,
- pop: t.pop,
- scope: t.scope,
- t: t.t,
- GraphTraversal: gt.GraphTraversal,
- GraphTraversalSource: gt.GraphTraversalSource,
- statics: gt.statics
+module.exports = {
+ driver: {
+ RemoteConnection: rc.RemoteConnection,
+ RemoteStrategy: rc.RemoteStrategy,
+ RemoteTraversal: rc.RemoteTraversal
+ },
+ process: {
+ Bytecode: Bytecode,
+ EnumValue: t.EnumValue,
+ P: t.P,
+ Traversal: t.Traversal,
+ TraversalSideEffects: t.TraversalSideEffects,
+ TraversalStrategies: strategiesModule.TraversalStrategies,
+ TraversalStrategy: strategiesModule.TraversalStrategy,
+ Traverser: t.Traverser,
+ barrier: t.barrier,
+ cardinality: t.cardinality,
+ column: t.column,
+ direction: t.direction,
+ operator: t.operator,
+ order: t.order,
+ pop: t.pop,
+ scope: t.scope,
+ t: t.t,
+ GraphTraversal: gt.GraphTraversal,
+ GraphTraversalSource: gt.GraphTraversalSource,
+ statics: gt.statics
+ },
+ structure: {
+ io: {
+ GraphSONReader: gs.GraphSONReader,
+ GraphSONWriter: gs.GraphSONWriter
},
- structure: {
- io: {
- GraphSONReader: gs.GraphSONReader,
- GraphSONWriter: gs.GraphSONWriter
- },
- Edge: graph.Edge,
- Graph: graph.Graph,
- Path: graph.Path,
- Property: graph.Property,
- Vertex: graph.Vertex,
- VertexProperty: graph.VertexProperty
- }
- };
-
-
- if (typeof module !== 'undefined') {
- // CommonJS
- module.exports = toExport;
- return;
+ Edge: graph.Edge,
+ Graph: graph.Graph,
+ Path: graph.Path,
+ Property: graph.Property,
+ Vertex: graph.Vertex,
+ VertexProperty: graph.VertexProperty
}
- return toExport;
-}).call(this);
\ No newline at end of file
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
new file mode 100644
index 0000000..0d6d507
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var crypto = require('crypto');
+var WebSocket = require('ws');
+var util = require('util');
+var RemoteConnection = require('./remote-connection').RemoteConnection;
+var utils = require('../utils');
+var serializer = require('../structure/io/graph-serializer');
+var inherits = utils.inherits;
+var mimeType = 'application/vnd.gremlin-v2.0+json';
+var header = String.fromCharCode(mimeType.length) + mimeType;
+var responseStatusCode = {
+ success: 200,
+ noContent: 204,
+ partialContent: 206
+};
+
+/**
+ * Creates a new instance of DriverRemoteConnection.
+ * @param {String} url The resource uri.
+ * @param {Object} [options] The connection options.
+ * @param {Array} [options.ca] Trusted certificates.
+ * @param {String|Array|Buffer} [options.cert] The certificate key.
+ * @param {String|Buffer} [options.pfx] The private key, certificate, and CA certs.
+ * @param {GraphSONReader} [options.reader] The GraphSON2 reader to use.
+ * @param {Boolean} [options.rejectUnauthorized] Determines whether to verify or not the server certificate.
+ * @param {GraphSONWriter} [options.writer] The GraphSON2 writer to use.
+ * @constructor
+ */
+function DriverRemoteConnection(url, options) {
+ options = options || {};
+ this._ws = new WebSocket(url, {
+ ca: options.ca,
+ cert: options.cert,
+ pfx: options.pfx,
+ rejectUnauthorized: options.rejectUnauthorized
+ });
+ var self = this;
+ this._ws.on('open', function opened () {
+ self.isOpen = true;
+ if (self._openCallback) {
+ self._openCallback();
+ }
+ });
+ this._ws.on('message', function incoming (data) {
+ self._handleMessage(data);
+ });
+ // A map containing the request id and the handler
+ this._responseHandlers = {};
+ this._reader = options.reader || new serializer.GraphSONReader();
+ this._writer = options.writer || new serializer.GraphSONWriter();
+ this._openPromise = null;
+ this._openCallback = null;
+ this._closePromise = null;
+ this.isOpen = false;
+}
+
+inherits(DriverRemoteConnection, RemoteConnection);
+
+/**
+ * Opens the connection, if its not already opened.
+ * @returns {Promise}
+ */
+DriverRemoteConnection.prototype.open = function (promiseFactory) {
+ if (this._closePromise) {
+ return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
+ callback(new Error('Connection has been closed'));
+ });
+ }
+ if (this._openPromise) {
+ return this._openPromise;
+ }
+ var self = this;
+ return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
+ if (self.isOpen) {
+ return callback();
+ }
+ // It will be invoked when opened
+ self._openCallback = callback;
+ });
+};
+
+/** @override */
+DriverRemoteConnection.prototype.submit = function (bytecode, promiseFactory) {
+ var self = this;
+ return this.open().then(function () {
+ return utils.toPromise(promiseFactory, function promiseHandler(callback) {
+ var requestId = getUuid();
+ self._responseHandlers[requestId] = {
+ callback: callback,
+ result: null
+ };
+ var message = bufferFromString(header + JSON.stringify(self._getRequest(requestId, bytecode)));
+ self._ws.send(message);
+ });
+ });
+};
+
+DriverRemoteConnection.prototype._getRequest = function (id, bytecode) {
+ return ({
+ 'requestId': { '@type': 'g:UUID', '@value': id },
+ 'op': 'bytecode',
+ 'processor': 'traversal',
+ 'args': {
+ 'gremlin': this._writer.adaptObject(bytecode),
+ 'aliases': { 'g': 'g'}
+ }
+ });
+};
+
+DriverRemoteConnection.prototype._handleMessage = function (data) {
+ var response = this._reader.read(JSON.parse(data.toString()));
+ var handler = this._responseHandlers[response.requestId];
+ if (response.status.code >= 400) {
+ // callback in error
+ return handler.callback(
+ new Error(util.format('Server error: %s (%d)', response.status.message, response.status.code)));
+ }
+ switch (response.status.code) {
+ case responseStatusCode.noContent:
+ return handler.callback(null, { traversers: []});
+ case responseStatusCode.partialContent:
+ handler.result = handler.result || [];
+ handler.result.push.apply(handler.result, response.result.data);
+ break;
+ default:
+ if (handler.result) {
+ handler.result.push.apply(handler.result, response.result.data);
+ }
+ else {
+ handler.result = response.result.data;
+ }
+ return handler.callback(null, { traversers: handler.result });
+ }
+};
+
+/**
+ * Closes the Connection.
+ * @return {Promise}
+ */
+DriverRemoteConnection.prototype.close = function (promiseFactory) {
+ if (this._closePromise) {
+ return this._closePromise;
+ }
+ var self = this;
+ return this._closePromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
+ self._ws.on('close', function () {
+ self.isOpen = false;
+ callback();
+ });
+ self._ws.close();
+ });
+};
+
+function getUuid() {
+ var buffer = crypto.randomBytes(16);
+ //clear the version
+ buffer[6] &= 0x0f;
+ //set the version 4
+ buffer[6] |= 0x40;
+ //clear the variant
+ buffer[8] &= 0x3f;
+ //set the IETF variant
+ buffer[8] |= 0x80;
+ var hex = buffer.toString('hex');
+ return (
+ hex.substr(0, 8) + '-' +
+ hex.substr(8, 4) + '-' +
+ hex.substr(12, 4) + '-' +
+ hex.substr(16, 4) + '-' +
+ hex.substr(20, 12));
+}
+
+var bufferFromString = Buffer.from || function newBuffer(text) {
+ return new Buffer(text, 'utf8');
+};
+
+module.exports = DriverRemoteConnection;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
new file mode 100644
index 0000000..8176c37
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var t = require('../process/traversal');
+var TraversalStrategy = require('../process/traversal-strategy').TraversalStrategy;
+var utils = require('../utils');
+var inherits = utils.inherits;
+
+function RemoteConnection(url, traversalSource) {
+ this.url = url;
+}
+
+/**
+ * @abstract
+ * @param {Bytecode} bytecode
+ * @param {Function|undefined} promiseFactory
+ * @returns {Promise}
+ */
+RemoteConnection.prototype.submit = function (bytecode, promiseFactory) {
+ throw new Error('submit() was not implemented');
+};
+
+/**
+ * @extends {Traversal}
+ * @constructor
+ */
+function RemoteTraversal(traversers, sideEffects) {
+ t.Traversal.call(this, null, null, null);
+ this.traversers = traversers;
+ this.sideEffects = sideEffects;
+}
+
+inherits(RemoteTraversal, t.Traversal);
+
+/**
+ *
+ * @param {RemoteConnection} connection
+ * @extends {TraversalStrategy}
+ * @constructor
+ */
+function RemoteStrategy(connection) {
+ TraversalStrategy.call(this);
+ this.connection = connection;
+}
+
+inherits(RemoteStrategy, TraversalStrategy);
+
+/** @override */
+RemoteStrategy.prototype.apply = function (traversal, promiseFactory) {
+ if (traversal.traversers) {
+ return utils.resolvedPromise(promiseFactory);
+ }
+ return this.connection.submit(traversal.getBytecode(), promiseFactory).then(function (remoteTraversal) {
+ traversal.sideEffects = remoteTraversal.sideEffects;
+ traversal.traversers = remoteTraversal.traversers;
+ });
+};
+
+module.exports = {
+ RemoteConnection: RemoteConnection,
+ RemoteStrategy: RemoteStrategy,
+ RemoteTraversal: RemoteTraversal
+};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
new file mode 100644
index 0000000..9256e6a
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+/**
+ * Creates a new instance of Bytecode
+ * @param {Bytecode} [toClone]
+ * @constructor
+ */
+function Bytecode(toClone) {
+ if (!toClone) {
+ this.sourceInstructions = [];
+ this.stepInstructions = [];
+ }
+ else {
+ this.sourceInstructions = toClone.sourceInstructions.slice(0);
+ this.stepInstructions = toClone.sourceInstructions.slice(0);
+ }
+}
+
+/**
+ * Adds a new source instructions
+ * @param {String} name
+ * @param {Array} values
+ * @returns {Bytecode}
+ */
+Bytecode.prototype.addSource = function (name, values) {
+ if (name === undefined) {
+ throw new Error('Name is not defined');
+ }
+ var instruction = new Array(values.length + 1);
+ instruction[0] = name;
+ for (var i = 0; i < values.length; ++i) {
+ instruction[i + 1] = this._convertToArgument(values[i]);
+ }
+ this.sourceInstructions.push(this._generateInstruction(name, values));
+ return this;
+};
+
+/**
+ * Adds a new step instructions
+ * @param {String} name
+ * @param {Array} values
+ * @returns {Bytecode}
+ */
+Bytecode.prototype.addStep = function (name, values) {
+ if (name === undefined) {
+ throw new Error('Name is not defined');
+ }
+ this.stepInstructions.push(this._generateInstruction(name, values));
+ return this;
+};
+
+Bytecode.prototype._generateInstruction = function (name, values) {
+ var length = (values ? values.length : 0) + 1;
+ var instruction = new Array(length);
+ instruction[0] = name;
+ for (var i = 1; i < length; i++) {
+ instruction[i] = this._convertToArgument(values[i - 1]);
+ }
+ return instruction;
+};
+
+/**
+ * Returns the JSON representation of the source and step instructions
+ * @returns {String}
+ */
+Bytecode.prototype.toString = function () {
+ return (
+ (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
+ (this.stepInstructions.length > 0 ? JSON.stringify(this.stepInstructions) : '')
+ );
+};
+
+Bytecode.prototype._convertToArgument = function (value) {
+ return value;
+};
+
+module.exports = Bytecode;
\ No newline at end of file
[34/47] tinkerpop git commit: Use ES6 syntax
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index d887fe0..2877f02 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -26,202 +26,209 @@ const utils = require('../utils');
const parseArgs = utils.parseArgs;
const itemDone = Object.freeze({ value: null, done: true });
-function Traversal(graph, traversalStrategies, bytecode) {
- this.graph = graph;
- this.traversalStrategies = traversalStrategies;
- this.bytecode = bytecode;
- /** @type {Array<Traverser>} */
- this.traversers = null;
- this.sideEffects = null;
- this._traversalStrategiesPromise = null;
- this._traversersIteratorIndex = 0;
-}
+class Traversal {
+ constructor(graph, traversalStrategies, bytecode) {
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode;
+ /** @type {Array<Traverser>} */
+ this.traversers = null;
+ this.sideEffects = null;
+ this._traversalStrategiesPromise = null;
+ this._traversersIteratorIndex = 0;
+ }
-/** @returns {Bytecode} */
-Traversal.prototype.getBytecode = function () {
- return this.bytecode;
-};
+ /** @returns {Bytecode} */
+ getBytecode() {
+ return this.bytecode;
+ }
-/**
- * Returns an Array containing the traverser objects.
- * @returns {Promise.<Array>}
- */
-Traversal.prototype.toList = function () {
- return this._applyStrategies().then(() => {
- const result = [];
- let it;
- while ((it = this._getNext()) && !it.done) {
- result.push(it.value);
+ /**
+ * Returns an Array containing the traverser objects.
+ * @returns {Promise.<Array>}
+ */
+ toList() {
+ return this._applyStrategies().then(() => {
+ const result = [];
+ let it;
+ while ((it = this._getNext()) && !it.done) {
+ result.push(it.value);
+ }
+ return result;
+ });
+ };
+
+ /**
+ * Iterates all Traverser instances in the traversal.
+ * @returns {Promise}
+ */
+ iterate() {
+ return this._applyStrategies().then(() => {
+ let it;
+ while ((it = this._getNext()) && !it.done) {
+ }
+ });
+ }
+
+ /**
+ * Async iterator method implementation.
+ * Returns a promise containing an iterator item.
+ * @returns {Promise.<{value, done}>}
+ */
+ next() {
+ return this._applyStrategies().then(() => this._getNext());
+ }
+
+ /**
+ * Synchronous iterator of traversers including
+ * @private
+ */
+ _getNext() {
+ while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
+ let traverser = this.traversers[this._traversersIteratorIndex];
+ if (traverser.bulk > 0) {
+ traverser.bulk--;
+ return { value: traverser.object, done: false };
+ }
+ this._traversersIteratorIndex++;
}
- return result;
- });
-};
+ return itemDone;
+ }
-/**
- * Iterates all Traverser instances in the traversal.
- * @returns {Promise}
- */
-Traversal.prototype.iterate = function () {
- return this._applyStrategies().then(() => {
- let it;
- while ((it = this._getNext()) && !it.done) {
+ _applyStrategies() {
+ if (this._traversalStrategiesPromise) {
+ // Apply strategies only once
+ return this._traversalStrategiesPromise;
}
- });
-};
+ return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
+ }
-/**
- * Async iterator method implementation.
- * Returns a promise containing an iterator item.
- * @returns {Promise.<{value, done}>}
- */
-Traversal.prototype.next = function () {
- return this._applyStrategies().then(() => this._getNext());
-};
+ /**
+ * Returns the Bytecode JSON representation of the traversal
+ * @returns {String}
+ */
+ toString() {
+ return this.bytecode.toString();
+ };
+}
-/**
- * Synchronous iterator of traversers including
- * @private
- */
-Traversal.prototype._getNext = function () {
- while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
- let traverser = this.traversers[this._traversersIteratorIndex];
- if (traverser.bulk > 0) {
- traverser.bulk--;
- return { value: traverser.object, done: false };
+class P {
+ /**
+ * Represents an operation.
+ * @constructor
+ */
+ constructor(operator, value, other) {
+ this.operator = operator;
+ this.value = value;
+ this.other = other;
+ }
+
+ /**
+ * Returns the string representation of the instance.
+ * @returns {string}
+ */
+ toString() {
+ if (this.other === undefined) {
+ return this.operator + '(' + this.value + ')';
}
- this._traversersIteratorIndex++;
+ return this.operator + '(' + this.value + ', ' + this.other + ')';
}
- return itemDone;
-};
-Traversal.prototype._applyStrategies = function () {
- if (this._traversalStrategiesPromise) {
- // Apply strategies only once
- return this._traversalStrategiesPromise;
+ and(arg) {
+ return new P('and', this, arg);
}
- return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
-};
-/**
- * Returns the Bytecode JSON representation of the traversal
- * @returns {String}
- */
-Traversal.prototype.toString = function () {
- return this.bytecode.toString();
-};
+ or(arg) {
+ return new P('or', this, arg);
+ }
-/**
- * Represents an operation.
- * @constructor
- */
-function P(operator, value, other) {
- this.operator = operator;
- this.value = value;
- this.other = other;
-}
+ /** @param {...Object} args */
+ static between(args) {
+ return createP('between', parseArgs.apply(null, arguments));
+ }
-/**
- * Returns the string representation of the instance.
- * @returns {string}
- */
-P.prototype.toString = function () {
- if (this.other === undefined) {
- return this.operator + '(' + this.value + ')';
+ /** @param {...Object} args */
+ static eq(args) {
+ return createP('eq', parseArgs.apply(null, arguments));
+ }
+
+ /** @param {...Object} args */
+ static gt(args) {
+ return createP('gt', parseArgs.apply(null, arguments));
+ }
+
+ /** @param {...Object} args */
+ static gte(args) {
+ return createP('gte', parseArgs.apply(null, arguments));
+ }
+
+ /** @param {...Object} args */
+ static inside(args) {
+ return createP('inside', parseArgs.apply(null, arguments));
+ }
+
+ /** @param {...Object} args */
+ static lt(args) {
+ return createP('lt', parseArgs.apply(null, arguments));
+ }
+
+ /** @param {...Object} args */
+ static lte(args) {
+ return createP('lte', parseArgs.apply(null, arguments));
+ }
+
+ /** @param {...Object} args */
+ static neq(args) {
+ return createP('neq', parseArgs.apply(null, arguments));
}
- return this.operator + '(' + this.value + ', ' + this.other + ')';
-};
+
+ /** @param {...Object} args */
+ static not(args) {
+ return createP('not', parseArgs.apply(null, arguments));
+ }
+
+ /** @param {...Object} args */
+ static outside(args) {
+ return createP('outside', parseArgs.apply(null, arguments));
+ }
+
+ /** @param {...Object} args */
+ static test(args) {
+ return createP('test', parseArgs.apply(null, arguments));
+ }
+
+ /** @param {...Object} args */
+ static within(args) {
+ return createP('within', parseArgs.apply(null, arguments));
+ }
+
+ /** @param {...Object} args */
+ static without(args) {
+ return createP('without', parseArgs.apply(null, arguments));
+ }
+
+}
function createP(operator, args) {
args.unshift(null, operator);
return new (Function.prototype.bind.apply(P, args));
}
-/** @param {...Object} args */
-P.between = function (args) {
- return createP('between', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.eq = function (args) {
- return createP('eq', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.gt = function (args) {
- return createP('gt', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.gte = function (args) {
- return createP('gte', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.inside = function (args) {
- return createP('inside', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.lt = function (args) {
- return createP('lt', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.lte = function (args) {
- return createP('lte', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.neq = function (args) {
- return createP('neq', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.not = function (args) {
- return createP('not', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.outside = function (args) {
- return createP('outside', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.test = function (args) {
- return createP('test', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.within = function (args) {
- return createP('within', parseArgs.apply(null, arguments));
-};
-
-/** @param {...Object} args */
-P.without = function (args) {
- return createP('without', parseArgs.apply(null, arguments));
-};
-
-P.prototype.and = function (arg) {
- return new P('and', this, arg);
-};
-
-P.prototype.or = function (arg) {
- return new P('or', this, arg);
-};
-
-function Traverser(object, bulk) {
- this.object = object;
- this.bulk = bulk || 1;
+class Traverser {
+ constructor(object, bulk) {
+ this.object = object;
+ this.bulk = bulk || 1;
+ }
}
-function TraversalSideEffects() {
+class TraversalSideEffects {
}
function toEnum(typeName, keys) {
- var result = {};
- keys.split(' ').forEach(function (k) {
- var jsKey = k;
+ const result = {};
+ keys.split(' ').forEach(k => {
+ let jsKey = k;
if (jsKey === jsKey.toUpperCase()) {
jsKey = jsKey.toLowerCase();
}
@@ -230,17 +237,19 @@ function toEnum(typeName, keys) {
return result;
}
-function EnumValue(typeName, elementName) {
- this.typeName = typeName;
- this.elementName = elementName;
+class EnumValue {
+ constructor(typeName, elementName) {
+ this.typeName = typeName;
+ this.elementName = elementName;
+ }
}
module.exports = {
- EnumValue: EnumValue,
- P: P,
- Traversal: Traversal,
- TraversalSideEffects: TraversalSideEffects,
- Traverser: Traverser,
+ EnumValue,
+ P,
+ Traversal,
+ TraversalSideEffects,
+ Traverser,
barrier: toEnum('Barrier', 'normSack'),
cardinality: toEnum('Cardinality', 'list set single'),
column: toEnum('Column', 'keys values'),
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
index cbb7e2c..2861a50 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
@@ -22,120 +22,120 @@
*/
'use strict';
-var gt = require('../process/graph-traversal');
-var TraversalStrategies = require('../process/traversal-strategy').TraversalStrategies;
-var utils = require('../utils');
-var inherits = utils.inherits;
-
-function Graph() {
+const gt = require('../process/graph-traversal');
+const TraversalStrategies = require('../process/traversal-strategy').TraversalStrategies;
+
+class Graph {
+ /**
+ * Returns the graph traversal source.
+ * @returns {GraphTraversalSource}
+ */
+ traversal() {
+ return new gt.GraphTraversalSource(this, new TraversalStrategies());
+ }
+ toString() {
+ return 'graph[empty]';
+ }
}
-/**
- * Returns the graph traversal source.
- * @returns {GraphTraversalSource}
- */
-Graph.prototype.traversal = function () {
- return new gt.GraphTraversalSource(this, new TraversalStrategies());
-};
-
-Graph.prototype.toString = function () {
- return 'graph[empty]';
-};
+class Element {
+ constructor(id, label) {
+ this.id = id;
+ this.label = label;
+ }
-function Element(id, label) {
- this.id = id;
- this.label = label;
+ /**
+ * Compares this instance to another and determines if they can be considered as equal.
+ * @param {Element} other
+ * @returns {boolean}
+ */
+ equals(other) {
+ return (other instanceof Element) && this.id === other.id;
+ }
}
-/**
- * Compares this instance to another and determines if they can be considered as equal.
- * @param {Element} other
- * @returns {boolean}
- */
-Element.prototype.equals = function (other) {
- return (other instanceof Element) && this.id === other.id;
-};
+class Vertex extends Element {
+ constructor(id, label, properties) {
+ super(id, label);
+ this.properties = properties;
+ }
-function Vertex(id, label, properties) {
- Element.call(this, id, label);
- this.properties = properties;
+ toString() {
+ return 'v[' + this.id + ']';
+ }
}
-Vertex.prototype.toString = function () {
- return 'v[' + this.id + ']';
-};
-
-inherits(Vertex, Element);
-
-function Edge(id, outV, label, inV, properties) {
- Element.call(this, id, label);
- this.outV = outV;
- this.inV = inV;
- this.properties = {};
- (function adaptProperties(self) {
+class Edge extends Element {
+ constructor(id, outV, label, inV, properties) {
+ super(id, label);
+ this.outV = outV;
+ this.inV = inV;
+ this.properties = {};
if (properties) {
- var keys = Object.keys(properties);
- for (var i = 0; i < keys.length; i++) {
- var k = keys[i];
- self.properties[k] = properties[k].value;
+ const keys = Object.keys(properties);
+ for (let i = 0; i < keys.length; i++) {
+ const k = keys[i];
+ this.properties[k] = properties[k].value;
}
}
- })(this);
-}
-
-inherits(Edge, Element);
-
-Edge.prototype.toString = function () {
- return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
-};
+ }
-function VertexProperty(id, label, value, properties) {
- Element.call(this, id, label);
- this.value = value;
- this.key = this.label;
- this.properties = properties;
+ toString() {
+ return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
+ }
}
-inherits(VertexProperty, Element);
-
-VertexProperty.prototype.toString = function () {
- return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']';
-};
+class VertexProperty extends Element {
+ constructor(id, label, value, properties) {
+ super(id, label);
+ this.value = value;
+ this.key = this.label;
+ this.properties = properties;
+ }
-function Property(key, value) {
- this.key = key;
- this.value = value;
+ toString() {
+ return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']';
+ }
}
-Property.prototype.toString = function () {
- return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']';
-};
+class Property {
+ constructor(key, value) {
+ this.key = key;
+ this.value = value;
+ }
-Property.prototype.equals = function (other) {
- return (other instanceof Property) && this.key === other.key && this.value === other.value;
-};
+ toString() {
+ return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']';
+ }
-/**
- * Represents a walk through a graph as defined by a traversal.
- * @param {Array} labels
- * @param {Array} objects
- * @constructor
- */
-function Path(labels, objects) {
- this.labels = labels;
- this.objects = objects;
+ equals(other) {
+ return (other instanceof Property) && this.key === other.key && this.value === other.value;
+ }
}
-Path.prototype.equals = function (other) {
- if (!(other instanceof Path)) {
- return false;
+class Path {
+ /**
+ * Represents a walk through a graph as defined by a traversal.
+ * @param {Array} labels
+ * @param {Array} objects
+ * @constructor
+ */
+ constructor(labels, objects) {
+ this.labels = labels;
+ this.objects = objects;
}
- if (other === this) {
- return true;
+
+ equals(other) {
+ if (!(other instanceof Path)) {
+ return false;
+ }
+ if (other === this) {
+ return true;
+ }
+ return areEqual(this.objects, other.objects) && areEqual(this.labels, other.labels);
}
- return areEqual(this.objects, other.objects) && areEqual(this.labels, other.labels);
-};
+}
function areEqual(obj1, obj2) {
if (obj1 === obj2) {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
index 8e4ad5e..3dbd340 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
@@ -22,430 +22,159 @@
*/
'use strict';
-var t = require('../../process/traversal');
-var Bytecode = require('../../process/bytecode');
-var g = require('../graph');
-var utils = require('../../utils');
-
-/**
- * A type serializer
- * @typedef {Object} Serializer
- * @property {Function} serialize
- * @property {Function} deserialize
- * @property {Function} [canBeUsedFor]
- */
-
-/**
- * @const
- * @private
- */
-var valueKey = '@value';
-
-/**
- * @const
- * @private
- */
-var typeKey = '@type';
-
-var deserializers = {
- 'g:Traverser': TraverserSerializer,
- 'g:Int32': NumberSerializer,
- 'g:Int64': NumberSerializer,
- 'g:Float': NumberSerializer,
- 'g:Double': NumberSerializer,
- 'g:Vertex': VertexSerializer,
- 'g:Edge': EdgeSerializer,
- 'g:VertexProperty': VertexPropertySerializer,
- 'g:Property': PropertySerializer,
- 'g:Path': PathSerializer
-};
-
-var serializers = [
- NumberSerializer,
- BytecodeSerializer,
- TraverserSerializer,
- PSerializer,
- LambdaSerializer,
- EnumSerializer,
- VertexSerializer,
- EdgeSerializer,
- LongSerializer
-];
+const typeSerializers = require('./type-serializers');
/**
* GraphSON Writer
- * @param {Object} [options]
- * @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and
- * serializer instances as values, ie: { 'g:Int64': longSerializer }.
- * @constructor
- */
-function GraphSONWriter(options) {
- this._options = options || {};
- // Create instance of the default serializers
- this._serializers = serializers.map(function (serializerConstructor) {
- var s = new serializerConstructor();
- s.writer = this;
- return s;
- }, this);
- var customSerializers = this._options.serializers || {};
- Object.keys(customSerializers).forEach(function (key) {
- var s = customSerializers[key];
- if (!s.serialize) {
- return;
- }
- s.writer = this;
- // Insert custom serializers first
- this._serializers.unshift(s);
- }, this);
-}
-
-GraphSONWriter.prototype.adaptObject = function (value) {
- var s;
- if (Array.isArray(value)) {
- return value.map(function (item) {
- return this.adaptObject(item);
- }, this);
- }
- for (var i = 0; i < this._serializers.length; i++) {
- var currentSerializer = this._serializers[i];
- if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) {
- s = currentSerializer;
- break;
- }
- }
- if (s) {
- return s.serialize(value);
- }
- // Default (strings / objects / ...)
- return value;
-};
-
-/**
- * Returns the GraphSON representation of the provided object instance.
- * @param {Object} obj
- * @returns {String}
*/
-GraphSONWriter.prototype.write = function (obj) {
- return JSON.stringify(this.adaptObject(obj));
-};
-
-/**
- * GraphSON Reader
- * @param {Object} [options]
- * @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and
- * deserializer instances as values, ie: { 'g:Int64': longSerializer }.
- * @constructor
- */
-function GraphSONReader(options) {
- this._options = options || {};
- this._deserializers = {};
- Object.keys(deserializers).forEach(function (typeName) {
- var serializerConstructor = deserializers[typeName];
- var s = new serializerConstructor();
- s.reader = this;
- this._deserializers[typeName] = s;
- }, this);
- if (this._options.serializers) {
- var customSerializers = this._options.serializers || {};
- Object.keys(customSerializers).forEach(function (key) {
- var s = customSerializers[key];
- if (!s.deserialize) {
+class GraphSONWriter {
+ /**
+ * @param {Object} [options]
+ * @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and
+ * serializer instances as values, ie: { 'g:Int64': longSerializer }.
+ * @constructor
+ */
+ constructor(options) {
+ this._options = options || {};
+ // Create instance of the default serializers
+ this._serializers = serializers.map(serializerConstructor => {
+ const s = new serializerConstructor();
+ s.writer = this;
+ return s;
+ });
+ const customSerializers = this._options.serializers || {};
+ Object.keys(customSerializers).forEach(key => {
+ const s = customSerializers[key];
+ if (!s.serialize) {
return;
}
- s.reader = this;
- this._deserializers[key] = s;
- }, this);
+ s.writer = this;
+ // Insert custom serializers first
+ this._serializers.unshift(s);
+ });
}
-}
-GraphSONReader.prototype.read = function (obj) {
- if (obj === undefined) {
- return undefined;
- }
- if (obj === null) {
- return null;
- }
- if (Array.isArray(obj)) {
- return obj.map(function mapEach(item) {
- return this.read(item);
- }, this);
- }
- var type = obj[typeKey];
- if (type) {
- var d = this._deserializers[type];
- if (d) {
- // Use type serializer
- return d.deserialize(obj);
+ adaptObject(value) {
+ let s;
+ if (Array.isArray(value)) {
+ return value.map(item => this.adaptObject(item));
}
- return obj[valueKey];
- }
- if (obj && typeof obj === 'object' && obj.constructor === Object) {
- return this._deserializeObject(obj);
+ for (let i = 0; i < this._serializers.length; i++) {
+ const currentSerializer = this._serializers[i];
+ if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) {
+ s = currentSerializer;
+ break;
+ }
+ }
+ if (s) {
+ return s.serialize(value);
+ }
+ // Default (strings / objects / ...)
+ return value;
}
- // Default (for boolean, number and other scalars)
- return obj;
-};
-GraphSONReader.prototype._deserializeObject = function (obj) {
- var keys = Object.keys(obj);
- var result = {};
- for (var i = 0; i < keys.length; i++) {
- result[keys[i]] = this.read(obj[keys[i]]);
+ /**
+ * Returns the GraphSON representation of the provided object instance.
+ * @param {Object} obj
+ * @returns {String}
+ */
+ write(obj) {
+ return JSON.stringify(this.adaptObject(obj));
}
- return result;
-};
-
-function NumberSerializer() {
-
-}
-
-NumberSerializer.prototype.serialize = function (item) {
- return item;
-};
-
-NumberSerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return parseFloat(value);
-};
-
-NumberSerializer.prototype.canBeUsedFor = function (value) {
- return (typeof value === 'number');
-};
-
-function LongSerializer() {
-
-}
-
-NumberSerializer.prototype.serialize = function (item) {
- return {
- [typeKey]: 'g:Int64',
- [valueKey]: item.value
- };
-};
-
-NumberSerializer.prototype.canBeUsedFor = function (value) {
- return (value instanceof utils.Long);
-};
-
-function BytecodeSerializer() {
-
}
-BytecodeSerializer.prototype.serialize = function (item) {
- var bytecode = item;
- if (item instanceof t.Traversal) {
- bytecode = item.getBytecode();
- }
- var result = {};
- result[typeKey] = 'g:Bytecode';
- var resultValue = result[valueKey] = {};
- var sources = this._serializeInstructions(bytecode.sourceInstructions);
- if (sources) {
- resultValue['source'] = sources;
- }
- var steps = this._serializeInstructions(bytecode.stepInstructions);
- if (steps) {
- resultValue['step'] = steps;
+class GraphSONReader {
+ /**
+ * GraphSON Reader
+ * @param {Object} [options]
+ * @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and
+ * deserializer instances as values, ie: { 'g:Int64': longSerializer }.
+ * @constructor
+ */
+ constructor(options) {
+ this._options = options || {};
+ this._deserializers = {};
+ Object.keys(deserializers).forEach(typeName => {
+ const serializerConstructor = deserializers[typeName];
+ const s = new serializerConstructor();
+ s.reader = this;
+ this._deserializers[typeName] = s;
+ });
+ if (this._options.serializers) {
+ const customSerializers = this._options.serializers || {};
+ Object.keys(customSerializers).forEach(key => {
+ const s = customSerializers[key];
+ if (!s.deserialize) {
+ return;
+ }
+ s.reader = this;
+ this._deserializers[key] = s;
+ });
+ }
}
- return result;
-};
-BytecodeSerializer.prototype._serializeInstructions = function (instructions) {
- if (instructions.length === 0) {
- return null;
- }
- var result = new Array(instructions.length);
- result[0] = instructions[0];
- for (var i = 0; i < instructions.length; i++) {
- result[i] = this.writer.adaptObject(instructions[i]);
+ read(obj) {
+ if (obj === undefined) {
+ return undefined;
+ }
+ if (obj === null) {
+ return null;
+ }
+ if (Array.isArray(obj)) {
+ return obj.map(item => this.read(item));
+ }
+ const type = obj[typeSerializers.typeKey];
+ if (type) {
+ const d = this._deserializers[type];
+ if (d) {
+ // Use type serializer
+ return d.deserialize(obj);
+ }
+ return obj[typeSerializers.valueKey];
+ }
+ if (obj && typeof obj === 'object' && obj.constructor === Object) {
+ return this._deserializeObject(obj);
+ }
+ // Default (for boolean, number and other scalars)
+ return obj;
}
- return result;
-};
-
-BytecodeSerializer.prototype.canBeUsedFor = function (value) {
- return (value instanceof Bytecode) || (value instanceof t.Traversal);
-};
-
-function PSerializer() {
-}
-
-/** @param {P} item */
-PSerializer.prototype.serialize = function (item) {
- var result = {};
- result[typeKey] = 'g:P';
- var resultValue = result[valueKey] = {
- 'predicate': item.operator
- };
- if (item.other === undefined || item.other === null) {
- resultValue['value'] = this.writer.adaptObject(item.value);
- }
- else {
- resultValue['value'] = [ this.writer.adaptObject(item.value), this.writer.adaptObject(item.other) ];
+ _deserializeObject(obj) {
+ const keys = Object.keys(obj);
+ const result = {};
+ for (let i = 0; i < keys.length; i++) {
+ result[keys[i]] = this.read(obj[keys[i]]);
+ }
+ return result;
}
- return result;
-};
-
-PSerializer.prototype.canBeUsedFor = function (value) {
- return (value instanceof t.P);
-};
-
-function LambdaSerializer() {
-
-}
-
-/** @param {Function} item */
-LambdaSerializer.prototype.serialize = function (item) {
- var result = {};
- result[typeKey] = 'g:Lambda';
- result[valueKey] = {
- 'arguments': item.length,
- 'language': 'gremlin-javascript',
- 'script': item.toString()
- };
- return result;
-};
-
-LambdaSerializer.prototype.canBeUsedFor = function (value) {
- return (typeof value === 'function');
-};
-
-function EnumSerializer() {
-
}
-/** @param {EnumValue} item */
-EnumSerializer.prototype.serialize = function (item) {
- var result = {};
- result[typeKey] = 'g:' + item.typeName;
- result[valueKey] = item.elementName;
- return result;
-};
-
-EnumSerializer.prototype.canBeUsedFor = function (value) {
- return value && value.typeName && value instanceof t.EnumValue;
-};
-
-function TraverserSerializer() {
-
-}
-
-/** @param {Traverser} item */
-TraverserSerializer.prototype.serialize = function (item) {
- var result = {};
- result[typeKey] = 'g:Traverser';
- result[valueKey] = {
- 'value': this.writer.adaptObject(item.object),
- 'bulk': this.writer.adaptObject(item.bulk)
- };
- return result;
-};
-
-TraverserSerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return new t.Traverser(this.reader.read(value['value']), this.reader.read(value['bulk']));
-};
-
-TraverserSerializer.prototype.canBeUsedFor = function (value) {
- return (value instanceof t.Traverser);
-};
-
-function VertexSerializer() {
-
-}
-
-VertexSerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
-};
-
-/** @param {Vertex} item */
-VertexSerializer.prototype.serialize = function (item) {
- var result = {};
- result[typeKey] = 'g:Vertex';
- result[valueKey] = {
- 'id': this.writer.adaptObject(item.id),
- 'label': item.label
- };
- return result;
-};
-
-VertexSerializer.prototype.canBeUsedFor = function (value) {
- return (value instanceof g.Vertex);
-};
-
-function VertexPropertySerializer() {
-
-}
-
-VertexPropertySerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return new g.VertexProperty(
- this.reader.read(value['id']),
- value['label'],
- this.reader.read(value['value']),
- this.reader.read(value['properties'])
- );
-};
-
-function PropertySerializer() {
-
-}
-
-PropertySerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return new g.Property(
- value['key'],
- this.reader.read(value['value']));
-};
-
-function EdgeSerializer() {
-
-}
-
-EdgeSerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return new g.Edge(
- this.reader.read(value['id']),
- this.reader.read(value['outV']),
- value['label'],
- this.reader.read(value['inV']),
- this.reader.read(value['properties'])
- );
-};
-
-/** @param {Edge} item */
-EdgeSerializer.prototype.serialize = function (item) {
- var result = {};
- result[typeKey] = 'g:Edge';
- result[valueKey] = {
- 'id': this.writer.adaptObject(item.id),
- 'label': item.label,
- 'outV': this.writer.adaptObject(item.outV.id),
- 'outVLabel': item.outV.label,
- 'inV': this.writer.adaptObject(item.inV.id),
- 'inVLabel': item.inV.label
- };
- return result;
-};
-
-EdgeSerializer.prototype.canBeUsedFor = function (value) {
- return (value instanceof g.Edge);
-};
-
-function PathSerializer() {
-
-}
-
-PathSerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- var objects = value['objects'].map(function objectMapItem(o) {
- return this.reader.read(o);
- }, this);
- return new g.Path(this.reader.read(value['labels']), objects);
-};
+const deserializers = {
+ 'g:Traverser': typeSerializers.TraverserSerializer,
+ 'g:Int32': typeSerializers.NumberSerializer,
+ 'g:Int64': typeSerializers.NumberSerializer,
+ 'g:Float': typeSerializers.NumberSerializer,
+ 'g:Double': typeSerializers.NumberSerializer,
+ 'g:Vertex': typeSerializers.VertexSerializer,
+ 'g:Edge': typeSerializers.EdgeSerializer,
+ 'g:VertexProperty': typeSerializers.VertexPropertySerializer,
+ 'g:Property': typeSerializers.PropertySerializer,
+ 'g:Path': typeSerializers.PathSerializer
+};
+
+const serializers = [
+ typeSerializers.NumberSerializer,
+ typeSerializers.BytecodeSerializer,
+ typeSerializers.TraverserSerializer,
+ typeSerializers.PSerializer,
+ typeSerializers.LambdaSerializer,
+ typeSerializers.EnumSerializer,
+ typeSerializers.VertexSerializer,
+ typeSerializers.EdgeSerializer,
+ typeSerializers.LongSerializer
+];
module.exports = {
- GraphSONWriter: GraphSONWriter,
- GraphSONReader: GraphSONReader
+ GraphSONWriter,
+ GraphSONReader
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
new file mode 100644
index 0000000..d6f131c
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
@@ -0,0 +1,288 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+const t = require('../../process/traversal');
+const Bytecode = require('../../process/bytecode');
+const g = require('../graph');
+const utils = require('../../utils');
+
+const valueKey = '@value';
+const typeKey = '@type';
+
+/**
+ * @abstract
+ */
+class TypeSerializer {
+ serialize() {
+ throw new Error('serialize() method not implemented for ' + this.constructor.name);
+ }
+
+ deserialize() {
+ throw new Error('deserialize() method not implemented for ' + this.constructor.name);
+ }
+
+ canBeUsedFor() {
+ throw new Error('canBeUsedFor() method not implemented for ' + this.constructor.name);
+ }
+}
+
+class NumberSerializer extends TypeSerializer {
+ serialize(item) {
+ return item;
+ }
+
+ deserialize(obj) {
+ return parseFloat(obj[valueKey]);
+ }
+
+ canBeUsedFor(value) {
+ return (typeof value === 'number');
+ }
+}
+
+class LongSerializer extends TypeSerializer {
+ serialize(item) {
+ return {
+ [typeKey]: 'g:Int64',
+ [valueKey]: item.value
+ };
+ }
+
+ canBeUsedFor(value) {
+ return (value instanceof utils.Long);
+ }
+}
+
+class BytecodeSerializer extends TypeSerializer {
+ serialize(item) {
+ let bytecode = item;
+ if (item instanceof t.Traversal) {
+ bytecode = item.getBytecode();
+ }
+ const result = {};
+ result[typeKey] = 'g:Bytecode';
+ const resultValue = result[valueKey] = {};
+ const sources = this._serializeInstructions(bytecode.sourceInstructions);
+ if (sources) {
+ resultValue['source'] = sources;
+ }
+ const steps = this._serializeInstructions(bytecode.stepInstructions);
+ if (steps) {
+ resultValue['step'] = steps;
+ }
+ return result;
+ }
+
+ _serializeInstructions(instructions) {
+ if (instructions.length === 0) {
+ return null;
+ }
+ const result = new Array(instructions.length);
+ result[0] = instructions[0];
+ for (let i = 0; i < instructions.length; i++) {
+ result[i] = this.writer.adaptObject(instructions[i]);
+ }
+ return result;
+ }
+
+ canBeUsedFor(value) {
+ return (value instanceof Bytecode) || (value instanceof t.Traversal);
+ }
+}
+
+class PSerializer extends TypeSerializer {
+ /** @param {P} item */
+ serialize(item) {
+ const result = {};
+ result[typeKey] = 'g:P';
+ const resultValue = result[valueKey] = {
+ 'predicate': item.operator
+ };
+ if (item.other === undefined || item.other === null) {
+ resultValue['value'] = this.writer.adaptObject(item.value);
+ }
+ else {
+ resultValue['value'] = [ this.writer.adaptObject(item.value), this.writer.adaptObject(item.other) ];
+ }
+ return result;
+ }
+
+ canBeUsedFor(value) {
+ return (value instanceof t.P);
+ }
+}
+
+class LambdaSerializer extends TypeSerializer {
+ /** @param {Function} item */
+ serialize(item) {
+ return {
+ [typeKey]: 'g:Lambda',
+ [valueKey]: {
+ 'arguments': item.length,
+ 'language': 'gremlin-javascript',
+ 'script': item.toString()
+ }
+ };
+ }
+
+ canBeUsedFor(value) {
+ return (typeof value === 'function');
+ }
+}
+
+class EnumSerializer extends TypeSerializer {
+ /** @param {EnumValue} item */
+ serialize(item) {
+ return {
+ [typeKey]: 'g:' + item.typeName,
+ [valueKey]: item.elementName
+ };
+ }
+
+ canBeUsedFor(value) {
+ return value && value.typeName && value instanceof t.EnumValue;
+ }
+}
+
+class TraverserSerializer extends TypeSerializer {
+ /** @param {Traverser} item */
+ serialize(item) {
+ return {
+ [typeKey]: 'g:Traverser',
+ [valueKey]: {
+ 'value': this.writer.adaptObject(item.object),
+ 'bulk': this.writer.adaptObject(item.bulk)
+ }
+ };
+ }
+
+ deserialize(obj) {
+ const value = obj[valueKey];
+ return new t.Traverser(this.reader.read(value['value']), this.reader.read(value['bulk']));
+ }
+
+ canBeUsedFor(value) {
+ return (value instanceof t.Traverser);
+ }
+}
+
+class VertexSerializer extends TypeSerializer {
+ deserialize(obj) {
+ const value = obj[valueKey];
+ return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
+ }
+
+ /** @param {Vertex} item */
+ serialize(item) {
+ return {
+ [typeKey]: 'g:Vertex',
+ [valueKey]: {
+ 'id': this.writer.adaptObject(item.id),
+ 'label': item.label
+ }
+ };
+ }
+
+ canBeUsedFor(value) {
+ return (value instanceof g.Vertex);
+ }
+}
+
+class VertexPropertySerializer extends TypeSerializer {
+ deserialize(obj) {
+ const value = obj[valueKey];
+ return new g.VertexProperty(
+ this.reader.read(value['id']),
+ value['label'],
+ this.reader.read(value['value']),
+ this.reader.read(value['properties'])
+ );
+ }
+}
+
+class PropertySerializer extends TypeSerializer {
+ deserialize(obj) {
+ const value = obj[valueKey];
+ return new g.Property(
+ value['key'],
+ this.reader.read(value['value']));
+ }
+}
+
+class EdgeSerializer extends TypeSerializer {
+ deserialize(obj) {
+ const value = obj[valueKey];
+ return new g.Edge(
+ this.reader.read(value['id']),
+ this.reader.read(value['outV']),
+ value['label'],
+ this.reader.read(value['inV']),
+ this.reader.read(value['properties'])
+ );
+ }
+
+ /** @param {Edge} item */
+ serialize(item) {
+ return {
+ [typeKey]: 'g:Edge',
+ [valueKey]: {
+ 'id': this.writer.adaptObject(item.id),
+ 'label': item.label,
+ 'outV': this.writer.adaptObject(item.outV.id),
+ 'outVLabel': item.outV.label,
+ 'inV': this.writer.adaptObject(item.inV.id),
+ 'inVLabel': item.inV.label
+ }
+ };
+ }
+
+ canBeUsedFor(value) {
+ return (value instanceof g.Edge);
+ }
+}
+
+class PathSerializer extends TypeSerializer {
+ deserialize(obj) {
+ const value = obj[valueKey];
+ const objects = value['objects'].map(o => this.reader.read(o));
+ return new g.Path(this.reader.read(value['labels']), objects);
+ }
+}
+
+module.exports = {
+ BytecodeSerializer,
+ EdgeSerializer,
+ EnumSerializer,
+ LambdaSerializer,
+ LongSerializer,
+ NumberSerializer,
+ PathSerializer,
+ PropertySerializer,
+ PSerializer,
+ TraverserSerializer,
+ typeKey,
+ valueKey,
+ VertexPropertySerializer,
+ VertexSerializer
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
index cbaa53e..bf87368 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
@@ -22,9 +22,6 @@
* @author Jorge Bay Gondra
*/
'use strict';
-var util = require('util');
-
-exports.inherits = util.inherits;
exports.parseArgs = function parseArgs() {
return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
@@ -56,7 +53,7 @@ exports.resolvedPromise = function (promiseFactory) {
});
};
-var toPromise = exports.toPromise = function toPromise(promiseFactory, handler) {
+const toPromise = exports.toPromise = function toPromise(promiseFactory, handler) {
promiseFactory = promiseFactory || defaultPromiseFactory;
return promiseFactory(handler);
};
@@ -65,7 +62,7 @@ exports.toLong = function toLong(value) {
return new Long(value);
};
-var Long = exports.Long = function Long(value) {
+const Long = exports.Long = function Long(value) {
if (typeof value !== 'string' && typeof value !== 'number') {
throw new TypeError('Ty')
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
index e4895fe..9e115be 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
@@ -27,7 +27,7 @@ const Bytecode = require('../../lib/process/bytecode');
const graphModule = require('../../lib/structure/graph');
const helper = require('../helper');
-var connection;
+let connection;
describe('DriverRemoteConnection', function () {
before(function () {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
index 7109427..01dde62 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
@@ -29,7 +29,7 @@ const Vertex = graphModule.Vertex;
const utils = require('../../lib/utils');
const helper = require('../helper');
-var connection;
+let connection;
describe('Traversal', function () {
before(function () {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
index 3864a4a..53b6577 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
@@ -22,8 +22,8 @@
*/
'use strict';
-var assert = require('assert');
-var glvModule = require('../../');
+const assert = require('assert');
+const glvModule = require('../../');
describe('API', function () {
it('should export fields under process', function () {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
index ed5beb3..8bc7571 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
@@ -22,23 +22,23 @@
*/
'use strict';
-var assert = require('assert');
-var graph = require('../../lib/structure/graph');
-var t = require('../../lib/process/traversal.js');
-var gs = require('../../lib/structure/io/graph-serializer.js');
-var GraphSONReader = gs.GraphSONReader;
-var GraphSONWriter = gs.GraphSONWriter;
-var P = t.P;
+const assert = require('assert');
+const graph = require('../../lib/structure/graph');
+const t = require('../../lib/process/traversal.js');
+const gs = require('../../lib/structure/io/graph-serializer.js');
+const GraphSONReader = gs.GraphSONReader;
+const GraphSONWriter = gs.GraphSONWriter;
+const P = t.P;
describe('GraphSONReader', function () {
it('should parse GraphSON int32, float and double to Number from GraphSON', function () {
- var reader = new GraphSONReader();
+ const reader = new GraphSONReader();
[
[ 'g:Int32', 31 ],
[ 'g:Float', 31.3],
[ 'g:Double', 31.2]
].forEach(function (item) {
- var result = reader.read({
+ const result = reader.read({
"@type": item[0],
"@value": item[1]
});
@@ -47,12 +47,12 @@ describe('GraphSONReader', function () {
});
});
it('should parse vertices from GraphSON', function () {
- var obj = {
+ const obj = {
"@type":"g:Vertex", "@value":{"id":{"@type":"g:Int32","@value":1},"label":"person",
"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"marko"}],
"age":[{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29}}]}}};
- var reader = new GraphSONReader(obj);
- var result = reader.read(obj);
+ const reader = new GraphSONReader(obj);
+ const result = reader.read(obj);
assert.ok(result instanceof graph.Vertex);
assert.strictEqual(result.label, 'person');
assert.strictEqual(typeof result.id, 'number');
@@ -65,7 +65,7 @@ describe('GraphSONReader', function () {
assert.strictEqual(result.properties['age'][0].value, 29);
});
it('should parse paths from GraphSON', function () {
- var obj = {"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[
+ const obj = {"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[
{
"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person",
"properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},
@@ -79,8 +79,8 @@ describe('GraphSONReader', function () {
"lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},
"value":"java","label":"lang"}}]}}},
"lop"]}};
- var reader = new GraphSONReader(obj);
- var result = reader.read(obj);
+ const reader = new GraphSONReader(obj);
+ const result = reader.read(obj);
assert.ok(result);
assert.ok(result.objects);
assert.ok(result.labels);
@@ -93,17 +93,17 @@ describe('GraphSONReader', function () {
});
describe('GraphSONWriter', function () {
it('should write numbers', function () {
- var writer = new GraphSONWriter();
+ const writer = new GraphSONWriter();
assert.strictEqual(writer.write(2), '2');
});
it('should write boolean values', function () {
- var writer = new GraphSONWriter();
+ const writer = new GraphSONWriter();
assert.strictEqual(writer.write(true), 'true');
assert.strictEqual(writer.write(false), 'false');
});
it('should write P', function () {
- var writer = new GraphSONWriter();
- var expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[
+ const writer = new GraphSONWriter();
+ const expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[
{"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},
{"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},
{"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}});
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
index 2be504b..9310143 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
@@ -33,8 +33,8 @@ describe('Traversal', function () {
describe('#getByteCode()', function () {
it('should add steps for with a string parameter', function () {
- var g = new graph.Graph().traversal();
- var bytecode = g.V().out('created').getBytecode();
+ const g = new graph.Graph().traversal();
+ const bytecode = g.V().out('created').getBytecode();
assert.ok(bytecode);
assert.strictEqual(bytecode.sourceInstructions.length, 0);
assert.strictEqual(bytecode.stepInstructions.length, 2);
@@ -44,8 +44,8 @@ describe('Traversal', function () {
});
it('should add steps with an enum value', function () {
- var g = new graph.Graph().traversal();
- var bytecode = g.V().order().by('age', t.order.decr).getBytecode();
+ const g = new graph.Graph().traversal();
+ const bytecode = g.V().order().by('age', t.order.decr).getBytecode();
assert.ok(bytecode);
assert.strictEqual(bytecode.sourceInstructions.length, 0);
assert.strictEqual(bytecode.stepInstructions.length, 3);
@@ -61,15 +61,15 @@ describe('Traversal', function () {
describe('#next()', function () {
it('should apply the strategies and return a Promise with the iterator item', function () {
- var strategyMock = {
+ const strategyMock = {
apply: function (traversal) {
traversal.traversers = [ new t.Traverser(1, 1), new t.Traverser(2, 1) ];
return utils.resolvedPromise();
}
};
- var strategies = new TraversalStrategies();
+ const strategies = new TraversalStrategies();
strategies.addStrategy(strategyMock);
- var traversal = new t.Traversal(null, strategies, null);
+ const traversal = new t.Traversal(null, strategies, null);
return traversal.next()
.then(function (item) {
assert.strictEqual(item.value, 1);
@@ -125,15 +125,15 @@ describe('Traversal', function () {
describe('#toList()', function () {
it('should apply the strategies and return a Promise with an array', function () {
- var strategyMock = {
+ const strategyMock = {
apply: function (traversal) {
traversal.traversers = [ new t.Traverser('a', 1), new t.Traverser('b', 1) ];
return utils.resolvedPromise();
}
};
- var strategies = new TraversalStrategies();
+ const strategies = new TraversalStrategies();
strategies.addStrategy(strategyMock);
- var traversal = new t.Traversal(null, strategies, null);
+ const traversal = new t.Traversal(null, strategies, null);
return traversal.toList().then(function (list) {
assert.ok(list);
assert.deepEqual(list, [ 'a', 'b' ]);
@@ -141,15 +141,15 @@ describe('Traversal', function () {
});
it('should return an empty array when traversers is empty', function () {
- var strategyMock = {
+ const strategyMock = {
apply: function (traversal) {
traversal.traversers = [];
return utils.resolvedPromise();
}
};
- var strategies = new TraversalStrategies();
+ const strategies = new TraversalStrategies();
strategies.addStrategy(strategyMock);
- var traversal = new t.Traversal(null, strategies, null);
+ const traversal = new t.Traversal(null, strategies, null);
return traversal.toList().then(function (list) {
assert.ok(Array.isArray(list));
assert.strictEqual(list.length, 0);
[45/47] tinkerpop git commit: Merge branch 'TINKERPOP-1489' into tp32
Posted by jo...@apache.org.
Merge branch 'TINKERPOP-1489' into tp32
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/0bcab7ff
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/0bcab7ff
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/0bcab7ff
Branch: refs/heads/master
Commit: 0bcab7ff3a3c35109c6b6d04d55d8110a6b80925
Parents: 389394c 328c936
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Jan 25 11:33:11 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Thu Jan 25 11:33:11 2018 +0100
----------------------------------------------------------------------
.travis.install-maven.sh | 19 +
.travis.yml | 14 +-
docker/build/Dockerfile.template | 4 +
.../developer/development-environment.asciidoc | 15 +
docs/src/reference/gremlin-variants.asciidoc | 75 +-
.../glv/GraphTraversalSource.template | 126 ++
gremlin-javascript/glv/PackageJson.template | 59 +
gremlin-javascript/glv/TraversalSource.template | 201 +++
gremlin-javascript/glv/generate.groovy | 107 ++
gremlin-javascript/pom.xml | 301 +++++
.../javascript/gremlin-javascript/.gitignore | 5 +
.../javascript/gremlin-javascript/.npmignore | 26 +
.../javascript/gremlin-javascript/README.md | 39 +
.../main/javascript/gremlin-javascript/index.js | 75 ++
.../lib/driver/driver-remote-connection.js | 194 +++
.../lib/driver/remote-connection.js | 77 ++
.../gremlin-javascript/lib/process/bytecode.js | 98 ++
.../lib/process/graph-traversal.js | 1264 ++++++++++++++++++
.../lib/process/traversal-strategy.js | 75 ++
.../gremlin-javascript/lib/process/traversal.js | 268 ++++
.../gremlin-javascript/lib/structure/graph.js | 168 +++
.../lib/structure/io/graph-serializer.js | 181 +++
.../lib/structure/io/type-serializers.js | 295 ++++
.../javascript/gremlin-javascript/lib/utils.js | 35 +
.../javascript/gremlin-javascript/package.json | 40 +
.../test/cucumber/feature-steps.js | 327 +++++
.../gremlin-javascript/test/cucumber/world.js | 126 ++
.../gremlin-javascript/test/helper.js | 29 +
.../test/integration/remote-connection-tests.js | 58 +
.../test/integration/traversal-test.js | 69 +
.../test/unit/exports-test.js | 73 +
.../test/unit/graphson-test.js | 112 ++
.../test/unit/traversal-test.js | 194 +++
pom.xml | 6 +
34 files changed, 4751 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0bcab7ff/docs/src/dev/developer/development-environment.asciidoc
----------------------------------------------------------------------
[33/47] tinkerpop git commit: Adjust pom.xml to be forward compatible
Posted by jo...@apache.org.
Adjust pom.xml to be forward compatible
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/843a727d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/843a727d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/843a727d
Branch: refs/heads/master
Commit: 843a727d255f33720df029a89ad701e3f18eae25
Parents: d458f76
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Nov 30 16:05:10 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:17 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/pom.xml | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/843a727d/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 830052b..aa219ab 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -150,7 +150,8 @@ def binding = ["enums": CoreImports.getClassImports()
findAll { GraphTraversalSource.class.equals(it.returnType) }.
findAll {
!it.name.equals("clone") &&
- !it.name.equals(TraversalSource.Symbols.withBindings) &&
+ // Use hardcoded name to be for forward-compatibility
+ !it.name.equals("withBindings") &&
!it.name.equals(TraversalSource.Symbols.withRemote) &&
!it.name.equals(TraversalSource.Symbols.withComputer)
}.
@@ -223,6 +224,10 @@ packageJsonFile.newWriter().withWriter{ it << packageJsonTemplate }
<name>executionName</name>
<value>${project.name}</value>
</property>
+ <property>
+ <name>projectBaseDir</name>
+ <value>${project.basedir}</value>
+ </property>
</properties>
<scripts>
<script>${gremlin.server.dir}/src/test/scripts/test-server-start.groovy</script>
[22/47] tinkerpop git commit: Setup world and basic steps
Posted by jo...@apache.org.
Setup world and basic steps
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e73038cd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e73038cd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e73038cd
Branch: refs/heads/master
Commit: e73038cd0a353b92c2c5f78b7133951eff0cd1a4
Parents: 9bf6500
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Nov 23 15:06:17 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:15 2018 +0100
----------------------------------------------------------------------
.../lib/driver/driver-remote-connection.js | 4 +-
.../test/cucumber/feature-steps.js | 59 +++++++++++++++---
.../gremlin-javascript/test/cucumber/world.js | 64 +++++++++++++++++++-
.../test/integration/traversal-test.js | 6 +-
4 files changed, 119 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e73038cd/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index 18c551c..31f27cd 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -72,11 +72,11 @@ function DriverRemoteConnection(url, options) {
this._responseHandlers = {};
this._reader = options.reader || new serializer.GraphSONReader();
this._writer = options.writer || new serializer.GraphSONWriter();
- this._traversalSource = options.traversalSource || 'g';
this._openPromise = null;
this._openCallback = null;
this._closePromise = null;
this.isOpen = false;
+ this.traversalSource = options.traversalSource || 'g';
}
inherits(DriverRemoteConnection, RemoteConnection);
@@ -127,7 +127,7 @@ DriverRemoteConnection.prototype._getRequest = function (id, bytecode) {
'processor': 'traversal',
'args': {
'gremlin': this._writer.adaptObject(bytecode),
- 'aliases': { 'g': this._traversalSource }
+ 'aliases': { 'g': this.traversalSource }
}
});
};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e73038cd/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index bea7321..5270b39 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -23,13 +23,24 @@
'use strict';
const defineSupportCode = require('cucumber').defineSupportCode;
+const assert = require('assert');
const vm = require('vm');
-
+const graphModule = require('../../lib/structure/graph');
+const graphTraversalModule = require('../../lib/process/graph-traversal');
+const traversalModule = require('../../lib/process/traversal');
+const Graph = graphModule.Graph;
+const __ = graphTraversalModule.statics;
defineSupportCode(function(methods) {
methods.Given(/^the (.+) graph$/, function (graphName) {
- //TODO: Set context g
+ if (graphName === 'empty') {
+ //TODO
+ }
+ const data = this.getDataByGraphName(graphName);
+ this.graphName = graphName;
+ this.g = new Graph().traversal().withRemote(data.connection)
});
+
methods.Given('the graph initializer of', function () {
//TODO
});
@@ -37,7 +48,7 @@ defineSupportCode(function(methods) {
methods.Given('an unsupported test', () => {});
methods.Given('the traversal of', function (traversalText) {
- //TODO: make traversal
+ this.traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g));
});
methods.Given(/^$/, function (paramName, stringValue) {
@@ -45,16 +56,24 @@ defineSupportCode(function(methods) {
});
methods.When('iterated to list', function () {
- //TODO
+ return this.traversal.toList().then(list => this.result = list);
});
methods.When('iterated next', function () {
- //TODO
+ return this.traversal.next().then(it => this.result = it.value);
});
methods.Then(/^the result should be (\w+)$/, function (characterizedAs, resultTable) {
+ switch (characterizedAs) {
+ case 'empty':
+ assert.strictEqual(0, result.length);
+ break;
+ case 'ordered':
+ const expectedResult = resultTable.rows().map(parseRow);
+ console.log('--- ordered', expectedResult);
+ break;
+ }
//TODO
- //console.log('--resultTable', resultTable.rows());
if (typeof resultTable === 'function'){
return resultTable();
}
@@ -69,4 +88,30 @@ defineSupportCode(function(methods) {
});
methods.Then('nothing should happen because', () => {});
-});
\ No newline at end of file
+});
+
+function getSandbox(g) {
+ return {
+ g: g,
+ __: __,
+ Cardinality: traversalModule.cardinality,
+ Column: traversalModule.column,
+ Direction: traversalModule.direction,
+ Order: traversalModule.order,
+ P: traversalModule.P,
+ Pick: traversalModule.pick,
+ Scope: traversalModule.scope,
+ Operator: traversalModule.operator,
+ T: traversalModule.t,
+ };
+}
+
+function translate(traversalText) {
+ traversalText = traversalText.replace('.in(', '.in_(');
+ traversalText = traversalText.replace('.from(', '.from_(');
+ return traversalText;
+}
+
+function parseRow(row) {
+ return row[0];
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e73038cd/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
index 2e4f6e1..8f72c58 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -23,17 +23,77 @@
'use strict';
const defineSupportCode = require('cucumber').defineSupportCode;
+const helper = require('../helper');
+const graphModule = require('../../lib/structure/graph');
+const graphTraversalModule = require('../../lib/process/graph-traversal');
+const Graph = graphModule.Graph;
+const __ = graphTraversalModule.statics;
defineSupportCode(function (methods) {
+ const cache = {};
+
function TinkerPopWorld(){
this.g = null;
this.traversal = null;
+ this.result = null;
+ this.cache = null;
}
+
+ TinkerPopWorld.prototype.getDataByGraphName = function (name) {
+ return this.cache[name];
+ };
+
methods.setWorldConstructor(TinkerPopWorld);
+
methods.BeforeAll(function () {
// load all traversals
+ const promises = ['modern', 'classic', 'crew', 'grateful'].map(graphName => {
+ const connection = helper.getConnection('g' + graphName);
+ return connection.open()
+ .then(() => Promise.all([getVertices(connection), getEdges(connection)]))
+ .then(values => {
+ cache[graphName] = {
+ connection: connection,
+ vertices: values[0],
+ edges: values[1]
+ };
+ });
+ });
+ return Promise.all(promises);
});
- methods.Before(function () {
+ methods.AfterAll(function () {
+ return Promise.all(Object.keys(cache).map(graphName => cache[graphName].connection.close()));
});
-});
\ No newline at end of file
+
+ methods.Before(function () {
+ this.cache = cache;
+ });
+});
+
+function getVertices(connection) {
+ const g = new Graph().traversal().withRemote(connection);
+ return g.V().group().by('name').by(__.tail()).next().then(it => it.value);
+}
+
+function getEdges(connection) {
+ const g = new Graph().traversal().withRemote(connection);
+ return g.E().group()
+ .by(__.project("o", "l", "i").by(__.outV().values("name")).by(__.inV().values("name")))
+ .by(__.tail())
+ .next()
+ .then(it => {
+ const edges = {};
+ Object.keys(it.value).map(key => {
+ edges[getEdgeKey(key)] = it.value[key];
+ });
+ return edges;
+ });
+}
+
+function getEdgeKey(key) {
+ const o = /o=(.+?)[,}]/.exec(key)[1];
+ const l = /l=(.+?)[,}]/.exec(key)[1];
+ const i = /i=(.+?)[,}]/.exec(key)[1];
+ return o + "-" + l + "->" + i;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e73038cd/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
index 96de7c7..adb7d6c 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
@@ -42,10 +42,10 @@ describe('Traversal', function () {
describe('#toList()', function () {
it('should submit the traversal and return a list', function () {
var g = new Graph().traversal().withRemote(connection);
- return g.addV('user').toList().then(function (list) {
+ return g.V().toList().then(function (list) {
assert.ok(list);
- assert.strictEqual(list.length, 1);
- assert.ok(list[0] instanceof Vertex);
+ assert.strictEqual(list.length, 7);
+ list.forEach(v => assert.ok(v instanceof Vertex));
});
});
});
[17/47] tinkerpop git commit: Js GLV: Use Groovy templates for
generation
Posted by jo...@apache.org.
Js GLV: Use Groovy templates for generation
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/98dc52c3
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/98dc52c3
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/98dc52c3
Branch: refs/heads/master
Commit: 98dc52c3f2cdcb0e57493e3710adf675d03a925d
Parents: f5c9049
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Aug 17 17:28:32 2017 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:15 2018 +0100
----------------------------------------------------------------------
.../glv/GraphTraversalSource.template | 127 ++++++++++
gremlin-javascript/glv/PackageJson.template | 55 +++++
gremlin-javascript/glv/TraversalSource.template | 171 +++++++++++++
gremlin-javascript/pom.xml | 131 ++++++++--
.../javascript/GenerateGremlinJavascript.groovy | 36 ---
.../GraphTraversalSourceGenerator.groovy | 231 ------------------
.../javascript/PackageJsonGenerator.groovy | 72 ------
.../gremlin/javascript/SymbolHelper.groovy | 50 ----
.../javascript/TraversalSourceGenerator.groovy | 237 -------------------
.../lib/process/graph-traversal.js | 42 +---
.../gremlin-javascript/lib/process/traversal.js | 6 +-
.../javascript/gremlin-javascript/package.json | 2 +-
12 files changed, 475 insertions(+), 685 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/glv/GraphTraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/GraphTraversalSource.template b/gremlin-javascript/glv/GraphTraversalSource.template
new file mode 100644
index 0000000..e0fb453
--- /dev/null
+++ b/gremlin-javascript/glv/GraphTraversalSource.template
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var t = require('./traversal.js');
+var remote = require('../driver/remote-connection');
+var utils = require('../utils');
+var Bytecode = require('./bytecode');
+var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
+var inherits = utils.inherits;
+var parseArgs = utils.parseArgs;
+
+/**
+ *
+ * @param {Graph} graph
+ * @param {TraversalStrategies} traversalStrategies
+ * @param {Bytecode} [bytecode]
+ * @constructor
+ */
+function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode || new Bytecode();
+}
+
+/**
+ * @param remoteConnection
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+ var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
+ traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+ return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
+};
+
+/**
+ * Returns the string representation of the GraphTraversalSource.
+ * @returns {string}
+ */
+GraphTraversalSource.prototype.toString = function () {
+ return 'graphtraversalsource[' + this.graph.toString() + ']';
+};
+<% sourceStepMethods.each{ method -> %>
+/**
+ * Graph Traversal Source <%= method %> method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.<%= toJs.call(method) %> = function (args) {
+ var b = new Bytecode(this.bytecode).addSource('<%= method %>', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+<%
+}
+sourceSpawnMethods.each{ method -> %>
+/**
+ * <%= method %> GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.<%= toJs.call(method) %> = function (args) {
+ var b = new Bytecode(this.bytecode).addStep('<%= method %>', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+<% } %>
+/**
+ * Represents a graph traversal.
+ * @extends Traversal
+ * @constructor
+ */
+function GraphTraversal(graph, traversalStrategies, bytecode) {
+ t.Traversal.call(this, graph, traversalStrategies, bytecode);
+}
+
+inherits(GraphTraversal, t.Traversal);
+<% graphStepMethods.each{ method -> %>
+/**
+ * Graph traversal <%= method %> method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.<%= toJs.call(method) %> = function (args) {
+ this.bytecode.addStep('<%= method %>', parseArgs.apply(null, arguments));
+ return this;
+};
+<% } %>
+/**
+ * Contains the static method definitions
+ * @type {Object}
+ */
+var statics = {};
+<% anonStepMethods.each{ method -> %>
+/**
+ * <%= method %>() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.<%= toJs.call(method) %> = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.<%= toJs.call(method) %>.apply(g, arguments);
+};
+<% } %>
+module.exports = {
+ GraphTraversal: GraphTraversal,
+ GraphTraversalSource: GraphTraversalSource,
+ statics: statics
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/glv/PackageJson.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template
new file mode 100644
index 0000000..f61913f
--- /dev/null
+++ b/gremlin-javascript/glv/PackageJson.template
@@ -0,0 +1,55 @@
+<%
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+%>{
+ "name": "gremlin-javascript",
+ "version": "<%= version %>",
+ "description": "JavaScript Gremlin Language Variant",
+ "author": "Apache TinkerPop team",
+ "keywords": [
+ "graph",
+ "gremlin",
+ "tinkerpop",
+ "connection",
+ "glv",
+ "driver",
+ "graphdb"
+ ],
+ "license": "Apache-2.0",
+ "dependencies": {
+ "ws": "^3.0.0"
+ },
+ "devDependencies": {
+ "mocha": ">= 1.14.0"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/apache/tinkerpop.git"
+ },
+ "bugs": {
+ "url": "https://issues.apache.org/jira/browse/TINKERPOP"
+ },
+ "scripts": {
+ "test": "./node_modules/.bin/mocha test --recursive -t 5000",
+ "unit-test": "./node_modules/.bin/mocha test/unit"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
new file mode 100644
index 0000000..dbb7bc4
--- /dev/null
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var utils = require('../utils');
+var parseArgs = utils.parseArgs;
+var itemDone = Object.freeze({ value: null, done: true });
+var emptyArray = Object.freeze([]);
+
+function Traversal(graph, traversalStrategies, bytecode) {
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode;
+ this.traversers = null;
+ this.sideEffects = null;
+ this._traversalStrategiesPromise = null;
+ this._traversersIteratorIndex = 0;
+}
+
+/** @returns {Bytecode} */
+Traversal.prototype.getBytecode = function () {
+ return this.bytecode;
+};
+
+/**
+ * Returns an Array containing the traverser objects.
+ * @returns {Promise.<Array>}
+ */
+Traversal.prototype.toList = function () {
+ var self = this;
+ return this._applyStrategies().then(function () {
+ if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+ return emptyArray;
+ }
+ var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
+ for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
+ arr[i] = self.traversers[i].object;
+ }
+ self._traversersIteratorIndex = self.traversers.length;
+ return arr;
+ });
+};
+
+/**
+ * Async iterator method implementation.
+ * Returns a promise containing an iterator item.
+ * @returns {Promise.<{value, done}>}
+ */
+Traversal.prototype.next = function () {
+ var self = this;
+ return this._applyStrategies().then(function () {
+ if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+ return itemDone;
+ }
+ return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
+ });
+};
+
+Traversal.prototype._applyStrategies = function () {
+ if (this._traversalStrategiesPromise) {
+ // Apply strategies only once
+ return this._traversalStrategiesPromise;
+ }
+ return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
+};
+
+/**
+ * Returns the Bytecode JSON representation of the traversal
+ * @returns {String}
+ */
+Traversal.prototype.toString = function () {
+ return this.bytecode.toString();
+};
+
+/**
+ * Represents an operation.
+ * @constructor
+ */
+function P(operator, value, other) {
+ this.operator = operator;
+ this.value = value;
+ this.other = other;
+}
+
+/**
+ * Returns the string representation of the instance.
+ * @returns {string}
+ */
+P.prototype.toString = function () {
+ if (this.other === undefined) {
+ return this.operator + '(' + this.value + ')';
+ }
+ return this.operator + '(' + this.value + ', ' + this.other + ')';
+};
+
+function createP(operator, args) {
+ args.unshift(null, operator);
+ return new (Function.prototype.bind.apply(P, args));
+}
+<% pmethods.each{ method -> %>
+/** @param {...Object} args */
+P.<%= toJs.call(method) %> = function (args) {
+ return createP('<%= method %>', parseArgs.apply(null, arguments));
+};
+<% } %>
+P.prototype.and = function (arg) {
+ return new P('and', this, arg);
+};
+
+P.prototype.or = function (arg) {
+ return new P('or', this, arg);
+};
+
+function Traverser(object, bulk) {
+ this.object = object;
+ this.bulk = bulk == undefined ? 1 : bulk;
+}
+
+function TraversalSideEffects() {
+
+}
+
+function toEnum(typeName, keys) {
+ var result = {};
+ keys.split(' ').forEach(function (k) {
+ var jsKey = k;
+ if (jsKey === jsKey.toUpperCase()) {
+ jsKey = jsKey.toLowerCase();
+ }
+ result[jsKey] = new EnumValue(typeName, k);
+ });
+ return result;
+}
+
+function EnumValue(typeName, elementName) {
+ this.typeName = typeName;
+ this.elementName = elementName;
+}
+
+module.exports = {
+ EnumValue: EnumValue,
+ P: P,
+ Traversal: Traversal,
+ TraversalSideEffects: TraversalSideEffects,
+ Traverser: Traverser<%
+enums.each{ enumClass ->
+ out.print ",\n " + decapitalize.call(enumClass.simpleName) + ": toEnum('" + enumClass.simpleName + "', '" +
+ enumClass.getEnumConstants().sort { a, b -> a.name() <=> b.name() }.collect { toJs.call(it.name()) }.join(' ') + "')"
+}
+%>
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 452e183..203e59e 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -31,12 +31,6 @@ limitations under the License.
<artifactId>gremlin-core</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy</artifactId>
- <version>${groovy.version}</version>
- <classifier>indy</classifier>
- </dependency>
<!-- TESTING -->
<dependency>
<groupId>org.apache.tinkerpop</groupId>
@@ -72,27 +66,18 @@ limitations under the License.
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2.1</version>
- <executions>
- <execution>
- <id>generate-javascript</id>
- <phase>generate-test-resources</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>org.apache.tinkerpop.gremlin.javascript.GenerateGremlinJavascript</mainClass>
- <arguments>
- <argument>${project.version}</argument>
- <argument>${basedir}</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
</plugin>
<plugin>
+ <!--
+ Use gmavenplus-plugin to:
+ - Generate js sources
+ - Start and stop gremlin server for integration tests
+ -->
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<dependencies>
@@ -116,6 +101,102 @@ limitations under the License.
</dependencies>
<executions>
<execution>
+ <id>generate-javascript</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <scripts>
+ <script><![CDATA[
+import org.apache.tinkerpop.gremlin.jsr223.CoreImports
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
+import java.lang.reflect.Modifier
+
+def toJsMap = ["in": "in_",
+ "from": "from_"]
+
+def toJs = { symbol -> toJsMap.getOrDefault(symbol, symbol) }
+
+def decapitalize = {
+ String string = it;
+ if (string == null || string.length() == 0) {
+ return string;
+ }
+ def c = string.toCharArray();
+ c[0] = Character.toLowerCase(c[0]);
+ return new String(c);
+}
+
+def determineVersion = {
+ def env = System.getenv()
+ def mavenVersion = env.containsKey("TP_RELEASE_VERSION") ? env.get("JS_RELEASE_VERSION") : '${project.version}'
+ return mavenVersion.replace("-SNAPSHOT", "-alpha1")
+}
+
+def binding = ["enums": CoreImports.getClassImports()
+ .findAll { Enum.class.isAssignableFrom(it) }
+ .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() },
+ "pmethods": P.class.getMethods().
+ findAll { Modifier.isStatic(it.getModifiers()) }.
+ findAll { P.class.isAssignableFrom(it.returnType) }.
+ collect { it.name }.
+ unique().
+ sort { a, b -> a <=> b },
+ "sourceStepMethods": GraphTraversalSource.getMethods(). // SOURCE STEPS
+ findAll { GraphTraversalSource.class.equals(it.returnType) }.
+ findAll {
+ !it.name.equals("clone") &&
+ !it.name.equals(TraversalSource.Symbols.withBindings) &&
+ !it.name.equals(TraversalSource.Symbols.withRemote) &&
+ !it.name.equals(TraversalSource.Symbols.withComputer)
+ }.
+ collect { it.name }.
+ unique().
+ sort { a, b -> a <=> b },
+ "sourceSpawnMethods": GraphTraversalSource.getMethods(). // SPAWN STEPS
+ findAll { GraphTraversal.class.equals(it.returnType) }.
+ collect { it.name }.
+ unique().
+ sort { a, b -> a <=> b },
+ "graphStepMethods": GraphTraversal.getMethods().
+ findAll { GraphTraversal.class.equals(it.returnType) }.
+ findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
+ collect { it.name }.
+ unique().
+ sort { a, b -> a <=> b },
+ "anonStepMethods": __.class.getMethods().
+ findAll { GraphTraversal.class.equals(it.returnType) }.
+ findAll { Modifier.isStatic(it.getModifiers()) }.
+ findAll { !it.name.equals("__") && !it.name.equals("start") }.
+ collect { it.name }.
+ unique().
+ sort { a, b -> a <=> b },
+ "toJs": toJs,
+ "version": determineVersion(),
+ "decapitalize": decapitalize]
+
+def engine = new groovy.text.GStringTemplateEngine()
+def graphTraversalTemplate = engine.createTemplate(new File('${project.basedir}/glv/GraphTraversalSource.template')).make(binding)
+def graphTraversalFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js')
+graphTraversalFile.newWriter().withWriter{ it << graphTraversalTemplate }
+
+def traversalTemplate = engine.createTemplate(new File('${project.basedir}/glv/TraversalSource.template')).make(binding)
+def traversalFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/traversal.js')
+traversalFile.newWriter().withWriter{ it << traversalTemplate }
+
+def packageJsonTemplate = engine.createTemplate(new File('${project.basedir}/glv/PackageJson.template')).make(binding)
+def packageJsonFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/package.json')
+packageJsonFile.newWriter().withWriter{ it << packageJsonTemplate }
+]]> </script>
+ </scripts>
+ </configuration>
+ </execution>
+ <execution>
<id>gremlin-server-start</id>
<phase>pre-integration-test</phase>
<goals>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
deleted file mode 100644
index ab9eaf1..0000000
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GenerateGremlinJavascript.groovy
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript
-
-public class GenerateGremlinJavascript {
- public static void main(String[] args) {
- String projectVersion = args[0];
- final String baseDir = args[1];
- final String jsModuleDir = "${baseDir}/src/main/javascript/gremlin-javascript";
- Integer versionSnapshotIndex = projectVersion.indexOf("-SNAPSHOT");
- if (versionSnapshotIndex > 0) {
- // Use a alpha version x.y.z-alpha1
- projectVersion = projectVersion.substring(0, versionSnapshotIndex) + "-alpha1";
- }
- TraversalSourceGenerator.create("$jsModuleDir/lib/process/traversal.js");
- GraphTraversalSourceGenerator.create("$jsModuleDir/lib/process/graph-traversal.js");
- PackageJsonGenerator.create("$jsModuleDir/package.json", projectVersion);
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
deleted file mode 100644
index 3227f2c..0000000
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript
-
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
-import org.apache.tinkerpop.gremlin.javascript.SymbolHelper
-
-import java.lang.reflect.Modifier
-
-/**
- * @author Jorge Bay Gondra
- */
-class GraphTraversalSourceGenerator {
-
- public static void create(final String graphTraversalSourceFile) {
-
- final StringBuilder moduleOutput = new StringBuilder()
-
- moduleOutput.append("""/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- """)
-
-//////////////////////////
-// GraphTraversalSource //
-//////////////////////////
- moduleOutput.append("""
-/**
- * @author Jorge Bay Gondra
- */
-'use strict';
-
-var t = require('./traversal.js');
-var remote = require('../driver/remote-connection');
-var utils = require('../utils');
-var Bytecode = require('./bytecode');
-var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
-var inherits = utils.inherits;
-var parseArgs = utils.parseArgs;
-
-/**
- *
- * @param {Graph} graph
- * @param {TraversalStrategies} traversalStrategies
- * @param {Bytecode} [bytecode]
- * @constructor
- */
-function GraphTraversalSource(graph, traversalStrategies, bytecode) {
- this.graph = graph;
- this.traversalStrategies = traversalStrategies;
- this.bytecode = bytecode || new Bytecode();
-}
-
-/**
- * @param remoteConnection
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
- var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
- traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
- return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
-};
-
-/**
- * Returns the string representation of the GraphTraversalSource.
- * @returns {string}
- */
-GraphTraversalSource.prototype.toString = function () {
- return 'graphtraversalsource[' + this.graph.toString() + ']';
-};
-""")
- GraphTraversalSource.getMethods(). // SOURCE STEPS
- findAll { GraphTraversalSource.class.equals(it.returnType) }.
- findAll {
- !it.name.equals("clone") &&
- !it.name.equals(TraversalSource.Symbols.withBindings) &&
- !it.name.equals(TraversalSource.Symbols.withRemote)
- }.
- collect { it.name }.
- unique().
- sort { a, b -> a <=> b }.
- forEach { methodName ->
- moduleOutput.append(
- """
-/**
- * Graph Traversal Source ${methodName} method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
- var b = new Bytecode(this.bytecode).addSource('$methodName', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-""")
- }
- GraphTraversalSource.getMethods().
- findAll { GraphTraversal.class.equals(it.returnType) }.
- collect { it.name }.
- unique().
- sort { a, b -> a <=> b }.
- forEach { methodName ->
- moduleOutput.append(
- """
-/**
- * $methodName GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
- var b = new Bytecode(this.bytecode).addStep('$methodName', parseArgs.apply(null, arguments));
- return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-""")
- }
-////////////////////
-// GraphTraversal //
-////////////////////
- moduleOutput.append(
- """
-/**
- * Represents a graph traversal.
- * @extends Traversal
- * @constructor
- */
-function GraphTraversal(graph, traversalStrategies, bytecode) {
- t.Traversal.call(this, graph, traversalStrategies, bytecode);
-}
-
-inherits(GraphTraversal, t.Traversal);
-""")
- GraphTraversal.getMethods().
- findAll { GraphTraversal.class.equals(it.returnType) }.
- findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
- collect { it.name }.
- unique().
- sort { a, b -> a <=> b }.
- forEach { methodName ->
- moduleOutput.append(
- """
-/**
- * Graph traversal $methodName method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.${SymbolHelper.toJs(methodName)} = function (args) {
- this.bytecode.addStep('$methodName', parseArgs.apply(null, arguments));
- return this;
-};
-""")
- };
-
-////////////////////////
-// AnonymousTraversal //
-////////////////////////
- moduleOutput.append("""
-/**
- * Contains the static method definitions
- * @type {Object}
- */
-var statics = {};
-""");
- __.class.getMethods().
- findAll { GraphTraversal.class.equals(it.returnType) }.
- findAll { Modifier.isStatic(it.getModifiers()) }.
- findAll { !it.name.equals("__") }.
- collect { SymbolHelper.toJs(it.name) }.
- unique().
- sort { a, b -> a <=> b }.
- forEach { method ->
- moduleOutput.append(
- """
-/**
- * ${method}() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.${method} = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.${method}.apply(g, arguments);
-};
-""")
- };
-
- moduleOutput.append("""
-module.exports = {
- GraphTraversal: GraphTraversal,
- GraphTraversalSource: GraphTraversalSource,
- statics: statics
-};""");
-
- // save to file
- final File file = new File(graphTraversalSourceFile);
- file.delete()
- moduleOutput.eachLine { file.append(it + "\n") }
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
deleted file mode 100644
index 4b4d012..0000000
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/PackageJsonGenerator.groovy
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript
-
-/**
- * @author Jorge Bay Gondra
- */
-class PackageJsonGenerator {
-
- public static void create(final String traversalSourceFile, final String version) {
-
- final StringBuilder moduleOutput = new StringBuilder();
- moduleOutput.append("""{
- "name": "gremlin-javascript",
- "version": "${version}",
- "description": "JavaScript Gremlin Language Variant",
- "author": "Apache TinkerPop team",
- "keywords": [
- "graph",
- "gremlin",
- "tinkerpop",
- "connection",
- "glv",
- "driver",
- "graphdb"
- ],
- "license": "Apache-2.0",
- "dependencies": {
- "ws": "^3.0.0"
- },
- "devDependencies": {
- "mocha": ">= 1.14.0"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/apache/tinkerpop.git"
- },
- "bugs": {
- "url": "https://issues.apache.org/jira/browse/TINKERPOP"
- },
- "scripts": {
- "test": "./node_modules/.bin/mocha test --recursive -t 5000",
- "unit-test": "./node_modules/.bin/mocha test/unit"
- },
- "engines": {
- "node": ">=4"
- }
-}""" );
-
- // save to a file
- final File file = new File(traversalSourceFile);
- file.delete()
- moduleOutput.eachLine { file.append(it + "\n") }
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
deleted file mode 100644
index ed45cdb..0000000
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/SymbolHelper.groovy
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript
-
-/**
- * @author Jorge Bay Gondra
- */
-public final class SymbolHelper {
-
- private final static Map<String, String> TO_JS_MAP = new HashMap<>();
-
- static {
- TO_JS_MAP.put("in", "in_");
- TO_JS_MAP.put("from", "from_");
- }
-
- private SymbolHelper() {
- // static methods only, do not instantiate
- }
-
- public static String toJs(final String symbol) {
- return TO_JS_MAP.getOrDefault(symbol, symbol);
- }
-
- public static String decapitalize(String string) {
- if (string == null || string.length() == 0) {
- return string;
- }
- def c = string.toCharArray();
- c[0] = Character.toLowerCase(c[0]);
- return new String(c);
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
deleted file mode 100644
index f3405c3..0000000
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tinkerpop.gremlin.javascript
-
-import org.apache.tinkerpop.gremlin.process.traversal.P
-import org.apache.tinkerpop.gremlin.util.CoreImports
-
-import java.lang.reflect.Modifier
-
-/**
- * @author Jorge Bay Gondra
- */
-class TraversalSourceGenerator {
-
- public static void create(final String traversalSourceFile) {
-
- final StringBuilder moduleOutput = new StringBuilder()
-
- moduleOutput.append("""/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-""")
- moduleOutput.append("""
-/**
- * @author Jorge Bay Gondra
- */
-'use strict';
-
-var utils = require('../utils');
-var parseArgs = utils.parseArgs;
-var itemDone = Object.freeze({ value: null, done: true });
-var emptyArray = Object.freeze([]);
-
-function Traversal(graph, traversalStrategies, bytecode) {
- this.graph = graph;
- this.traversalStrategies = traversalStrategies;
- this.bytecode = bytecode;
- this.traversers = null;
- this.sideEffects = null;
- this._traversalStrategiesPromise = null;
- this._traversersIteratorIndex = 0;
-}
-
-/** @returns {Bytecode} */
-Traversal.prototype.getBytecode = function () {
- return this.bytecode;
-};
-
-/**
- * Returns an Array containing the traverser objects.
- * @returns {Promise.<Array>}
- */
-Traversal.prototype.toList = function () {
- var self = this;
- return this._applyStrategies().then(function () {
- if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
- return emptyArray;
- }
- var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
- for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
- arr[i] = self.traversers[i].object;
- }
- self._traversersIteratorIndex = self.traversers.length;
- return arr;
- });
-};
-
-/**
- * Async iterator method implementation.
- * Returns a promise containing an iterator item.
- * @returns {Promise.<{value, done}>}
- */
-Traversal.prototype.next = function () {
- var self = this;
- return this._applyStrategies().then(function () {
- if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
- return itemDone;
- }
- return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
- });
-};
-
-Traversal.prototype._applyStrategies = function () {
- if (this._traversalStrategiesPromise) {
- // Apply strategies only once
- return this._traversalStrategiesPromise;
- }
- return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
-};
-
-/**
- * Returns the Bytecode JSON representation of the traversal
- * @returns {String}
- */
-Traversal.prototype.toString = function () {
- return this.bytecode.toString();
-};
- """);
-
- moduleOutput.append("""
-/**
- * Represents an operation.
- * @constructor
- */
-function P(operator, value, other) {
- this.operator = operator;
- this.value = value;
- this.other = other;
-}
-
-/**
- * Returns the string representation of the instance.
- * @returns {string}
- */
-P.prototype.toString = function () {
- if (this.other === undefined) {
- return this.operator + '(' + this.value + ')';
- }
- return this.operator + '(' + this.value + ', ' + this.other + ')';
-};
-
-function createP(operator, args) {
- args.unshift(null, operator);
- return new (Function.prototype.bind.apply(P, args));
-}
-""")
- P.class.getMethods().
- findAll { Modifier.isStatic(it.getModifiers()) }.
- findAll { P.class.isAssignableFrom(it.returnType) }.
- collect { it.name }.
- unique().
- sort { a, b -> a <=> b }.
- each { methodName ->
- moduleOutput.append(
- """
-/** @param {...Object} args */
-P.${SymbolHelper.toJs(methodName)} = function (args) {
- return createP('$methodName', parseArgs.apply(null, arguments));
-};
-""")
- };
- moduleOutput.append("""
-P.prototype.and = function (arg) {
- return new P('and', this, arg);
-};
-
-P.prototype.or = function (arg) {
- return new P('or', this, arg);
-};
-""")
-
- moduleOutput.append("""
-function Traverser(object, bulk) {
- this.object = object;
- this.bulk = bulk == undefined ? 1 : bulk;
-}
-
-function TraversalSideEffects() {
-
-}
-
-function toEnum(typeName, keys) {
- var result = {};
- keys.split(' ').forEach(function (k) {
- var jsKey = k;
- if (jsKey === jsKey.toUpperCase()) {
- jsKey = jsKey.toLowerCase();
- }
- result[jsKey] = new EnumValue(typeName, k);
- });
- return result;
-}
-
-function EnumValue(typeName, elementName) {
- this.typeName = typeName;
- this.elementName = elementName;
-}
-
-module.exports = {
- EnumValue: EnumValue,
- P: P,
- Traversal: Traversal,
- TraversalSideEffects: TraversalSideEffects,
- Traverser: Traverser""")
- for (final Class<? extends Enum> enumClass : CoreImports.getClassImports().
- findAll { Enum.class.isAssignableFrom(it) }.
- sort { a, b -> a.simpleName <=> b.simpleName }) {
- moduleOutput.append(",\n ${SymbolHelper.decapitalize(enumClass.simpleName)}: " +
- "toEnum('${SymbolHelper.toJs(enumClass.simpleName)}', '");
- moduleOutput.append(
- enumClass.getEnumConstants().
- sort { a, b -> a.name() <=> b.name() }.
- collect { SymbolHelper.toJs(it.name()) }.
- join(' '));
- moduleOutput.append("\')");
- }
-
- moduleOutput.append("""\n};""");
-
- // save to a file
- final File file = new File(traversalSourceFile);
- file.delete()
- moduleOutput.eachLine { file.append(it + "\n") }
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
index 5ee734a1..f6a0de1 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+
/**
* @author Jorge Bay Gondra
*/
@@ -72,16 +72,6 @@ GraphTraversalSource.prototype.withBulk = function (args) {
};
/**
- * Graph Traversal Source withComputer method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withComputer = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
* Graph Traversal Source withPath method.
* @param {...Object} args
* @returns {GraphTraversalSource}
@@ -1539,33 +1529,33 @@ statics.identity = function (args) {
};
/**
- * inE() static method
+ * in() static method
* @param {...Object} args
* @returns {GraphTraversal}
*/
-statics.inE = function (args) {
+statics.in_ = function (args) {
var g = new GraphTraversal(null, null, new Bytecode());
- return g.inE.apply(g, arguments);
+ return g.in_.apply(g, arguments);
};
/**
- * inV() static method
+ * inE() static method
* @param {...Object} args
* @returns {GraphTraversal}
*/
-statics.inV = function (args) {
+statics.inE = function (args) {
var g = new GraphTraversal(null, null, new Bytecode());
- return g.inV.apply(g, arguments);
+ return g.inE.apply(g, arguments);
};
/**
- * in_() static method
+ * inV() static method
* @param {...Object} args
* @returns {GraphTraversal}
*/
-statics.in_ = function (args) {
+statics.inV = function (args) {
var g = new GraphTraversal(null, null, new Bytecode());
- return g.in_.apply(g, arguments);
+ return g.inV.apply(g, arguments);
};
/**
@@ -1909,16 +1899,6 @@ statics.simplePath = function (args) {
};
/**
- * start() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.start = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.start.apply(g, arguments);
-};
-
-/**
* store() static method
* @param {...Object} args
* @returns {GraphTraversal}
@@ -2092,4 +2072,4 @@ module.exports = {
GraphTraversal: GraphTraversal,
GraphTraversalSource: GraphTraversalSource,
statics: statics
-};
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index 1cd6b53..49c6aef 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -91,7 +91,7 @@ Traversal.prototype._applyStrategies = function () {
Traversal.prototype.toString = function () {
return this.bytecode.toString();
};
-
+
/**
* Represents an operation.
* @constructor
@@ -227,10 +227,12 @@ module.exports = {
cardinality: toEnum('Cardinality', 'list set single'),
column: toEnum('Column', 'keys values'),
direction: toEnum('Direction', 'BOTH IN OUT'),
+ graphSONVersion: toEnum('GraphSONVersion', 'V1_0 V2_0'),
+ gryoVersion: toEnum('GryoVersion', 'V1_0'),
operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
pick: toEnum('Pick', 'any none'),
pop: toEnum('Pop', 'all first last'),
scope: toEnum('Scope', 'global local'),
t: toEnum('T', 'id key label value')
-};
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98dc52c3/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index db6d3fe..514663b 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -33,4 +33,4 @@
"engines": {
"node": ">=4"
}
-}
+}
\ No newline at end of file
[09/47] tinkerpop git commit: TINKERPOP-1489 Cleaned up pom
Posted by jo...@apache.org.
TINKERPOP-1489 Cleaned up pom
Removed some weird characters in license and bumped version to 3.2.5-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7f5d0306
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7f5d0306
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7f5d0306
Branch: refs/heads/master
Commit: 7f5d0306e2e20ae756292bf829b9ddcfbbac0db6
Parents: 598b991
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 18 12:47:48 2017 -0400
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:14 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/pom.xml | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7f5d0306/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 387e628..b9b78cc 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -1,22 +1,19 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -24,7 +21,7 @@
<parent>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>tinkerpop</artifactId>
- <version>3.2.3-SNAPSHOT</version>
+ <version>3.2.5-SNAPSHOT</version>
</parent>
<artifactId>gremlin-javascript</artifactId>
<name>Apache TinkerPop :: Gremlin Javascript</name>
[21/47] tinkerpop git commit: Add travis support
Posted by jo...@apache.org.
Add travis support
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d35aef7c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d35aef7c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d35aef7c
Branch: refs/heads/master
Commit: d35aef7c8d2b0f4df78ca6aacd16f6e6891d4d23
Parents: eccbd15
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 22 15:46:14 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:15 2018 +0100
----------------------------------------------------------------------
.travis.yml | 3 ++-
gremlin-javascript/pom.xml | 1 -
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d35aef7c/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 9b7029c..2c86de3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,4 +15,5 @@ before_install:
jobs:
include:
- script: "mvn clean install -Dci"
- - script: "touch gremlin-dotnet/src/.glv && touch gremlin-dotnet/test/.glv && mvn clean install -pl :gremlin-dotnet,:gremlin-dotnet-tests -P gremlin-dotnet -DskipIntegrationTests=false"
\ No newline at end of file
+ - script: "touch gremlin-dotnet/src/.glv && touch gremlin-dotnet/test/.glv && mvn clean install -pl :gremlin-dotnet,:gremlin-dotnet-tests -P gremlin-dotnet -DskipIntegrationTests=false"
+ - script: "mvn clean install -pl :gremlin-javascript -DskipIntegrationTests=false"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d35aef7c/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index 919c87e..c08b59b 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -31,7 +31,6 @@ limitations under the License.
<artifactId>gremlin-core</artifactId>
<version>${project.version}</version>
</dependency>
- <!-- TESTING -->
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>tinkergraph-gremlin</artifactId>
[42/47] tinkerpop git commit: Remove utils.toPromise()
Posted by jo...@apache.org.
Remove utils.toPromise()
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/af718f7c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/af718f7c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/af718f7c
Branch: refs/heads/master
Commit: af718f7ca53111b371903471ae76841aa7e06861
Parents: f2f9729
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Jan 22 11:19:07 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Mon Jan 22 11:19:07 2018 +0100
----------------------------------------------------------------------
.../lib/driver/driver-remote-connection.js | 68 +++++++++-----------
.../lib/driver/remote-connection.js | 9 ++-
.../lib/process/traversal-strategy.js | 20 ++----
.../javascript/gremlin-javascript/lib/utils.js | 31 ---------
.../test/unit/traversal-test.js | 13 ++--
5 files changed, 44 insertions(+), 97 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/af718f7c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index ac3fb0f..5587fd6 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -59,16 +59,13 @@ class DriverRemoteConnection extends RemoteConnection {
pfx: options.pfx,
rejectUnauthorized: options.rejectUnauthorized
});
- var self = this;
- this._ws.on('open', function opened () {
- self.isOpen = true;
- if (self._openCallback) {
- self._openCallback();
+ this._ws.on('open', () => {
+ this.isOpen = true;
+ if (this._openCallback) {
+ this._openCallback();
}
});
- this._ws.on('message', function incoming (data) {
- self._handleMessage(data);
- });
+ this._ws.on('message', data => this._handleMessage(data));
// A map containing the request id and the handler
this._responseHandlers = {};
this._reader = options.reader || new serializer.GraphSONReader();
@@ -86,39 +83,33 @@ class DriverRemoteConnection extends RemoteConnection {
* Opens the connection, if its not already opened.
* @returns {Promise}
*/
- open(promiseFactory) {
+ open() {
if (this._closePromise) {
- return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
- callback(new Error('Connection has been closed'));
- });
+ return this._openPromise = Promise.reject(new Error('Connection has been closed'));
+ }
+ if (this.isOpen) {
+ return Promise.resolve();
}
if (this._openPromise) {
return this._openPromise;
}
- const self = this;
- return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
- if (self.isOpen) {
- return callback();
- }
- // It will be invoked when opened
- self._openCallback = callback;
+ return this._openPromise = new Promise((resolve, reject) => {
+ // Set the callback that will be invoked once the WS is opened
+ this._openCallback = err => err ? reject(err) : resolve();
});
}
/** @override */
- submit(bytecode, promiseFactory) {
- const self = this;
- return this.open().then(function () {
- return utils.toPromise(promiseFactory, function promiseHandler(callback) {
- const requestId = getUuid();
- self._responseHandlers[requestId] = {
- callback: callback,
- result: null
- };
- const message = bufferFromString(self._header + JSON.stringify(self._getRequest(requestId, bytecode)));
- self._ws.send(message);
- });
- });
+ submit(bytecode) {
+ return this.open().then(() => new Promise((resolve, reject) => {
+ const requestId = getUuid();
+ this._responseHandlers[requestId] = {
+ callback: (err, result) => err ? reject(err) : resolve(result),
+ result: null
+ };
+ const message = bufferFromString(this._header + JSON.stringify(this._getRequest(requestId, bytecode)));
+ this._ws.send(message);
+ }));
}
_getRequest(id, bytecode) {
@@ -163,17 +154,16 @@ class DriverRemoteConnection extends RemoteConnection {
* Closes the Connection.
* @return {Promise}
*/
- close(promiseFactory) {
+ close() {
if (this._closePromise) {
return this._closePromise;
}
- const self = this;
- return this._closePromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
- self._ws.on('close', function () {
- self.isOpen = false;
- callback();
+ this._closePromise = new Promise(resolve => {
+ this._ws.on('close', function () {
+ this.isOpen = false;
+ resolve();
});
- self._ws.close();
+ this._ws.close();
});
}
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/af718f7c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
index 37f3d0e..2672ff4 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
@@ -33,10 +33,9 @@ class RemoteConnection {
/**
* @abstract
* @param {Bytecode} bytecode
- * @param {Function|undefined} promiseFactory
* @returns {Promise}
*/
- submit(bytecode, promiseFactory) {
+ submit(bytecode) {
throw new Error('submit() was not implemented');
};
}
@@ -60,11 +59,11 @@ class RemoteStrategy extends TraversalStrategy {
}
/** @override */
- apply(traversal, promiseFactory) {
+ apply(traversal) {
if (traversal.traversers) {
- return utils.resolvedPromise(promiseFactory);
+ return Promise.resolve();
}
- return this.connection.submit(traversal.getBytecode(), promiseFactory).then(function (remoteTraversal) {
+ return this.connection.submit(traversal.getBytecode()).then(function (remoteTraversal) {
traversal.sideEffects = remoteTraversal.sideEffects;
traversal.traversers = remoteTraversal.traversers;
});
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/af718f7c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
index fbc3fba..d3d97b8 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
@@ -28,22 +28,16 @@ class TraversalStrategies {
/**
* Creates a new instance of TraversalStrategies.
* @param {TraversalStrategies} [parent] The parent strategies from where to clone the values from.
- * @param {Function} [promiseFactory] The factory used to create the A+ Promise instances. Use it when you want to
- * create Promise instances without using ECMAScript Promise constructor, ie: bluebird or Q promises.
* @constructor
*/
- constructor(parent, promiseFactory) {
+ constructor(parent) {
if (parent) {
// Clone the strategies
this.strategies = parent.strategies.slice(0);
- this.promiseFactory = parent.promiseFactory;
}
else {
this.strategies = [];
}
- if (promiseFactory) {
- this.promiseFactory = promiseFactory;
- }
}
/** @param {TraversalStrategy} strategy */
@@ -57,12 +51,9 @@ class TraversalStrategies {
*/
applyStrategies(traversal) {
// Apply all strategies serially
- const self = this;
- return this.strategies.reduce(function reduceItem(promise, strategy) {
- return promise.then(function () {
- return strategy.apply(traversal, self.promiseFactory);
- });
- }, utils.resolvedPromise(this.promiseFactory));
+ return this.strategies.reduce((promise, strategy) => {
+ return promise.then(() => strategy.apply(traversal));
+ }, Promise.resolve());
}
}
@@ -71,10 +62,9 @@ class TraversalStrategy {
/**
* @abstract
* @param {Traversal} traversal
- * @param {Function|undefined} promiseFactory
* @returns {Promise}
*/
- apply(traversal, promiseFactory) {
+ apply(traversal) {
}
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/af718f7c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
index bf87368..c864efd 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
@@ -27,37 +27,6 @@ exports.parseArgs = function parseArgs() {
return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
};
-/**
- * @param {Function} handler
- * @returns {Promise}
- */
-function defaultPromiseFactory(handler) {
- return new Promise(function executor(resolve, reject) {
- handler(function handlerCallback(err, result) {
- if (err) {
- return reject(err);
- }
- resolve(result);
- });
- });
-}
-
-/**
- * Gets a resolved Promise instance.
- * @param {Function} promiseFactory
- * @returns {Promise}
- */
-exports.resolvedPromise = function (promiseFactory) {
- return toPromise(promiseFactory, function handler(cb) {
- cb();
- });
-};
-
-const toPromise = exports.toPromise = function toPromise(promiseFactory, handler) {
- promiseFactory = promiseFactory || defaultPromiseFactory;
- return promiseFactory(handler);
-};
-
exports.toLong = function toLong(value) {
return new Long(value);
};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/af718f7c/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
index 9310143..130a218 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
@@ -25,7 +25,6 @@
const assert = require('assert');
const expect = require('chai').expect;
const graph = require('../../lib/structure/graph');
-const utils = require('../../lib/utils');
const t = require('../../lib/process/traversal');
const TraversalStrategies = require('../../lib/process/traversal-strategy').TraversalStrategies;
@@ -64,7 +63,7 @@ describe('Traversal', function () {
const strategyMock = {
apply: function (traversal) {
traversal.traversers = [ new t.Traverser(1, 1), new t.Traverser(2, 1) ];
- return utils.resolvedPromise();
+ return Promise.resolve();
}
};
const strategies = new TraversalStrategies();
@@ -92,7 +91,7 @@ describe('Traversal', function () {
const strategyMock = {
apply: function (traversal) {
traversal.traversers = [ new t.Traverser(1, 2), new t.Traverser(2, 1) ];
- return utils.resolvedPromise();
+ return Promise.resolve();
}
};
const strategies = new TraversalStrategies();
@@ -128,7 +127,7 @@ describe('Traversal', function () {
const strategyMock = {
apply: function (traversal) {
traversal.traversers = [ new t.Traverser('a', 1), new t.Traverser('b', 1) ];
- return utils.resolvedPromise();
+ return Promise.resolve();
}
};
const strategies = new TraversalStrategies();
@@ -144,7 +143,7 @@ describe('Traversal', function () {
const strategyMock = {
apply: function (traversal) {
traversal.traversers = [];
- return utils.resolvedPromise();
+ return Promise.resolve();
}
};
const strategies = new TraversalStrategies();
@@ -161,7 +160,7 @@ describe('Traversal', function () {
apply: function (traversal) {
traversal.traversers = [ new t.Traverser(1, 1), new t.Traverser(2, 3), new t.Traverser(3, 2),
new t.Traverser(4, 1) ];
- return utils.resolvedPromise();
+ return Promise.resolve();
}
};
const strategies = new TraversalStrategies();
@@ -181,7 +180,7 @@ describe('Traversal', function () {
apply: function (traversal) {
applied = true;
traversal.traversers = [ new t.Traverser('a', 1), new t.Traverser('b', 1) ];
- return utils.resolvedPromise();
+ return Promise.resolve();
}
};
const strategies = new TraversalStrategies();
[23/47] tinkerpop git commit: Support ignore scenarios
Posted by jo...@apache.org.
Support ignore scenarios
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f9f7033e
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f9f7033e
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f9f7033e
Branch: refs/heads/master
Commit: f9f7033ed3abd9aaadc7203054fed9554315a78f
Parents: b8eb6c0
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Nov 28 13:14:26 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:16 2018 +0100
----------------------------------------------------------------------
.../test/cucumber/feature-steps.js | 20 ++++++++++++++------
.../gremlin-javascript/test/cucumber/world.js | 4 +++-
2 files changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f9f7033e/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 99e2ec8..06a3283 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -52,8 +52,20 @@ const parsers = [
[ 'c\\[(.+)\\]', toLambda ]
].map(x => [ new RegExp('^' + x[0] + '$'), x[1] ]);
+const ignoreReason = {
+ lambdaNotSupported: 'Lambdas are not supported on gremlin-javascript',
+};
+
+const ignoredScenarios = {
+ // An associative array containing the scenario name as key, for example:
+ // 'g_V_branchXlabel_eq_person': new IgnoreError(ignoreReason.lambdaNotSupported),
+};
+
defineSupportCode(function(methods) {
methods.Given(/^the (.+) graph$/, function (graphName) {
+ if (ignoredScenarios[this.scenario]) {
+ return 'skipped';
+ }
this.graphName = graphName;
const data = this.getData();
this.g = new Graph().traversal().withRemote(data.connection);
@@ -282,7 +294,7 @@ function parseMapValue(value) {
}
function toLambda() {
- throw new IgnoreError(IgnoreError.reason.lambdaNotSupported);
+ throw new IgnoreError(ignoreReason.lambdaNotSupported);
}
/**
@@ -310,8 +322,4 @@ function IgnoreError(reason) {
Error.captureStackTrace(this, IgnoreError);
}
-util.inherits(IgnoreError, Error);
-
-IgnoreError.reason = {
- lambdaNotSupported: 'Lambdas are not supported on gremlin-javascript',
-};
\ No newline at end of file
+util.inherits(IgnoreError, Error);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f9f7033e/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
index 03febd1..ae3f9a6 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -33,6 +33,7 @@ defineSupportCode(function (methods) {
const cache = {};
function TinkerPopWorld(){
+ this.scenario = null;
this.g = null;
this.traversal = null;
this.result = null;
@@ -91,7 +92,8 @@ defineSupportCode(function (methods) {
return Promise.all(Object.keys(cache).map(graphName => cache[graphName].connection.close()));
});
- methods.Before(function () {
+ methods.Before(function (info) {
+ this.scenario = info.pickle.name;
this.cache = cache;
});
});
[05/47] tinkerpop git commit: Update Javascript GLV
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
deleted file mode 100644
index 7f36e59..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
+++ /dev/null
@@ -1,2016 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineGraphTraversalModule() {
- "use strict";
-
- var t = loadModule.call(this, './traversal.js');
- var remote = loadModule.call(this, '../driver/remote-connection.js');
- var Bytecode = t.Bytecode;
- var inherits = t.inherits;
- var parseArgs = t.parseArgs;
-
- /**
- *
- * @param {Graph} graph
- * @param {TraversalStrategies} traversalStrategies
- * @param {Bytecode} [bytecode]
- * @constructor
- */
- function GraphTraversalSource(graph, traversalStrategies, bytecode) {
- this.graph = graph;
- this.traversalStrategies = traversalStrategies;
- this.bytecode = bytecode || new Bytecode();
- }
-
- /**
- * @param remoteConnection
- * @returns {GraphTraversalSource}
- */
- GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
- var traversalStrategy = new t.TraversalStrategies(this.traversalStrategies);
- traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
- return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
- };
-
- /**
- * Returns the string representation of the GraphTraversalSource.
- * @returns {string}
- */
- GraphTraversalSource.prototype.toString = function () {
- return 'graphtraversalsource[' + this.graph.toString() + ']';
- };
-
- /**
- * withBulk GraphTraversalSource method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
- GraphTraversalSource.prototype.withBulk = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
-
- /**
- * withComputer GraphTraversalSource method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
- GraphTraversalSource.prototype.withComputer = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
-
- /**
- * withPath GraphTraversalSource method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
- GraphTraversalSource.prototype.withPath = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
-
- /**
- * withSack GraphTraversalSource method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
- GraphTraversalSource.prototype.withSack = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
-
- /**
- * withSideEffect GraphTraversalSource method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
- GraphTraversalSource.prototype.withSideEffect = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
-
- /**
- * withStrategies GraphTraversalSource method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
- GraphTraversalSource.prototype.withStrategies = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
-
- /**
- * withoutStrategies GraphTraversalSource method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
- GraphTraversalSource.prototype.withoutStrategies = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
-
- /**
- * E GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversalSource.prototype.E = function (args) {
- var b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
- return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
-
- /**
- * V GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversalSource.prototype.V = function (args) {
- var b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
- return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
-
- /**
- * addV GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversalSource.prototype.addV = function (args) {
- var b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
- return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
-
- /**
- * inject GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversalSource.prototype.inject = function (args) {
- var b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
- return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
- };
-
- /**
- * Represents a graph traversal.
- * @extends Traversal
- * @constructor
- */
- function GraphTraversal(graph, traversalStrategies, bytecode) {
- t.Traversal.call(this, graph, traversalStrategies, bytecode);
- }
-
- inherits(GraphTraversal, t.Traversal);
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.V = function (args) {
- this.bytecode.addStep('V', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.addE = function (args) {
- this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.addInE = function (args) {
- this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.addOutE = function (args) {
- this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.addV = function (args) {
- this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.aggregate = function (args) {
- this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.and = function (args) {
- this.bytecode.addStep('and', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.as = function (args) {
- this.bytecode.addStep('as', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.barrier = function (args) {
- this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.both = function (args) {
- this.bytecode.addStep('both', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.bothE = function (args) {
- this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.bothV = function (args) {
- this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.branch = function (args) {
- this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.by = function (args) {
- this.bytecode.addStep('by', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.cap = function (args) {
- this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.choose = function (args) {
- this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.coalesce = function (args) {
- this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.coin = function (args) {
- this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.constant = function (args) {
- this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.count = function (args) {
- this.bytecode.addStep('count', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.cyclicPath = function (args) {
- this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.dedup = function (args) {
- this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.drop = function (args) {
- this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.emit = function (args) {
- this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.filter = function (args) {
- this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.flatMap = function (args) {
- this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.fold = function (args) {
- this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.from_ = function (args) {
- this.bytecode.addStep('from', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.group = function (args) {
- this.bytecode.addStep('group', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.groupCount = function (args) {
- this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.groupV3d0 = function (args) {
- this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.has = function (args) {
- this.bytecode.addStep('has', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.hasId = function (args) {
- this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.hasKey = function (args) {
- this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.hasLabel = function (args) {
- this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.hasNot = function (args) {
- this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.hasValue = function (args) {
- this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.id = function (args) {
- this.bytecode.addStep('id', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.identity = function (args) {
- this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.inE = function (args) {
- this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.inV = function (args) {
- this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.in_ = function (args) {
- this.bytecode.addStep('in', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.inject = function (args) {
- this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.is = function (args) {
- this.bytecode.addStep('is', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.key = function (args) {
- this.bytecode.addStep('key', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.label = function (args) {
- this.bytecode.addStep('label', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.limit = function (args) {
- this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.local = function (args) {
- this.bytecode.addStep('local', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.loops = function (args) {
- this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.map = function (args) {
- this.bytecode.addStep('map', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.mapKeys = function (args) {
- this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.mapValues = function (args) {
- this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.match = function (args) {
- this.bytecode.addStep('match', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.max = function (args) {
- this.bytecode.addStep('max', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.mean = function (args) {
- this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.min = function (args) {
- this.bytecode.addStep('min', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.not = function (args) {
- this.bytecode.addStep('not', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.option = function (args) {
- this.bytecode.addStep('option', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.optional = function (args) {
- this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.or = function (args) {
- this.bytecode.addStep('or', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.order = function (args) {
- this.bytecode.addStep('order', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.otherV = function (args) {
- this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.out = function (args) {
- this.bytecode.addStep('out', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.outE = function (args) {
- this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.outV = function (args) {
- this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.pageRank = function (args) {
- this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.path = function (args) {
- this.bytecode.addStep('path', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.peerPressure = function (args) {
- this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.profile = function (args) {
- this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.program = function (args) {
- this.bytecode.addStep('program', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.project = function (args) {
- this.bytecode.addStep('project', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.properties = function (args) {
- this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.property = function (args) {
- this.bytecode.addStep('property', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.propertyMap = function (args) {
- this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.range = function (args) {
- this.bytecode.addStep('range', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.repeat = function (args) {
- this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.sack = function (args) {
- this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.sample = function (args) {
- this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.select = function (args) {
- this.bytecode.addStep('select', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.sideEffect = function (args) {
- this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.simplePath = function (args) {
- this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.store = function (args) {
- this.bytecode.addStep('store', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.subgraph = function (args) {
- this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.sum = function (args) {
- this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.tail = function (args) {
- this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.timeLimit = function (args) {
- this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.times = function (args) {
- this.bytecode.addStep('times', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.to = function (args) {
- this.bytecode.addStep('to', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.toE = function (args) {
- this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.toV = function (args) {
- this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.tree = function (args) {
- this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.unfold = function (args) {
- this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.union = function (args) {
- this.bytecode.addStep('union', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.until = function (args) {
- this.bytecode.addStep('until', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.value = function (args) {
- this.bytecode.addStep('value', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.valueMap = function (args) {
- this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.values = function (args) {
- this.bytecode.addStep('values', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- GraphTraversal.prototype.where = function (args) {
- this.bytecode.addStep('where', parseArgs.apply(null, arguments));
- return this;
- };
-
- /**
- * Contains the static method definitions
- * @type {Object}
- */
- var statics = {};
-
- /**
- * V() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.V = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.V.apply(g, arguments);
- };
-
- /**
- * addE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.addE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.addE.apply(g, arguments);
- };
-
- /**
- * addInE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.addInE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.addInE.apply(g, arguments);
- };
-
- /**
- * addOutE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.addOutE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.addOutE.apply(g, arguments);
- };
-
- /**
- * addV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.addV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.addV.apply(g, arguments);
- };
-
- /**
- * aggregate() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.aggregate = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.aggregate.apply(g, arguments);
- };
-
- /**
- * and() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.and = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.and.apply(g, arguments);
- };
-
- /**
- * as() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.as = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.as.apply(g, arguments);
- };
-
- /**
- * barrier() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.barrier = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.barrier.apply(g, arguments);
- };
-
- /**
- * both() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.both = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.both.apply(g, arguments);
- };
-
- /**
- * bothE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.bothE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.bothE.apply(g, arguments);
- };
-
- /**
- * bothV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.bothV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.bothV.apply(g, arguments);
- };
-
- /**
- * branch() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.branch = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.branch.apply(g, arguments);
- };
-
- /**
- * cap() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.cap = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.cap.apply(g, arguments);
- };
-
- /**
- * choose() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.choose = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.choose.apply(g, arguments);
- };
-
- /**
- * coalesce() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.coalesce = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.coalesce.apply(g, arguments);
- };
-
- /**
- * coin() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.coin = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.coin.apply(g, arguments);
- };
-
- /**
- * constant() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.constant = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.constant.apply(g, arguments);
- };
-
- /**
- * count() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.count = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.count.apply(g, arguments);
- };
-
- /**
- * cyclicPath() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.cyclicPath = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.cyclicPath.apply(g, arguments);
- };
-
- /**
- * dedup() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.dedup = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.dedup.apply(g, arguments);
- };
-
- /**
- * drop() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.drop = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.drop.apply(g, arguments);
- };
-
- /**
- * emit() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.emit = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.emit.apply(g, arguments);
- };
-
- /**
- * filter() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.filter = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.filter.apply(g, arguments);
- };
-
- /**
- * flatMap() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.flatMap = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.flatMap.apply(g, arguments);
- };
-
- /**
- * fold() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.fold = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.fold.apply(g, arguments);
- };
-
- /**
- * group() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.group = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.group.apply(g, arguments);
- };
-
- /**
- * groupCount() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.groupCount = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.groupCount.apply(g, arguments);
- };
-
- /**
- * groupV3d0() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.groupV3d0 = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.groupV3d0.apply(g, arguments);
- };
-
- /**
- * has() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.has = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.has.apply(g, arguments);
- };
-
- /**
- * hasId() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.hasId = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.hasId.apply(g, arguments);
- };
-
- /**
- * hasKey() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.hasKey = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.hasKey.apply(g, arguments);
- };
-
- /**
- * hasLabel() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.hasLabel = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.hasLabel.apply(g, arguments);
- };
-
- /**
- * hasNot() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.hasNot = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.hasNot.apply(g, arguments);
- };
-
- /**
- * hasValue() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.hasValue = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.hasValue.apply(g, arguments);
- };
-
- /**
- * id() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.id = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.id.apply(g, arguments);
- };
-
- /**
- * identity() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.identity = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.identity.apply(g, arguments);
- };
-
- /**
- * inE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.inE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.inE.apply(g, arguments);
- };
-
- /**
- * inV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.inV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.inV.apply(g, arguments);
- };
-
- /**
- * in_() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.in_ = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.in_.apply(g, arguments);
- };
-
- /**
- * inject() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.inject = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.inject.apply(g, arguments);
- };
-
- /**
- * is() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.is = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.is.apply(g, arguments);
- };
-
- /**
- * key() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.key = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.key.apply(g, arguments);
- };
-
- /**
- * label() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.label = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.label.apply(g, arguments);
- };
-
- /**
- * limit() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.limit = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.limit.apply(g, arguments);
- };
-
- /**
- * local() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.local = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.local.apply(g, arguments);
- };
-
- /**
- * loops() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.loops = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.loops.apply(g, arguments);
- };
-
- /**
- * map() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.map = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.map.apply(g, arguments);
- };
-
- /**
- * mapKeys() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.mapKeys = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.mapKeys.apply(g, arguments);
- };
-
- /**
- * mapValues() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.mapValues = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.mapValues.apply(g, arguments);
- };
-
- /**
- * match() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.match = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.match.apply(g, arguments);
- };
-
- /**
- * max() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.max = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.max.apply(g, arguments);
- };
-
- /**
- * mean() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.mean = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.mean.apply(g, arguments);
- };
-
- /**
- * min() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.min = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.min.apply(g, arguments);
- };
-
- /**
- * not() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.not = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.not.apply(g, arguments);
- };
-
- /**
- * optional() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.optional = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.optional.apply(g, arguments);
- };
-
- /**
- * or() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.or = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.or.apply(g, arguments);
- };
-
- /**
- * order() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.order = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.order.apply(g, arguments);
- };
-
- /**
- * otherV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.otherV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.otherV.apply(g, arguments);
- };
-
- /**
- * out() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.out = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.out.apply(g, arguments);
- };
-
- /**
- * outE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.outE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.outE.apply(g, arguments);
- };
-
- /**
- * outV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.outV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.outV.apply(g, arguments);
- };
-
- /**
- * path() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.path = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.path.apply(g, arguments);
- };
-
- /**
- * project() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.project = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.project.apply(g, arguments);
- };
-
- /**
- * properties() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.properties = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.properties.apply(g, arguments);
- };
-
- /**
- * property() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.property = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.property.apply(g, arguments);
- };
-
- /**
- * propertyMap() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.propertyMap = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.propertyMap.apply(g, arguments);
- };
-
- /**
- * range() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.range = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.range.apply(g, arguments);
- };
-
- /**
- * repeat() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.repeat = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.repeat.apply(g, arguments);
- };
-
- /**
- * sack() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.sack = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.sack.apply(g, arguments);
- };
-
- /**
- * sample() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.sample = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.sample.apply(g, arguments);
- };
-
- /**
- * select() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.select = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.select.apply(g, arguments);
- };
-
- /**
- * sideEffect() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.sideEffect = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.sideEffect.apply(g, arguments);
- };
-
- /**
- * simplePath() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.simplePath = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.simplePath.apply(g, arguments);
- };
-
- /**
- * start() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.start = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.start.apply(g, arguments);
- };
-
- /**
- * store() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.store = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.store.apply(g, arguments);
- };
-
- /**
- * subgraph() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.subgraph = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.subgraph.apply(g, arguments);
- };
-
- /**
- * sum() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.sum = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.sum.apply(g, arguments);
- };
-
- /**
- * tail() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.tail = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.tail.apply(g, arguments);
- };
-
- /**
- * timeLimit() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.timeLimit = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.timeLimit.apply(g, arguments);
- };
-
- /**
- * times() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.times = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.times.apply(g, arguments);
- };
-
- /**
- * to() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.to = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.to.apply(g, arguments);
- };
-
- /**
- * toE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.toE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.toE.apply(g, arguments);
- };
-
- /**
- * toV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.toV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.toV.apply(g, arguments);
- };
-
- /**
- * tree() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.tree = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.tree.apply(g, arguments);
- };
-
- /**
- * unfold() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.unfold = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.unfold.apply(g, arguments);
- };
-
- /**
- * union() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.union = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.union.apply(g, arguments);
- };
-
- /**
- * until() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.until = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.until.apply(g, arguments);
- };
-
- /**
- * value() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.value = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.value.apply(g, arguments);
- };
-
- /**
- * valueMap() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.valueMap = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.valueMap.apply(g, arguments);
- };
-
- /**
- * values() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.values = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.values.apply(g, arguments);
- };
-
- /**
- * where() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.where = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.where.apply(g, arguments);
- };
-
- function loadModule(moduleName) {
- if (typeof require !== 'undefined') {
- return require(moduleName);
- }
- if (typeof load !== 'undefined') {
- var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
- this.__dependencies = this.__dependencies || {};
- return this.__dependencies[path] = (this.__dependencies[path] || load(path));
- }
- throw new Error('No module loader was found');
- }
-
- var toExport = {
- GraphTraversal: GraphTraversal,
- GraphTraversalSource: GraphTraversalSource,
- statics: statics
- };
- if (typeof module !== 'undefined') {
- // CommonJS
- module.exports = toExport;
- return;
- }
- // Nashorn and rest
- return toExport;
-}).call(this);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
deleted file mode 100644
index 9709a4f..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineTraversalModule() {
- "use strict";
-
- function Traversal(graph, traversalStrategies, bytecode) {
- this.graph = graph;
- this.traversalStrategies = traversalStrategies;
- this.bytecode = bytecode;
- this.traversers = null;
- this.sideEffects = null;
- }
-
- /** @returns {Bytecode} */
- Traversal.prototype.getBytecode = function () {
- return this.bytecode;
- };
-
- /** @param {Function} callback */
- Traversal.prototype.list = function (callback) {
- var self = this;
- this.traversalStrategies.applyStrategies(this, function (err) {
- if (err) {
- return callback(err);
- }
- callback(err, self.traversers);
- });
- };
-
- /** @param {Function} callback */
- Traversal.prototype.one = function (callback) {
- this.list(function (err, result) {
- callback(err, result && result.length > 0 ? result[0] : null);
- });
- };
-
- /**
- * Returns the Bytecode JSON representation of the traversal
- * @returns {String}
- */
- Traversal.prototype.toString = function () {
- return this.bytecode.toString();
- };
-
- /**
- * Represents an operation.
- * @constructor
- */
- function P(operator, value, other) {
- this.operator = operator;
- this.value = value;
- this.other = other;
- }
-
- /**
- * Returns the string representation of the instance.
- * @returns {string}
- */
- P.prototype.toString = function () {
- if (this.other === undefined) {
- return this.operator + '(' + this.value + ')';
- }
- return this.operator + '(' + this.value + ', ' + this.other + ')';
- };
-
- function createP(operator, args) {
- args.unshift(null, operator);
- return new (Function.prototype.bind.apply(P, args));
- }
-
- /** @param {...Object} args */
- P.between = function (args) {
- return createP('between', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.eq = function (args) {
- return createP('eq', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.gt = function (args) {
- return createP('gt', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.gte = function (args) {
- return createP('gte', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.inside = function (args) {
- return createP('inside', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.lt = function (args) {
- return createP('lt', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.lte = function (args) {
- return createP('lte', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.neq = function (args) {
- return createP('neq', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.not = function (args) {
- return createP('not', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.outside = function (args) {
- return createP('outside', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.test = function (args) {
- return createP('test', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.within = function (args) {
- return createP('within', parseArgs.apply(null, arguments));
- };
-
- /** @param {...Object} args */
- P.without = function (args) {
- return createP('without', parseArgs.apply(null, arguments));
- };
-
- P.prototype.and = function (arg) {
- return new P('and', this, arg);
- };
-
- P.prototype.or = function (arg) {
- return new P('or', this, arg);
- };
-
- function Traverser(object, bulk) {
- this.object = object;
- this.bulk = bulk == undefined ? 1 : bulk;
- }
-
- function TraversalSideEffects() {
-
- }
-
- /**
- * Creates a new instance of TraversalStrategies.
- * @param {TraversalStrategies} [traversalStrategies]
- * @constructor
- */
- function TraversalStrategies(traversalStrategies) {
- /** @type {Array<TraversalStrategy>} */
- this.strategies = traversalStrategies ? traversalStrategies.strategies : [];
- }
-
- /** @param {TraversalStrategy} strategy */
- TraversalStrategies.prototype.addStrategy = function (strategy) {
- this.strategies.push(strategy);
- };
-
- /**
- * @param {Traversal} traversal
- * @param {Function} callback
- */
- TraversalStrategies.prototype.applyStrategies = function (traversal, callback) {
- eachSeries(this.strategies, function eachStrategy(s, next) {
- s.apply(traversal, next);
- }, callback);
- };
-
- /**
- * @abstract
- * @constructor
- */
- function TraversalStrategy() {
-
- }
-
- /**
- * @abstract
- * @param {Traversal} traversal
- * @param {Function} callback
- */
- TraversalStrategy.prototype.apply = function (traversal, callback) {
-
- };
-
- /**
- * Creates a new instance of Bytecode
- * @param {Bytecode} [toClone]
- * @constructor
- */
- function Bytecode(toClone) {
- this._bindings = {};
- if (!toClone) {
- this.sourceInstructions = [];
- this.stepInstructions = [];
- }
- else {
- this.sourceInstructions = toClone.sourceInstructions.slice(0);
- this.stepInstructions = toClone.sourceInstructions.slice(0);
- }
- }
-
- /**
- * Adds a new source instructions
- * @param {String} name
- * @param {Array} values
- * @returns {Bytecode}
- */
- Bytecode.prototype.addSource = function (name, values) {
- if (name === undefined) {
- throw new Error('Name is not defined');
- }
- var instruction = new Array(values.length + 1);
- instruction[0] = name;
- for (var i = 0; i < values.length; ++i) {
- instruction[i + 1] = this._convertToArgument(values[i]);
- }
- this.sourceInstructions.push(this._generateInstruction(name, values));
- return this;
- };
-
- /**
- * Adds a new step instructions
- * @param {String} name
- * @param {Array} values
- * @returns {Bytecode}
- */
- Bytecode.prototype.addStep = function (name, values) {
- if (name === undefined) {
- throw new Error('Name is not defined');
- }
- this.stepInstructions.push(this._generateInstruction(name, values));
- return this;
- };
-
- Bytecode.prototype._generateInstruction = function (name, values) {
- var instruction = new Array(values.length + 1);
- instruction[0] = name;
- for (var i = 0; i < values.length; ++i) {
- instruction[i + 1] = this._convertToArgument(values[i]);
- }
- return instruction;
- };
-
- /**
- * Returns the JSON representation of the source and step instructions
- * @returns {String}
- */
- Bytecode.prototype.toString = function () {
- return (
- (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
- (this.stepInstructions.length > 0 ? JSON.stringify(this.stepInstructions) : '')
- );
- };
-
- Bytecode.prototype._convertToArgument = function (value) {
- return value;
- };
-
- function toEnum(typeName, keys) {
- var result = {};
- keys.split(' ').forEach(function (k) {
- if (k === k.toUpperCase()) {
- k = k.toLowerCase();
- }
- result[k] = new EnumValue(typeName, k);
- });
- return result;
- }
-
- function EnumValue(typeName, elementName) {
- this.typeName = typeName;
- this.elementName = elementName;
- }
-
- // Utility functions
- /** @returns {Array} */
- function parseArgs() {
- return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
- }
-
- /**
- * @param {Array} arr
- * @param {Function} fn
- * @param {Function} [callback]
- */
- function eachSeries(arr, fn, callback) {
- if (!Array.isArray(arr)) {
- throw new TypeError('First parameter is not an Array');
- }
- callback = callback || noop;
- var length = arr.length;
- if (length === 0) {
- return callback();
- }
- var sync;
- var index = 1;
- fn(arr[0], next);
- if (sync === undefined) {
- sync = false;
- }
-
- function next(err) {
- if (err) {
- return callback(err);
- }
- if (index >= length) {
- return callback();
- }
- if (sync === undefined) {
- sync = true;
- }
- if (sync) {
- return process.nextTick(function () {
- fn(arr[index++], next);
- });
- }
- fn(arr[index++], next);
- }
- }
-
- function inherits(ctor, superCtor) {
- ctor.super_ = superCtor;
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- }
-
- var toExport = {
- Bytecode: Bytecode,
- EnumValue: EnumValue,
- inherits: inherits,
- P: P,
- parseArgs: parseArgs,
- Traversal: Traversal,
- TraversalSideEffects: TraversalSideEffects,
- TraversalStrategies: TraversalStrategies,
- TraversalStrategy: TraversalStrategy,
- Traverser: Traverser,
- barrier: toEnum('Barrier', 'normSack'),
- cardinality: toEnum('Cardinality', 'list set single'),
- column: toEnum('Column', 'keys values'),
- direction: toEnum('Direction', 'BOTH IN OUT'),
- operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
- order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
- pick: toEnum('Pick', 'any none'),
- pop: toEnum('Pop', 'all first last'),
- scope: toEnum('Scope', 'global local'),
- t: toEnum('T', 'id key label value')
- };
- if (typeof module !== 'undefined') {
- // CommonJS
- module.exports = toExport;
- return;
- }
- // Nashorn and rest
- return toExport;
-}).call(this);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
deleted file mode 100644
index cd408ae..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/graph.js
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineGraphModule() {
- "use strict";
-
- var gt = loadModule.call(this, '../process/graph-traversal.js');
- var t = loadModule.call(this, '../process/traversal.js');
- var inherits = t.inherits;
-
- function Graph() {
-
- }
-
- /**
- * Returns the graph traversal source.
- * @returns {GraphTraversalSource}
- */
- Graph.prototype.traversal = function () {
- return new gt.GraphTraversalSource(this, new t.TraversalStrategies());
- };
-
- Graph.prototype.toString = function () {
- return 'graph[empty]';
- };
-
- function Element(id, label) {
- this.id = id;
- this.label = label;
- }
-
- /**
- * Compares this instance to another and determines if they can be considered as equal.
- * @param {Element} other
- * @returns {boolean}
- */
- Element.prototype.equals = function (other) {
- return (other instanceof Element) && this.id === other.id;
- };
-
- function Vertex(id, label, properties) {
- Element.call(this, id, label);
- this.properties = properties;
- }
-
- Vertex.prototype.toString = function () {
- return 'v[' + this.id + ']';
- };
-
- inherits(Vertex, Element);
-
- function Edge(id, outV, label, inV, properties) {
- Element.call(this, id, label);
- this.outV = outV;
- this.inV = inV;
- this.properties = {};
- (function adaptProperties(self) {
- if (properties) {
- var keys = Object.keys(properties);
- for (var i = 0; i < keys.length; i++) {
- var k = keys[i];
- self.properties[k] = properties[k].value;
- }
- }
- })(this);
- }
-
- inherits(Edge, Element);
-
- Edge.prototype.toString = function () {
- return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
- };
-
- function VertexProperty(id, label, value, properties) {
- Element.call(this, id, label);
- this.value = value;
- this.key = this.label;
- this.properties = properties;
- }
-
- inherits(VertexProperty, Element);
-
- VertexProperty.prototype.toString = function () {
- return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']';
- };
-
- function Property(key, value) {
- this.key = key;
- this.value = value;
- }
-
- Property.prototype.toString = function () {
- return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']';
- };
-
- Property.prototype.equals = function (other) {
- return (other instanceof Property) && this.key === other.key && this.value === other.value;
- };
-
- /**
- * Represents a walk through a graph as defined by a traversal.
- * @param {Array} labels
- * @param {Array} objects
- * @constructor
- */
- function Path(labels, objects) {
- this.labels = labels;
- this.objects = objects;
- }
-
- function loadModule(moduleName) {
- if (typeof require !== 'undefined') {
- return require(moduleName);
- }
- if (typeof load !== 'undefined') {
- var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
- this.__dependencies = this.__dependencies || {};
- return this.__dependencies[path] = (this.__dependencies[path] || load(path));
- }
- throw new Error('No module loader was found');
- }
-
- var toExport = {
- Edge: Edge,
- Graph: Graph,
- Path: Path,
- Property: Property,
- Vertex: Vertex,
- VertexProperty: VertexProperty
- };
- if (typeof module !== 'undefined') {
- // CommonJS
- module.exports = toExport;
- return;
- }
- // Nashorn and rest
- return toExport;
-}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
deleted file mode 100644
index 31652da..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/structure/io/graph-serializer.js
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function graphSerializerModule() {
- "use strict";
-
- var t = loadModule.call(this, '../../process/traversal.js');
- var g = loadModule.call(this, '../graph.js');
-
- /**
- * A type serializer
- * @typedef {Object} Serializer
- * @property {Function} serialize
- * @property {Function} deserialize
- * @property {Function} [canBeUsedFor]
- */
-
- /**
- * @const
- * @private
- */
- var valueKey = '@value';
-
- /**
- * @const
- * @private
- */
- var typeKey = '@type';
-
- var deserializers = {
- 'g:Traverser': TraverserSerializer,
- 'g:Int32': NumberSerializer,
- 'g:Int64': NumberSerializer,
- 'g:Float': NumberSerializer,
- 'g:Double': NumberSerializer,
- 'g:Vertex': VertexSerializer,
- 'g:Edge': EdgeSerializer,
- 'g:VertexProperty': VertexPropertySerializer,
- 'g:Property': PropertySerializer,
- 'g:Path': PathSerializer
- };
-
- var serializers = [
- NumberSerializer,
- BytecodeSerializer,
- TraverserSerializer,
- PSerializer,
- LambdaSerializer,
- EnumSerializer
- ];
-
- /**
- * GraphSON Writer
- * @param {Object} [options]
- * @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and
- * serializer instances as values, ie: { 'g:Int64': longSerializer }.
- * @constructor
- */
- function GraphSONWriter(options) {
- this._options = options || {};
- // Create instance of the default serializers
- this._serializers = serializers.map(function (serializerConstructor) {
- var s = new serializerConstructor();
- s.writer = this;
- return s;
- }, this);
- var customSerializers = this._options.serializers || {};
- Object.keys(customSerializers).forEach(function (key) {
- var s = customSerializers[key];
- if (!s.serialize) {
- return;
- }
- s.writer = this;
- // Insert custom serializers first
- this._serializers.unshift(s);
- }, this);
- }
-
- GraphSONWriter.prototype.adaptObject = function (value) {
- var s;
- if (Array.isArray(value)) {
- return value.map(function (item) {
- return this.adaptObject(item);
- }, this);
- }
- for (var i = 0; i < this._serializers.length; i++) {
- var currentSerializer = this._serializers[i];
- if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) {
- s = currentSerializer;
- break;
- }
- }
- if (s) {
- return s.serialize(value);
- }
- // Default (strings / objects / ...)
- return value;
- };
-
- /**
- * Returns the GraphSON representation of the provided object instance.
- * @param {Object} obj
- * @returns {String}
- */
- GraphSONWriter.prototype.write = function (obj) {
- return JSON.stringify(this.adaptObject(obj));
- };
-
- /**
- * GraphSON Reader
- * @param {Object} [options]
- * @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and
- * deserializer instances as values, ie: { 'g:Int64': longSerializer }.
- * @constructor
- */
- function GraphSONReader(options) {
- this._options = options || {};
- this._deserializers = {};
- Object.keys(deserializers).forEach(function (typeName) {
- var serializerConstructor = deserializers[typeName];
- var s = new serializerConstructor();
- s.reader = this;
- this._deserializers[typeName] = s;
- }, this);
- if (this._options.serializers) {
- var customSerializers = this._options.serializers || {};
- Object.keys(customSerializers).forEach(function (key) {
- var s = customSerializers[key];
- if (!s.deserialize) {
- return;
- }
- s.reader = this;
- this._deserializers[key] = s;
- }, this);
- }
- }
-
- GraphSONReader.prototype.read = function (obj) {
- if (obj === undefined) {
- return undefined;
- }
- if (Array.isArray(obj)) {
- return obj.map(function mapEach(item) {
- return this.read(item);
- }, this);
- }
- var type = obj[typeKey];
- if (type) {
- var d = this._deserializers[type];
- if (d) {
- // Use type serializer
- return d.deserialize(obj);
- }
- return obj[valueKey];
- }
- if (obj && typeof obj === 'object' && obj.constructor === Object) {
- return this._deserializeObject(obj);
- }
- // Default (for boolean, number and other scalars)
- return obj;
- };
-
- GraphSONReader.prototype._deserializeObject = function (obj) {
- var keys = Object.keys(obj);
- var result = {};
- for (var i = 0; i < keys.length; i++) {
- result[keys[i]] = this.read(obj[keys[i]]);
- }
- return result;
- };
-
- function NumberSerializer() {
-
- }
-
- NumberSerializer.prototype.serialize = function (item) {
- return item;
- };
-
- NumberSerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return parseFloat(value);
- };
-
- NumberSerializer.prototype.canBeUsedFor = function (value) {
- return (typeof value === 'number');
- };
-
- function BytecodeSerializer() {
-
- }
-
- BytecodeSerializer.prototype.serialize = function (item) {
- var bytecode = item;
- if (item instanceof t.Traversal) {
- bytecode = item.getBytecode();
- }
- var result = {};
- result[typeKey] = 'g:Bytecode';
- var resultValue = result[valueKey] = {};
- var sources = this._serializeInstructions(bytecode.sourceInstructions);
- if (sources) {
- resultValue['source'] = sources;
- }
- var steps = this._serializeInstructions(bytecode.stepInstructions);
- if (steps) {
- resultValue['step'] = steps;
- }
- return result;
- };
-
- BytecodeSerializer.prototype._serializeInstructions = function (instructions) {
- if (instructions.length === 0) {
- return null;
- }
- var result = new Array(instructions.length);
- result[0] = instructions[0];
- for (var i = 1; i < instructions.length; i++) {
- result[i] = this.writer.adaptObject(instructions[i]);
- }
- return result;
- };
-
- BytecodeSerializer.prototype.canBeUsedFor = function (value) {
- return (value instanceof t.Bytecode) || (value instanceof t.Traversal);
- };
-
- function PSerializer() {
-
- }
-
- /** @param {P} item */
- PSerializer.prototype.serialize = function (item) {
- var result = {};
- result[typeKey] = 'g:P';
- var resultValue = result[valueKey] = {
- 'predicate': item.operator
- };
- if (item.other == undefined) {
- resultValue['value'] = this.writer.adaptObject(item.value);
- }
- else {
- resultValue['value'] = [ this.writer.adaptObject(item.value), this.writer.adaptObject(item.other) ];
- }
- return result;
- };
-
- PSerializer.prototype.canBeUsedFor = function (value) {
- return (value instanceof t.P);
- };
-
- function LambdaSerializer() {
-
- }
-
- /** @param {Function} item */
- LambdaSerializer.prototype.serialize = function (item) {
- var result = {};
- result[typeKey] = 'g:Lambda';
- result[valueKey] = {
- 'arguments': item.length,
- 'language': 'gremlin-javascript',
- 'script': item.toString()
- };
- return result;
- };
-
- LambdaSerializer.prototype.canBeUsedFor = function (value) {
- return (typeof value === 'function');
- };
-
- function EnumSerializer() {
-
- }
-
- /** @param {EnumValue} item */
- EnumSerializer.prototype.serialize = function (item) {
- var result = {};
- result[typeKey] = 'g:' + item.typeName;
- result[valueKey] = item.elementName;
- return result;
- };
-
- EnumSerializer.prototype.canBeUsedFor = function (value) {
- return value && value.typeName && value instanceof t.EnumValue;
- };
-
- function TraverserSerializer() {
-
- }
-
- /** @param {Traverser} item */
- TraverserSerializer.prototype.serialize = function (item) {
- var result = {};
- result[typeKey] = 'g:Traverser';
- result[valueKey] = {
- 'value': this.writer.adaptObject(item.object),
- 'bulk': this.writer.adaptObject(item.bulk)
- };
- return result;
- };
-
- TraverserSerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return new t.Traverser(this.reader.read(value['value']), this.reader.read(value['bulk']));
- };
-
- TraverserSerializer.prototype.canBeUsedFor = function (value) {
- return (value instanceof t.Traverser);
- };
-
- function VertexSerializer() {
-
- }
-
- VertexSerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
- };
-
- function VertexPropertySerializer() {
-
- }
-
- VertexPropertySerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return new g.VertexProperty(
- this.reader.read(value['id']),
- value['label'],
- this.reader.read(value['value']),
- this.reader.read(value['properties'])
- );
- };
-
- function PropertySerializer() {
-
- }
-
- PropertySerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return new g.Property(
- value['key'],
- this.reader.read(value['value']));
- };
-
- function EdgeSerializer() {
-
- }
-
- EdgeSerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- return new g.Edge(
- this.reader.read(value['id']),
- this.reader.read(value['outV']),
- value['label'],
- this.reader.read(value['inV']),
- this.reader.read(value['properties'])
- );
- };
-
- function PathSerializer() {
-
- }
-
- PathSerializer.prototype.deserialize = function (obj) {
- var value = obj[valueKey];
- var objects = value['objects'].map(function objectMapItem(o) {
- return this.reader.read(o);
- }, this);
- return new g.Path(this.reader.read(value['labels']), objects);
- };
-
- function loadModule(moduleName) {
- if (typeof require !== 'undefined') {
- return require(moduleName);
- }
- if (typeof load !== 'undefined') {
- var path = new java.io.File(__DIR__ + moduleName).getCanonicalPath();
- this.__dependencies = this.__dependencies || {};
- return this.__dependencies[path] = (this.__dependencies[path] || load(path));
- }
- throw new Error('No module loader was found');
- }
-
- var toExport = {
- GraphSONWriter: GraphSONWriter,
- GraphSONReader: GraphSONReader
- };
- if (typeof module !== 'undefined') {
- // CommonJS
- module.exports = toExport;
- return;
- }
- // Nashorn and rest
- return toExport;
-}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
new file mode 100644
index 0000000..df813ad
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var assert = require('assert');
+var Bytecode = require('../../lib/process/bytecode');
+var DriverRemoteConnection = require('../../lib/driver/driver-remote-connection');
+var graphModule = require('../../lib/structure/graph');
+
+var connection;
+
+describe('DriverRemoteConnection', function () {
+ before(function () {
+ connection = new DriverRemoteConnection('ws://localhost:45950/gremlin');
+ return connection.open();
+ });
+ after(function () {
+ return connection.close();
+ });
+ describe('#submit()', function () {
+ it('should send the request and parse the response', function () {
+ return connection.submit(new Bytecode().addStep('addV', [ 'person' ]).addStep('property', [ 'name', 'marko']))
+ .then(function (response) {
+ assert.ok(response);
+ assert.ok(response.traversers);
+ assert.strictEqual(response.traversers.length, 1);
+ assert.ok(response.traversers[0].object instanceof graphModule.Vertex);
+ });
+ });
+ it('should send the request with syntax error and parse the response error', function () {
+ return connection.submit(new Bytecode().addStep('SYNTAX_ERROR'))
+ .catch(function (err) {
+ assert.ok(err);
+ assert.ok(err.message.indexOf('599') > 0);
+ });
+ });
+ });
+});
+
+function delay(ms) {
+ return new Promise(function (resolve) {
+ setTimeout(resolve, ms);
+ });
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
new file mode 100644
index 0000000..90afced
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var assert = require('assert');
+var graphModule = require('../../lib/structure/graph');
+var Graph = graphModule.Graph;
+var Vertex = graphModule.Vertex;
+var utils = require('../../lib/utils');
+var t = require('../../lib/process/traversal');
+var TraversalStrategies = require('../../lib/process/traversal-strategy').TraversalStrategies;
+var DriverRemoteConnection = require('../../lib/driver/driver-remote-connection');
+
+var connection;
+
+describe('Traversal', function () {
+ before(function () {
+ connection = new DriverRemoteConnection('ws://localhost:45950/gremlin');
+ return connection.open();
+ });
+ after(function () {
+ return connection.close();
+ });
+ describe('#toList()', function () {
+ it('should submit the traversal and return a list', function () {
+ var g = new Graph().traversal().withRemote(connection);
+ return g.addV('user').toList().then(function (list) {
+ assert.ok(list);
+ assert.strictEqual(list.length, 1);
+ assert.ok(list[0] instanceof Vertex);
+ });
+ });
+ });
+ describe('#next()', function () {
+ it('should submit the traversal and return an iterator', function () {
+ var g = new Graph().traversal().withRemote(connection);
+ var traversal = g.V().count();
+ return traversal.next()
+ .then(function (item) {
+ assert.ok(item);
+ assert.strictEqual(item.done, false);
+ assert.strictEqual(typeof item.value, 'number');
+ return traversal.next();
+ }).then(function (item) {
+ assert.ok(item);
+ assert.strictEqual(item.done, true);
+ assert.strictEqual(item.value, null);
+ });
+ });
+ });
+});
\ No newline at end of file
[04/47] tinkerpop git commit: Update Javascript GLV
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
new file mode 100644
index 0000000..3864a4a
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/exports-test.js
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var assert = require('assert');
+var glvModule = require('../../');
+
+describe('API', function () {
+ it('should export fields under process', function () {
+ assert.ok(glvModule);
+ assert.ok(glvModule.process);
+ assert.strictEqual(typeof glvModule.process.Bytecode, 'function');
+ assert.strictEqual(typeof glvModule.process.EnumValue, 'function');
+ assert.strictEqual(typeof glvModule.process.P, 'function');
+ assert.strictEqual(typeof glvModule.process.Traversal, 'function');
+ assert.strictEqual(typeof glvModule.process.TraversalSideEffects, 'function');
+ assert.strictEqual(typeof glvModule.process.TraversalStrategies, 'function');
+ assert.strictEqual(typeof glvModule.process.TraversalStrategy, 'function');
+ assert.strictEqual(typeof glvModule.process.Traverser, 'function');
+ assert.strictEqual(typeof glvModule.process.GraphTraversal, 'function');
+ assert.strictEqual(typeof glvModule.process.GraphTraversalSource, 'function');
+ assert.strictEqual(typeof glvModule.process.barrier, 'object');
+ assert.strictEqual(typeof glvModule.process.cardinality, 'object');
+ assert.strictEqual(typeof glvModule.process.column, 'object');
+ assert.strictEqual(typeof glvModule.process.direction, 'object');
+ assert.strictEqual(typeof glvModule.process.direction.both, 'object');
+ assert.strictEqual(glvModule.process.direction.both.elementName, 'BOTH');
+ assert.strictEqual(typeof glvModule.process.operator, 'object');
+ assert.strictEqual(typeof glvModule.process.order, 'object');
+ assert.strictEqual(typeof glvModule.process.pop, 'object');
+ assert.strictEqual(typeof glvModule.process.scope, 'object');
+ assert.strictEqual(typeof glvModule.process.t, 'object');
+ assert.ok(glvModule.process.statics);
+ });
+ it('should expose fields under structure', function () {
+ assert.ok(glvModule.structure);
+ assert.ok(glvModule.structure.io);
+ assert.strictEqual(typeof glvModule.structure.io.GraphSONReader, 'function');
+ assert.strictEqual(typeof glvModule.structure.io.GraphSONWriter, 'function');
+ assert.strictEqual(typeof glvModule.structure.Edge, 'function');
+ assert.strictEqual(typeof glvModule.structure.Graph, 'function');
+ assert.strictEqual(typeof glvModule.structure.Path, 'function');
+ assert.strictEqual(typeof glvModule.structure.Property, 'function');
+ assert.strictEqual(typeof glvModule.structure.Vertex, 'function');
+ assert.strictEqual(typeof glvModule.structure.VertexProperty, 'function');
+ });
+ it('should expose fields under driver', function () {
+ assert.ok(glvModule.driver);
+ assert.strictEqual(typeof glvModule.driver.RemoteConnection, 'function');
+ assert.strictEqual(typeof glvModule.driver.RemoteStrategy, 'function');
+ assert.strictEqual(typeof glvModule.driver.RemoteTraversal, 'function');
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
new file mode 100644
index 0000000..ed5beb3
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var assert = require('assert');
+var graph = require('../../lib/structure/graph');
+var t = require('../../lib/process/traversal.js');
+var gs = require('../../lib/structure/io/graph-serializer.js');
+var GraphSONReader = gs.GraphSONReader;
+var GraphSONWriter = gs.GraphSONWriter;
+var P = t.P;
+
+describe('GraphSONReader', function () {
+ it('should parse GraphSON int32, float and double to Number from GraphSON', function () {
+ var reader = new GraphSONReader();
+ [
+ [ 'g:Int32', 31 ],
+ [ 'g:Float', 31.3],
+ [ 'g:Double', 31.2]
+ ].forEach(function (item) {
+ var result = reader.read({
+ "@type": item[0],
+ "@value": item[1]
+ });
+ assert.strictEqual(typeof result, 'number');
+ assert.strictEqual(result, item[1]);
+ });
+ });
+ it('should parse vertices from GraphSON', function () {
+ var obj = {
+ "@type":"g:Vertex", "@value":{"id":{"@type":"g:Int32","@value":1},"label":"person",
+ "properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"marko"}],
+ "age":[{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29}}]}}};
+ var reader = new GraphSONReader(obj);
+ var result = reader.read(obj);
+ assert.ok(result instanceof graph.Vertex);
+ assert.strictEqual(result.label, 'person');
+ assert.strictEqual(typeof result.id, 'number');
+ assert.ok(result.properties);
+ assert.ok(result.properties['name']);
+ assert.strictEqual(result.properties['name'].length, 1);
+ assert.strictEqual(result.properties['name'][0].value, 'marko');
+ assert.ok(result.properties['age']);
+ assert.strictEqual(result.properties['age'].length, 1);
+ assert.strictEqual(result.properties['age'][0].value, 29);
+ });
+ it('should parse paths from GraphSON', function () {
+ var obj = {"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[
+ {
+ "@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person",
+ "properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},
+ "value":"marko","label":"name"}}],"age":[{
+ "@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":1},
+ "value":{"@type":"g:Int32","@value":29},"label":"age"}}]}}},
+ {
+ "@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":3},"label":"software",
+ "properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":4},
+ "value":"lop","label":"name"}}],
+ "lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},
+ "value":"java","label":"lang"}}]}}},
+ "lop"]}};
+ var reader = new GraphSONReader(obj);
+ var result = reader.read(obj);
+ assert.ok(result);
+ assert.ok(result.objects);
+ assert.ok(result.labels);
+ assert.strictEqual(result.objects[2], 'lop');
+ assert.ok(result.objects[0] instanceof graph.Vertex);
+ assert.ok(result.objects[1] instanceof graph.Vertex);
+ assert.strictEqual(result.objects[0].label, 'person');
+ assert.strictEqual(result.objects[1].label, 'software');
+ });
+});
+describe('GraphSONWriter', function () {
+ it('should write numbers', function () {
+ var writer = new GraphSONWriter();
+ assert.strictEqual(writer.write(2), '2');
+ });
+ it('should write boolean values', function () {
+ var writer = new GraphSONWriter();
+ assert.strictEqual(writer.write(true), 'true');
+ assert.strictEqual(writer.write(false), 'false');
+ });
+ it('should write P', function () {
+ var writer = new GraphSONWriter();
+ var expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[
+ {"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},
+ {"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},
+ {"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}});
+ assert.strictEqual(writer.write(P.lt("b").or(P.gt("c")).and(P.neq("d"))), expected);
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
new file mode 100644
index 0000000..c5271c9
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var assert = require('assert');
+var graph = require('../../lib/structure/graph');
+var utils = require('../../lib/utils');
+var t = require('../../lib/process/traversal');
+var TraversalStrategies = require('../../lib/process/traversal-strategy').TraversalStrategies;
+
+describe('Traversal', function () {
+ describe('#getByteCode()', function () {
+ it('should add steps for with a string parameter', function () {
+ var g = new graph.Graph().traversal();
+ var bytecode = g.V().out('created').getBytecode();
+ assert.ok(bytecode);
+ assert.strictEqual(bytecode.sourceInstructions.length, 0);
+ assert.strictEqual(bytecode.stepInstructions.length, 2);
+ assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
+ assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
+ assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
+ });
+ it('should add steps with an enum value', function () {
+ var g = new graph.Graph().traversal();
+ var bytecode = g.V().order().by('age', t.order.decr).getBytecode();
+ assert.ok(bytecode);
+ assert.strictEqual(bytecode.sourceInstructions.length, 0);
+ assert.strictEqual(bytecode.stepInstructions.length, 3);
+ assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
+ assert.strictEqual(bytecode.stepInstructions[1][0], 'order');
+ assert.strictEqual(bytecode.stepInstructions[2][0], 'by');
+ assert.strictEqual(bytecode.stepInstructions[2][1], 'age');
+ assert.strictEqual(typeof bytecode.stepInstructions[2][2], 'object');
+ assert.strictEqual(bytecode.stepInstructions[2][2].typeName, 'Order');
+ assert.strictEqual(bytecode.stepInstructions[2][2].elementName, 'decr');
+ });
+ });
+ describe('#next()', function () {
+ it('should apply the strategies and return a Promise with the iterator item', function () {
+ var strategyMock = {
+ apply: function (traversal) {
+ traversal.traversers = [ new t.Traverser(1, 1), new t.Traverser(2, 1) ];
+ return utils.resolvedPromise();
+ }
+ };
+ var strategies = new TraversalStrategies();
+ strategies.addStrategy(strategyMock);
+ var traversal = new t.Traversal(null, strategies, null);
+ return traversal.next()
+ .then(function (item) {
+ assert.strictEqual(item.value, 1);
+ assert.strictEqual(item.done, false);
+ return traversal.next();
+ })
+ .then(function (item) {
+ assert.strictEqual(item.value, 2);
+ assert.strictEqual(item.done, false);
+ return traversal.next();
+ })
+ .then(function (item) {
+ assert.strictEqual(item.value, null);
+ assert.strictEqual(item.done, true);
+ return traversal.next();
+ });
+ });
+ });
+ describe('#toList()', function () {
+ it('should apply the strategies and return a Promise with an array', function () {
+ var strategyMock = {
+ apply: function (traversal) {
+ traversal.traversers = [ new t.Traverser('a', 1), new t.Traverser('b', 1) ];
+ return utils.resolvedPromise();
+ }
+ };
+ var strategies = new TraversalStrategies();
+ strategies.addStrategy(strategyMock);
+ var traversal = new t.Traversal(null, strategies, null);
+ return traversal.toList().then(function (list) {
+ assert.ok(list);
+ assert.deepEqual(list, [ 'a', 'b' ]);
+ });
+ });
+ it('should return an empty array when traversers is empty', function () {
+ var strategyMock = {
+ apply: function (traversal) {
+ traversal.traversers = [];
+ return utils.resolvedPromise();
+ }
+ };
+ var strategies = new TraversalStrategies();
+ strategies.addStrategy(strategyMock);
+ var traversal = new t.Traversal(null, strategies, null);
+ return traversal.toList().then(function (list) {
+ assert.ok(Array.isArray(list));
+ assert.strictEqual(list.length, 0);
+ });
+ })
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
deleted file mode 100644
index 858ed06..0000000
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/helper.js
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineHelperModule() {
- "use strict";
-
- var assert = {
- ok: function (condition, message) {
- if (!condition) {
- throw new AssertError(message || (condition + ' == true'));
- }
- },
- strictEqual: function (val1, val2, message) {
- if (val1 !== val2) {
- throw new AssertError(message || (val1 + ' === ' + val2));
- }
- }
- };
-
- function loadLibModule(moduleName) {
- if (typeof require !== 'undefined') {
- moduleName = '../lib/' + moduleName;
- return require(moduleName);
- }
- if (typeof load !== 'undefined' && typeof java !== 'undefined') {
- moduleName = __DIR__ + '../../../main/javascript/gremlin-javascript/' + moduleName;
- var path = new java.io.File(moduleName).getCanonicalPath();
- this.__dependencies = this.__dependencies || {};
- return this.__dependencies[path] = (this.__dependencies[path] || load(path));
- }
- throw new Error('No module loader was found');
- }
-
- function AssertError(message) {
- Error.call(this, message);
- this.stack = (new Error(message)).stack;
- if (typeof print !== 'undefined') {
- print(this.stack);
- }
- }
-
- inherits(AssertError, Error);
-
- function inherits(ctor, superCtor) {
- ctor.super_ = superCtor;
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- }
- var toExport = {
- assert: assert,
- loadLibModule: loadLibModule
- };
- if (typeof module !== 'undefined') {
- // CommonJS
- module.exports = toExport;
- return;
- }
- return toExport;
-}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
deleted file mode 100644
index b9265c7..0000000
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineTestCases() {
- "use strict";
-
- var helper = loadModule.call(this, './helper.js');
- var assert = helper.assert;
- var glvModule = helper.loadLibModule.call(this, './index.js');
-
- [
- function testExports() {
- assert.ok(glvModule);
-
- assert.ok(glvModule.process);
- assert.strictEqual(typeof glvModule.process.Bytecode, 'function');
- assert.strictEqual(typeof glvModule.process.EnumValue, 'function');
- assert.strictEqual(typeof glvModule.process.P, 'function');
- assert.strictEqual(typeof glvModule.process.Traversal, 'function');
- assert.strictEqual(typeof glvModule.process.TraversalSideEffects, 'function');
- assert.strictEqual(typeof glvModule.process.TraversalStrategies, 'function');
- assert.strictEqual(typeof glvModule.process.TraversalStrategy, 'function');
- assert.strictEqual(typeof glvModule.process.Traverser, 'function');
- assert.strictEqual(typeof glvModule.process.GraphTraversal, 'function');
- assert.strictEqual(typeof glvModule.process.GraphTraversalSource, 'function');
- assert.strictEqual(typeof glvModule.process.barrier, 'object');
- assert.strictEqual(typeof glvModule.process.cardinality, 'object');
- assert.strictEqual(typeof glvModule.process.column, 'object');
- assert.strictEqual(typeof glvModule.process.direction, 'object');
- assert.strictEqual(typeof glvModule.process.operator, 'object');
- assert.strictEqual(typeof glvModule.process.order, 'object');
- assert.strictEqual(typeof glvModule.process.pop, 'object');
- assert.strictEqual(typeof glvModule.process.scope, 'object');
- assert.strictEqual(typeof glvModule.process.t, 'object');
-
-
- assert.ok(glvModule.process.statics);
-
- assert.ok(glvModule.structure);
- assert.ok(glvModule.structure.io);
- assert.strictEqual(typeof glvModule.structure.io.GraphSONReader, 'function');
- assert.strictEqual(typeof glvModule.structure.io.GraphSONWriter, 'function');
- assert.strictEqual(typeof glvModule.structure.Edge, 'function');
- assert.strictEqual(typeof glvModule.structure.Graph, 'function');
- assert.strictEqual(typeof glvModule.structure.Path, 'function');
- assert.strictEqual(typeof glvModule.structure.Property, 'function');
- assert.strictEqual(typeof glvModule.structure.Vertex, 'function');
- assert.strictEqual(typeof glvModule.structure.VertexProperty, 'function');
-
- assert.ok(glvModule.driver);
- assert.strictEqual(typeof glvModule.driver.RemoteConnection, 'function');
- assert.strictEqual(typeof glvModule.driver.RemoteStrategy, 'function');
- assert.strictEqual(typeof glvModule.driver.RemoteTraversal, 'function');
- }
- ].forEach(function (testCase) {
- testCase.call(null);
- });
-
- function loadModule(moduleName) {
- if (typeof require !== 'undefined') {
- return require(moduleName);
- }
- if (typeof load !== 'undefined') {
- return load(__DIR__ + moduleName);
- }
- throw new Error('No module loader was found');
- }
-}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
deleted file mode 100644
index 418a9dd..0000000
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineTestCases() {
- "use strict";
-
- var helper = loadModule.call(this, './helper.js');
- var assert = helper.assert;
- var graph = helper.loadLibModule.call(this, 'structure/graph.js');
- var t = helper.loadLibModule.call(this, 'process/traversal.js');
- var gs = helper.loadLibModule.call(this, 'structure/io/graph-serializer.js');
- var GraphSONReader = gs.GraphSONReader;
- var GraphSONWriter = gs.GraphSONWriter;
- var P = t.P;
-
- [
- function testReadNumbers() {
- var reader = new GraphSONReader();
- [
- [{
- "@type": "g:Int32",
- "@value": 31
- }, 31],
- [{
- "@type": "g:Float",
- "@value": 31.3
- }, 31.3],
- [{
- "@type": "g:Double",
- "@value": 31.2
- }, 31.2]
- ].forEach(function (item) {
- var result = reader.read(item[0]);
- assert.strictEqual(result, item[1]);
- assert.strictEqual(typeof result, 'number');
- });
- },
- function testReadGraph() {
- var obj = {"@type":"g:Vertex", "@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","outE":{"created":[{"id":{"@type":"g:Int32","@value":9}, "inV":{"@type":"g:Int32","@value":3},"properties":{"weight":{"@type":"g:Double","@value":0.4}}}],"knows":[{"id":{"@type":"g:Int32","@value":7},"inV":{"@type":"g:Int32","@value":2},"properties":{"weight":{"@type":"g:Double","@value":0.5}}},{"id":{"@type":"g:Int32","@value":8},"inV":{"@type":"g:Int32","@value":4},"properties":{"weight":{"@type":"g:Double","@value":1.0}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"marko"}],"age":[{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29}}]}}};
- var reader = new GraphSONReader(obj);
- var result = reader.read(obj);
- assert.ok(result instanceof graph.Vertex);
- assert.strictEqual(result.label, 'person');
- assert.strictEqual(typeof result.id, 'number');
- },
- function testReadPath() {
- var obj = {"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[
- {"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},"value":"marko","label":"name"}}],"age":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29},"label":"age"}}]}}},
- {"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":3},"label":"software","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":4},"value":"lop","label":"name"}}],"lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},"value":"java","label":"lang"}}]}}},
- "lop"]}};
- var reader = new GraphSONReader(obj);
- var result = reader.read(obj);
- assert.ok(result);
- assert.ok(result.objects);
- assert.ok(result.labels);
- assert.strictEqual(result.objects[2], 'lop');
- assert.ok(result.objects[0] instanceof graph.Vertex);
- assert.ok(result.objects[1] instanceof graph.Vertex);
- assert.strictEqual(result.objects[0].label, 'person');
- assert.strictEqual(result.objects[1].label, 'software');
- },
- function testWriteNumber() {
- var writer = new GraphSONWriter();
- assert.strictEqual(writer.write(2), '2');
- },
- function testWriteBoolean() {
- var writer = new GraphSONWriter();
- assert.strictEqual(writer.write(true), 'true');
- assert.strictEqual(writer.write(false), 'false');
- },
- function testWriteP() {
- var writer = new GraphSONWriter();
- var expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[{"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},{"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},{"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}});
- assert.strictEqual(writer.write(P.lt("b").or(P.gt("c")).and(P.neq("d"))), expected);
- }
- ].forEach(function (testCase) {
- testCase.call(null);
- });
-
- function loadModule(moduleName) {
- if (typeof require !== 'undefined') {
- return require(moduleName);
- }
- if (typeof load !== 'undefined') {
- return load(__DIR__ + moduleName);
- }
- throw new Error('No module loader was found');
- }
-}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
deleted file mode 100644
index 1ec4253..0000000
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Jorge Bay Gondra
- */
-(function defineTestCases() {
- "use strict";
-
- var helper = loadModule.call(this, './helper.js');
- var assert = helper.assert;
- var graph = helper.loadLibModule.call(this, 'structure/graph.js');
- var t = helper.loadLibModule.call(this, 'process/traversal.js');
-
- [
- function testBytecode1() {
- var g = new graph.Graph().traversal();
- var bytecode = g.V().out('created').getBytecode();
- assert.ok(bytecode);
- assert.strictEqual(bytecode.sourceInstructions.length, 0);
- assert.strictEqual(bytecode.stepInstructions.length, 2);
- assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
- assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
- assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
- },
- function testBytecode2() {
- var g = new graph.Graph().traversal();
- var bytecode = g.V().order().by('age', t.order.decr).getBytecode();
- assert.ok(bytecode);
- assert.strictEqual(bytecode.sourceInstructions.length, 0);
- assert.strictEqual(bytecode.stepInstructions.length, 3);
- assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
- assert.strictEqual(bytecode.stepInstructions[1][0], 'order');
- assert.strictEqual(bytecode.stepInstructions[2][0], 'by');
- assert.strictEqual(bytecode.stepInstructions[2][1], 'age');
- assert.strictEqual(typeof bytecode.stepInstructions[2][2], 'object');
- assert.strictEqual(bytecode.stepInstructions[2][2].typeName, 'Order');
- assert.strictEqual(bytecode.stepInstructions[2][2].elementName, 'decr');
- }
- ].forEach(function (testCase) {
- testCase.call(null);
- });
-
- function loadModule(moduleName) {
- if (typeof require !== 'undefined') {
- return require(moduleName);
- }
- if (typeof load !== 'undefined') {
- return load(__DIR__ + moduleName);
- }
- throw new Error('No module loader was found');
- }
-}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9603d76..157b9bf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -322,6 +322,10 @@ limitations under the License.
<exclude>**/*.csproj</exclude>
<exclude>**/.vs/**</exclude>
<exclude>**/NuGet.Config</exclude>
+ <exclude>**/gremlin-javascript/node_modules/**</exclude>
+ <exclude>**/node/node_modules/**</exclude>
+ <exclude>**/node/node</exclude>
+ <exclude>**/npm-debug.log</exclude>
</excludes>
<licenses>
<license implementation="org.apache.rat.analysis.license.ApacheSoftwareLicense20"/>
[30/47] tinkerpop git commit: Vertex and Edge serialization
Posted by jo...@apache.org.
Vertex and Edge serialization
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e95b8eab
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e95b8eab
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e95b8eab
Branch: refs/heads/master
Commit: e95b8eabc2f7fdb7dd943d18905141e2e7746aa0
Parents: b9ca2ca
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Nov 28 12:50:37 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:16 2018 +0100
----------------------------------------------------------------------
.../lib/structure/io/graph-serializer.js | 42 ++++++++++++++++++--
1 file changed, 39 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e95b8eab/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
index 46d251e..ff3d72d 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
@@ -65,7 +65,9 @@ var serializers = [
TraverserSerializer,
PSerializer,
LambdaSerializer,
- EnumSerializer
+ EnumSerializer,
+ VertexSerializer,
+ EdgeSerializer
];
/**
@@ -237,7 +239,7 @@ BytecodeSerializer.prototype._serializeInstructions = function (instructions) {
}
var result = new Array(instructions.length);
result[0] = instructions[0];
- for (var i = 1; i < instructions.length; i++) {
+ for (var i = 0; i < instructions.length; i++) {
result[i] = this.writer.adaptObject(instructions[i]);
}
return result;
@@ -258,7 +260,7 @@ PSerializer.prototype.serialize = function (item) {
var resultValue = result[valueKey] = {
'predicate': item.operator
};
- if (item.other == undefined) {
+ if (item.other === undefined || item.other === null) {
resultValue['value'] = this.writer.adaptObject(item.value);
}
else {
@@ -340,6 +342,21 @@ VertexSerializer.prototype.deserialize = function (obj) {
return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
};
+/** @param {Vertex} item */
+VertexSerializer.prototype.serialize = function (item) {
+ var result = {};
+ result[typeKey] = 'g:Vertex';
+ result[valueKey] = {
+ 'id': this.writer.adaptObject(item.id),
+ 'label': item.label
+ };
+ return result;
+};
+
+VertexSerializer.prototype.canBeUsedFor = function (value) {
+ return (value instanceof g.Vertex);
+};
+
function VertexPropertySerializer() {
}
@@ -380,6 +397,25 @@ EdgeSerializer.prototype.deserialize = function (obj) {
);
};
+/** @param {Edge} item */
+EdgeSerializer.prototype.serialize = function (item) {
+ var result = {};
+ result[typeKey] = 'g:Edge';
+ result[valueKey] = {
+ 'id': this.writer.adaptObject(item.id),
+ 'label': item.label,
+ 'outV': this.writer.adaptObject(item.outV.id),
+ 'outVLabel': item.outV.label,
+ 'inV': this.writer.adaptObject(item.inV.id),
+ 'inVLabel': item.inV.label
+ };
+ return result;
+};
+
+EdgeSerializer.prototype.canBeUsedFor = function (value) {
+ return (value instanceof g.Edge);
+};
+
function PathSerializer() {
}
[20/47] tinkerpop git commit: Use cucumber-js
Posted by jo...@apache.org.
Use cucumber-js
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/56ddcb02
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/56ddcb02
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/56ddcb02
Branch: refs/heads/master
Commit: 56ddcb027a622c6d8a4a5c3ebe923bb567263a69
Parents: d35aef7
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 22 17:44:18 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:15 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/glv/PackageJson.template | 4 +-
gremlin-javascript/pom.xml | 16 ++++-
.../javascript/gremlin-javascript/package.json | 4 +-
.../test/cucumber/feature-steps.js | 69 ++++++++++++++++++++
.../gremlin-javascript/test/cucumber/world.js | 33 ++++++++++
5 files changed, 121 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/56ddcb02/gremlin-javascript/glv/PackageJson.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template
index f61913f..3ff17af 100644
--- a/gremlin-javascript/glv/PackageJson.template
+++ b/gremlin-javascript/glv/PackageJson.template
@@ -36,7 +36,8 @@
"ws": "^3.0.0"
},
"devDependencies": {
- "mocha": ">= 1.14.0"
+ "mocha": "~4.0.1",
+ "cucumber": "~3.1.0"
},
"repository": {
"type": "git",
@@ -47,6 +48,7 @@
},
"scripts": {
"test": "./node_modules/.bin/mocha test --recursive -t 5000",
+ "features": "./node_modules/.bin/cucumber.js ../../../../../gremlin-test/features/",
"unit-test": "./node_modules/.bin/mocha test/unit"
},
"engines": {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/56ddcb02/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index c08b59b..871fd7a 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -269,31 +269,41 @@ server.stop().join()
<executions>
<execution>
<id>install node and npm</id>
+ <phase>generate-test-resources</phase>
<goals>
<goal>install-node-and-npm</goal>
</goals>
- <phase>generate-test-resources</phase>
</execution>
<execution>
<id>npm install</id>
+ <phase>generate-test-resources</phase>
<goals>
<goal>npm</goal>
</goals>
- <phase>generate-test-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm test</id>
+ <phase>integration-test</phase>
<goals>
<goal>npm</goal>
</goals>
- <phase>integration-test</phase>
<configuration>
<arguments>test</arguments>
</configuration>
</execution>
+ <execution>
+ <id>npm test gherkin features</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>npm</goal>
+ </goals>
+ <configuration>
+ <arguments>run-script features</arguments>
+ </configuration>
+ </execution>
</executions>
<configuration>
<skip>${skipIntegrationTests}</skip>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/56ddcb02/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index 1228dd4..dfbaff2 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -17,7 +17,8 @@
"ws": "^3.0.0"
},
"devDependencies": {
- "mocha": ">= 1.14.0"
+ "mocha": "~4.0.1",
+ "cucumber": "~3.1.0"
},
"repository": {
"type": "git",
@@ -28,6 +29,7 @@
},
"scripts": {
"test": "./node_modules/.bin/mocha test --recursive -t 5000",
+ "features": "./node_modules/.bin/cucumber.js ../../../../../gremlin-test/features/",
"unit-test": "./node_modules/.bin/mocha test/unit"
},
"engines": {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/56ddcb02/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
new file mode 100644
index 0000000..10680b7
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+const {defineSupportCode} = require('cucumber');
+const vm = require('vm');
+
+
+defineSupportCode(function({Given, When, Then}) {
+ Given(/^the (.+) graph$/, function (graphName) {
+ //TODO: Set context g
+ });
+ // Given('the graph initializer of');
+ Given('an unsupported test', () => {});
+
+ Given('the traversal of', function (traversalText) {
+ //TODO: make traversal
+ });
+
+ Given(/^$/, function (paramName, stringValue) {
+ //TODO: Add parameter
+ });
+
+ When('iterated to list', function () {
+ //TODO
+ });
+
+ When('iterated next', function () {
+ //TODO
+ });
+
+ Then(/^the result should be (\w+)$/, function (characterizedAs, resultTable) {
+ //TODO
+ //console.log('--resultTable', resultTable.rows());
+ if (typeof resultTable === 'function'){
+ return resultTable();
+ }
+ });
+
+ Then(/^the graph should return (\d+) for count of (.+)$/, function (stringCount, traversalString) {
+
+ });
+
+ Then(/^the result should have a count of (\d+)$/, function (stringCount) {
+
+ });
+
+ Then('nothing should happen because', () => {});
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/56ddcb02/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
new file mode 100644
index 0000000..f1cd7a6
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+const {defineSupportCode} = require('cucumber');
+
+defineSupportCode(function ({setWorldConstructor}) {
+ function TinkerPopWorld(){
+ this.g = null;
+ this.traversal = null;
+ }
+ setWorldConstructor(TinkerPopWorld);
+});
\ No newline at end of file
[08/47] tinkerpop git commit: TINKERPOP-1489 Regenerated traversal.js
Posted by jo...@apache.org.
TINKERPOP-1489 Regenerated traversal.js
which added Pick.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e94d4154
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e94d4154
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e94d4154
Branch: refs/heads/master
Commit: e94d4154e02566d9197db81a8d940876be68a311
Parents: 7f5d030
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 18 12:48:27 2017 -0400
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:14 2018 +0100
----------------------------------------------------------------------
.../src/main/javascript/gremlin-javascript/process/traversal.js | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e94d4154/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index f585161..9709a4f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -377,6 +377,7 @@
direction: toEnum('Direction', 'BOTH IN OUT'),
operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
+ pick: toEnum('Pick', 'any none'),
pop: toEnum('Pop', 'all first last'),
scope: toEnum('Scope', 'global local'),
t: toEnum('T', 'id key label value')
[32/47] tinkerpop git commit: Support multiple mime types
Posted by jo...@apache.org.
Support multiple mime types
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b7f85ca5
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b7f85ca5
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b7f85ca5
Branch: refs/heads/master
Commit: b7f85ca5d167eac2443d7f5eb25423a8a7b4f6d4
Parents: 93cf86d
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 29 12:02:50 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:17 2018 +0100
----------------------------------------------------------------------
.../lib/driver/driver-remote-connection.js | 15 +++++++++------
.../lib/driver/remote-connection.js | 2 +-
2 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b7f85ca5/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index 31f27cd..51661c3 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -29,8 +29,7 @@ var RemoteConnection = require('./remote-connection').RemoteConnection;
var utils = require('../utils');
var serializer = require('../structure/io/graph-serializer');
var inherits = utils.inherits;
-var mimeType = 'application/vnd.gremlin-v2.0+json';
-var header = String.fromCharCode(mimeType.length) + mimeType;
+var defaultMimeType = 'application/vnd.gremlin-v2.0+json';
var responseStatusCode = {
success: 200,
noContent: 204,
@@ -41,16 +40,18 @@ var responseStatusCode = {
* Creates a new instance of DriverRemoteConnection.
* @param {String} url The resource uri.
* @param {Object} [options] The connection options.
- * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
* @param {Array} [options.ca] Trusted certificates.
* @param {String|Array|Buffer} [options.cert] The certificate key.
+ * @param {String} [options.mimeType] The mime type to use.
* @param {String|Buffer} [options.pfx] The private key, certificate, and CA certs.
- * @param {GraphSONReader} [options.reader] The GraphSON2 reader to use.
+ * @param {GraphSONReader} [options.reader] The reader to use.
* @param {Boolean} [options.rejectUnauthorized] Determines whether to verify or not the server certificate.
- * @param {GraphSONWriter} [options.writer] The GraphSON2 writer to use.
+ * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
+ * @param {GraphSONWriter} [options.writer] The writer to use.
* @constructor
*/
function DriverRemoteConnection(url, options) {
+ RemoteConnection.call(this, url);
options = options || {};
this._ws = new WebSocket(url, {
ca: options.ca,
@@ -75,6 +76,8 @@ function DriverRemoteConnection(url, options) {
this._openPromise = null;
this._openCallback = null;
this._closePromise = null;
+ var mimeType = options.mimeType || defaultMimeType;
+ this._header = String.fromCharCode(mimeType.length) + mimeType;
this.isOpen = false;
this.traversalSource = options.traversalSource || 'g';
}
@@ -114,7 +117,7 @@ DriverRemoteConnection.prototype.submit = function (bytecode, promiseFactory) {
callback: callback,
result: null
};
- var message = bufferFromString(header + JSON.stringify(self._getRequest(requestId, bytecode)));
+ var message = bufferFromString(self._header + JSON.stringify(self._getRequest(requestId, bytecode)));
self._ws.send(message);
});
});
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b7f85ca5/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
index 8176c37..235375a 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
@@ -27,7 +27,7 @@ var TraversalStrategy = require('../process/traversal-strategy').TraversalStrate
var utils = require('../utils');
var inherits = utils.inherits;
-function RemoteConnection(url, traversalSource) {
+function RemoteConnection(url) {
this.url = url;
}
[16/47] tinkerpop git commit: TINKERPOP-1489 Added Nashorn
ScriptEngine to gremlin-javascript
Posted by jo...@apache.org.
TINKERPOP-1489 Added Nashorn ScriptEngine to gremlin-javascript
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/eccbd15a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/eccbd15a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/eccbd15a
Branch: refs/heads/master
Commit: eccbd15a94a2fa6aeb1ac19e9d95ba7d6509c187
Parents: 80e1c7e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 5 12:36:12 2017 -0400
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:15 2018 +0100
----------------------------------------------------------------------
docs/src/reference/gremlin-variants.asciidoc | 2 +-
.../src/main/javascript/gremlin-javascript/package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eccbd15a/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index 76952eb..4a2fe7a 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -447,7 +447,7 @@ very similar to that of Java, it should be very easy to switch between Gremlin-J
[source,bash]
npm install gremlin-javascript
-In Gremlin-JavaScript there exists `GraphTraversalSource`, `GraphTraversal`, and `__` which mirror the respective classes
+The Gremlin-JavaScript provides `GraphTraversalSource`, `GraphTraversal`, and `__` which mirror the respective classes
in Gremlin-Java. The `GraphTraversalSource` requires a RemoteConnection implementation in order to communicate with
<<gremlin-server,GremlinServer>>.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eccbd15a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index 514663b..1228dd4 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -1,6 +1,6 @@
{
"name": "gremlin-javascript",
- "version": "3.2.6-alpha1",
+ "version": "3.2.7-alpha1",
"description": "JavaScript Gremlin Language Variant",
"author": "Apache TinkerPop team",
"keywords": [
[36/47] tinkerpop git commit: Use ES6 syntax
Posted by jo...@apache.org.
Use ES6 syntax
- Use class definitions
- Use const and let
- Computed property names in object literals
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d458f76d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d458f76d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d458f76d
Branch: refs/heads/master
Commit: d458f76dc3d464dae3a5e3bb3b28f63e5b3eead1
Parents: b7f85ca
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Nov 30 14:45:22 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:17 2018 +0100
----------------------------------------------------------------------
.../glv/GraphTraversalSource.template | 155 +-
gremlin-javascript/glv/TraversalSource.template | 247 +-
.../lib/driver/driver-remote-connection.js | 279 +-
.../lib/driver/remote-connection.js | 86 +-
.../gremlin-javascript/lib/process/bytecode.js | 125 +-
.../lib/process/graph-traversal.js | 2439 +++++++++---------
.../lib/process/traversal-strategy.js | 99 +-
.../gremlin-javascript/lib/process/traversal.js | 363 +--
.../gremlin-javascript/lib/structure/graph.js | 180 +-
.../lib/structure/io/graph-serializer.js | 535 +---
.../lib/structure/io/type-serializers.js | 288 +++
.../javascript/gremlin-javascript/lib/utils.js | 7 +-
.../test/integration/remote-connection-tests.js | 2 +-
.../test/integration/traversal-test.js | 2 +-
.../test/unit/exports-test.js | 4 +-
.../test/unit/graphson-test.js | 38 +-
.../test/unit/traversal-test.js | 26 +-
17 files changed, 2451 insertions(+), 2424 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/glv/GraphTraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/GraphTraversalSource.template b/gremlin-javascript/glv/GraphTraversalSource.template
index e0fb453..812cfcf 100644
--- a/gremlin-javascript/glv/GraphTraversalSource.template
+++ b/gremlin-javascript/glv/GraphTraversalSource.template
@@ -22,93 +22,96 @@
*/
'use strict';
-var t = require('./traversal.js');
-var remote = require('../driver/remote-connection');
-var utils = require('../utils');
-var Bytecode = require('./bytecode');
-var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
-var inherits = utils.inherits;
-var parseArgs = utils.parseArgs;
+const Traversal = require('./traversal').Traversal;
+const remote = require('../driver/remote-connection');
+const utils = require('../utils');
+const Bytecode = require('./bytecode');
+const TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
+const parseArgs = utils.parseArgs;
-/**
- *
- * @param {Graph} graph
- * @param {TraversalStrategies} traversalStrategies
- * @param {Bytecode} [bytecode]
- * @constructor
- */
-function GraphTraversalSource(graph, traversalStrategies, bytecode) {
- this.graph = graph;
- this.traversalStrategies = traversalStrategies;
- this.bytecode = bytecode || new Bytecode();
-}
/**
- * @param remoteConnection
- * @returns {GraphTraversalSource}
+ * Represents the primary DSL of the Gremlin traversal machine.
*/
-GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
- var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
- traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
- return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
-};
+class GraphTraversalSource {
+ /**
+ * @param {Graph} graph
+ * @param {TraversalStrategies} traversalStrategies
+ * @param {Bytecode} [bytecode]
+ */
+ constructor(graph, traversalStrategies, bytecode) {
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode || new Bytecode();
+ }
-/**
- * Returns the string representation of the GraphTraversalSource.
- * @returns {string}
- */
-GraphTraversalSource.prototype.toString = function () {
- return 'graphtraversalsource[' + this.graph.toString() + ']';
-};
-<% sourceStepMethods.each{ method -> %>
-/**
- * Graph Traversal Source <%= method %> method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.<%= toJs.call(method) %> = function (args) {
- var b = new Bytecode(this.bytecode).addSource('<%= method %>', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-<%
+ /**
+ * @param remoteConnection
+ * @returns {GraphTraversalSource}
+ */
+ withRemote(remoteConnection) {
+ const traversalStrategy = new TraversalStrategies(this.traversalStrategies);
+ traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+ return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
+ }
+
+ /**
+ * Returns the string representation of the GraphTraversalSource.
+ * @returns {string}
+ */
+ toString() {
+ return 'graphtraversalsource[' + this.graph.toString() + ']';
+ }
+ <% sourceStepMethods.each{ method -> %>
+ /**
+ * Graph Traversal Source <%= method %> method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ <%= toJs.call(method) %>(args) {
+ const b = new Bytecode(this.bytecode).addSource('<%= method %>', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+ <%
+ }
+ sourceSpawnMethods.each{ method -> %>
+ /**
+ * <%= method %> GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ <%= toJs.call(method) %>(args) {
+ const b = new Bytecode(this.bytecode).addStep('<%= method %>', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+ <% } %>
}
-sourceSpawnMethods.each{ method -> %>
-/**
- * <%= method %> GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.<%= toJs.call(method) %> = function (args) {
- var b = new Bytecode(this.bytecode).addStep('<%= method %>', parseArgs.apply(null, arguments));
- return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-<% } %>
+
/**
* Represents a graph traversal.
- * @extends Traversal
- * @constructor
*/
-function GraphTraversal(graph, traversalStrategies, bytecode) {
- t.Traversal.call(this, graph, traversalStrategies, bytecode);
+class GraphTraversal extends Traversal {
+ constructor(graph, traversalStrategies, bytecode) {
+ super(graph, traversalStrategies, bytecode);
+ }
+ <% graphStepMethods.each{ method -> %>
+ /**
+ * Graph traversal <%= method %> method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ <%= toJs.call(method) %>(args) {
+ this.bytecode.addStep('<%= method %>', parseArgs.apply(null, arguments));
+ return this;
+ }
+ <% } %>
}
-inherits(GraphTraversal, t.Traversal);
-<% graphStepMethods.each{ method -> %>
-/**
- * Graph traversal <%= method %> method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.<%= toJs.call(method) %> = function (args) {
- this.bytecode.addStep('<%= method %>', parseArgs.apply(null, arguments));
- return this;
-};
-<% } %>
/**
* Contains the static method definitions
* @type {Object}
*/
-var statics = {};
+const statics = {};
<% anonStepMethods.each{ method -> %>
/**
* <%= method %>() static method
@@ -116,12 +119,12 @@ var statics = {};
* @returns {GraphTraversal}
*/
statics.<%= toJs.call(method) %> = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.<%= toJs.call(method) %>.apply(g, arguments);
};
<% } %>
module.exports = {
- GraphTraversal: GraphTraversal,
- GraphTraversalSource: GraphTraversalSource,
- statics: statics
+ GraphTraversal,
+ GraphTraversalSource,
+ statics
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index 0d45e90..d707a42 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -26,142 +26,149 @@ const utils = require('../utils');
const parseArgs = utils.parseArgs;
const itemDone = Object.freeze({ value: null, done: true });
-function Traversal(graph, traversalStrategies, bytecode) {
- this.graph = graph;
- this.traversalStrategies = traversalStrategies;
- this.bytecode = bytecode;
- /** @type {Array<Traverser>} */
- this.traversers = null;
- this.sideEffects = null;
- this._traversalStrategiesPromise = null;
- this._traversersIteratorIndex = 0;
-}
+class Traversal {
+ constructor(graph, traversalStrategies, bytecode) {
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode;
+ /** @type {Array<Traverser>} */
+ this.traversers = null;
+ this.sideEffects = null;
+ this._traversalStrategiesPromise = null;
+ this._traversersIteratorIndex = 0;
+ }
-/** @returns {Bytecode} */
-Traversal.prototype.getBytecode = function () {
- return this.bytecode;
-};
+ /** @returns {Bytecode} */
+ getBytecode() {
+ return this.bytecode;
+ }
-/**
- * Returns an Array containing the traverser objects.
- * @returns {Promise.<Array>}
- */
-Traversal.prototype.toList = function () {
- return this._applyStrategies().then(() => {
- const result = [];
- let it;
- while ((it = this._getNext()) && !it.done) {
- result.push(it.value);
- }
- return result;
- });
-};
+ /**
+ * Returns an Array containing the traverser objects.
+ * @returns {Promise.<Array>}
+ */
+ toList() {
+ return this._applyStrategies().then(() => {
+ const result = [];
+ let it;
+ while ((it = this._getNext()) && !it.done) {
+ result.push(it.value);
+ }
+ return result;
+ });
+ };
+
+ /**
+ * Iterates all Traverser instances in the traversal.
+ * @returns {Promise}
+ */
+ iterate() {
+ return this._applyStrategies().then(() => {
+ let it;
+ while ((it = this._getNext()) && !it.done) {
+ }
+ });
+ }
-/**
- * Iterates all Traverser instances in the traversal.
- * @returns {Promise}
- */
-Traversal.prototype.iterate = function () {
- return this._applyStrategies().then(() => {
- let it;
- while ((it = this._getNext()) && !it.done) {
- }
- });
-};
+ /**
+ * Async iterator method implementation.
+ * Returns a promise containing an iterator item.
+ * @returns {Promise.<{value, done}>}
+ */
+ next() {
+ return this._applyStrategies().then(() => this._getNext());
+ }
-/**
- * Async iterator method implementation.
- * Returns a promise containing an iterator item.
- * @returns {Promise.<{value, done}>}
- */
-Traversal.prototype.next = function () {
- return this._applyStrategies().then(() => this._getNext());
-};
+ /**
+ * Synchronous iterator of traversers including
+ * @private
+ */
+ _getNext() {
+ while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
+ let traverser = this.traversers[this._traversersIteratorIndex];
+ if (traverser.bulk > 0) {
+ traverser.bulk--;
+ return { value: traverser.object, done: false };
+ }
+ this._traversersIteratorIndex++;
+ }
+ return itemDone;
+ }
-/**
- * Synchronous iterator of traversers including
- * @private
- */
-Traversal.prototype._getNext = function () {
- while (this.traversers && this._traversersIteratorIndex < this.traversers.length) {
- let traverser = this.traversers[this._traversersIteratorIndex];
- if (traverser.bulk > 0) {
- traverser.bulk--;
- return { value: traverser.object, done: false };
+ _applyStrategies() {
+ if (this._traversalStrategiesPromise) {
+ // Apply strategies only once
+ return this._traversalStrategiesPromise;
}
- this._traversersIteratorIndex++;
+ return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
}
- return itemDone;
-};
-Traversal.prototype._applyStrategies = function () {
- if (this._traversalStrategiesPromise) {
- // Apply strategies only once
- return this._traversalStrategiesPromise;
+ /**
+ * Returns the Bytecode JSON representation of the traversal
+ * @returns {String}
+ */
+ toString() {
+ return this.bytecode.toString();
+ };
+}
+
+class P {
+ /**
+ * Represents an operation.
+ * @constructor
+ */
+ constructor(operator, value, other) {
+ this.operator = operator;
+ this.value = value;
+ this.other = other;
}
- return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
-};
-/**
- * Returns the Bytecode JSON representation of the traversal
- * @returns {String}
- */
-Traversal.prototype.toString = function () {
- return this.bytecode.toString();
-};
+ /**
+ * Returns the string representation of the instance.
+ * @returns {string}
+ */
+ toString() {
+ if (this.other === undefined) {
+ return this.operator + '(' + this.value + ')';
+ }
+ return this.operator + '(' + this.value + ', ' + this.other + ')';
+ }
-/**
- * Represents an operation.
- * @constructor
- */
-function P(operator, value, other) {
- this.operator = operator;
- this.value = value;
- this.other = other;
-}
+ and(arg) {
+ return new P('and', this, arg);
+ }
-/**
- * Returns the string representation of the instance.
- * @returns {string}
- */
-P.prototype.toString = function () {
- if (this.other === undefined) {
- return this.operator + '(' + this.value + ')';
+ or(arg) {
+ return new P('or', this, arg);
+ }
+<% pmethods.each{ method -> %>
+ /** @param {...Object} args */
+ static <%= toJs.call(method) %>(args) {
+ return createP('<%= method %>', parseArgs.apply(null, arguments));
}
- return this.operator + '(' + this.value + ', ' + this.other + ')';
-};
+<% } %>
+}
function createP(operator, args) {
args.unshift(null, operator);
return new (Function.prototype.bind.apply(P, args));
}
-<% pmethods.each{ method -> %>
-/** @param {...Object} args */
-P.<%= toJs.call(method) %> = function (args) {
- return createP('<%= method %>', parseArgs.apply(null, arguments));
-};
-<% } %>
-P.prototype.and = function (arg) {
- return new P('and', this, arg);
-};
-
-P.prototype.or = function (arg) {
- return new P('or', this, arg);
-};
-function Traverser(object, bulk) {
- this.object = object;
- this.bulk = bulk || 1;
+class Traverser {
+ constructor(object, bulk) {
+ this.object = object;
+ this.bulk = bulk || 1;
+ }
}
-function TraversalSideEffects() {
+class TraversalSideEffects {
}
function toEnum(typeName, keys) {
- var result = {};
- keys.split(' ').forEach(function (k) {
- var jsKey = k;
+ const result = {};
+ keys.split(' ').forEach(k => {
+ let jsKey = k;
if (jsKey === jsKey.toUpperCase()) {
jsKey = jsKey.toLowerCase();
}
@@ -170,17 +177,19 @@ function toEnum(typeName, keys) {
return result;
}
-function EnumValue(typeName, elementName) {
- this.typeName = typeName;
- this.elementName = elementName;
+class EnumValue {
+ constructor(typeName, elementName) {
+ this.typeName = typeName;
+ this.elementName = elementName;
+ }
}
module.exports = {
- EnumValue: EnumValue,
- P: P,
- Traversal: Traversal,
- TraversalSideEffects: TraversalSideEffects,
- Traverser: Traverser<%
+ EnumValue,
+ P,
+ Traversal,
+ TraversalSideEffects,
+ Traverser<%
enums.each{ enumClass ->
out.print ",\n " + decapitalize.call(enumClass.simpleName) + ": toEnum('" + enumClass.simpleName + "', '" +
enumClass.getEnumConstants().sort { a, b -> a.name() <=> b.name() }.collect { toJs.call(it.name()) }.join(' ') + "')"
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index 51661c3..ac3fb0f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -22,165 +22,164 @@
*/
'use strict';
-var crypto = require('crypto');
-var WebSocket = require('ws');
-var util = require('util');
-var RemoteConnection = require('./remote-connection').RemoteConnection;
-var utils = require('../utils');
-var serializer = require('../structure/io/graph-serializer');
-var inherits = utils.inherits;
-var defaultMimeType = 'application/vnd.gremlin-v2.0+json';
-var responseStatusCode = {
+const crypto = require('crypto');
+const WebSocket = require('ws');
+const util = require('util');
+const RemoteConnection = require('./remote-connection').RemoteConnection;
+const utils = require('../utils');
+const serializer = require('../structure/io/graph-serializer');
+const responseStatusCode = {
success: 200,
noContent: 204,
partialContent: 206
};
+const defaultMimeType = 'application/vnd.gremlin-v2.0+json';
-/**
- * Creates a new instance of DriverRemoteConnection.
- * @param {String} url The resource uri.
- * @param {Object} [options] The connection options.
- * @param {Array} [options.ca] Trusted certificates.
- * @param {String|Array|Buffer} [options.cert] The certificate key.
- * @param {String} [options.mimeType] The mime type to use.
- * @param {String|Buffer} [options.pfx] The private key, certificate, and CA certs.
- * @param {GraphSONReader} [options.reader] The reader to use.
- * @param {Boolean} [options.rejectUnauthorized] Determines whether to verify or not the server certificate.
- * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
- * @param {GraphSONWriter} [options.writer] The writer to use.
- * @constructor
- */
-function DriverRemoteConnection(url, options) {
- RemoteConnection.call(this, url);
- options = options || {};
- this._ws = new WebSocket(url, {
- ca: options.ca,
- cert: options.cert,
- pfx: options.pfx,
- rejectUnauthorized: options.rejectUnauthorized
- });
- var self = this;
- this._ws.on('open', function opened () {
- self.isOpen = true;
- if (self._openCallback) {
- self._openCallback();
- }
- });
- this._ws.on('message', function incoming (data) {
- self._handleMessage(data);
- });
- // A map containing the request id and the handler
- this._responseHandlers = {};
- this._reader = options.reader || new serializer.GraphSONReader();
- this._writer = options.writer || new serializer.GraphSONWriter();
- this._openPromise = null;
- this._openCallback = null;
- this._closePromise = null;
- var mimeType = options.mimeType || defaultMimeType;
- this._header = String.fromCharCode(mimeType.length) + mimeType;
- this.isOpen = false;
- this.traversalSource = options.traversalSource || 'g';
-}
-
-inherits(DriverRemoteConnection, RemoteConnection);
+class DriverRemoteConnection extends RemoteConnection {
+ /**
+ * Creates a new instance of DriverRemoteConnection.
+ * @param {String} url The resource uri.
+ * @param {Object} [options] The connection options.
+ * @param {Array} [options.ca] Trusted certificates.
+ * @param {String|Array|Buffer} [options.cert] The certificate key.
+ * @param {String} [options.mimeType] The mime type to use.
+ * @param {String|Buffer} [options.pfx] The private key, certificate, and CA certs.
+ * @param {GraphSONReader} [options.reader] The reader to use.
+ * @param {Boolean} [options.rejectUnauthorized] Determines whether to verify or not the server certificate.
+ * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
+ * @param {GraphSONWriter} [options.writer] The writer to use.
+ * @constructor
+ */
+ constructor(url, options) {
+ super(url);
+ options = options || {};
+ this._ws = new WebSocket(url, {
+ ca: options.ca,
+ cert: options.cert,
+ pfx: options.pfx,
+ rejectUnauthorized: options.rejectUnauthorized
+ });
+ var self = this;
+ this._ws.on('open', function opened () {
+ self.isOpen = true;
+ if (self._openCallback) {
+ self._openCallback();
+ }
+ });
+ this._ws.on('message', function incoming (data) {
+ self._handleMessage(data);
+ });
+ // A map containing the request id and the handler
+ this._responseHandlers = {};
+ this._reader = options.reader || new serializer.GraphSONReader();
+ this._writer = options.writer || new serializer.GraphSONWriter();
+ this._openPromise = null;
+ this._openCallback = null;
+ this._closePromise = null;
+ const mimeType = options.mimeType || defaultMimeType;
+ this._header = String.fromCharCode(mimeType.length) + mimeType;
+ this.isOpen = false;
+ this.traversalSource = options.traversalSource || 'g';
+ }
-/**
- * Opens the connection, if its not already opened.
- * @returns {Promise}
- */
-DriverRemoteConnection.prototype.open = function (promiseFactory) {
- if (this._closePromise) {
+ /**
+ * Opens the connection, if its not already opened.
+ * @returns {Promise}
+ */
+ open(promiseFactory) {
+ if (this._closePromise) {
+ return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
+ callback(new Error('Connection has been closed'));
+ });
+ }
+ if (this._openPromise) {
+ return this._openPromise;
+ }
+ const self = this;
return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
- callback(new Error('Connection has been closed'));
+ if (self.isOpen) {
+ return callback();
+ }
+ // It will be invoked when opened
+ self._openCallback = callback;
});
}
- if (this._openPromise) {
- return this._openPromise;
+
+ /** @override */
+ submit(bytecode, promiseFactory) {
+ const self = this;
+ return this.open().then(function () {
+ return utils.toPromise(promiseFactory, function promiseHandler(callback) {
+ const requestId = getUuid();
+ self._responseHandlers[requestId] = {
+ callback: callback,
+ result: null
+ };
+ const message = bufferFromString(self._header + JSON.stringify(self._getRequest(requestId, bytecode)));
+ self._ws.send(message);
+ });
+ });
}
- var self = this;
- return this._openPromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
- if (self.isOpen) {
- return callback();
- }
- // It will be invoked when opened
- self._openCallback = callback;
- });
-};
-/** @override */
-DriverRemoteConnection.prototype.submit = function (bytecode, promiseFactory) {
- var self = this;
- return this.open().then(function () {
- return utils.toPromise(promiseFactory, function promiseHandler(callback) {
- var requestId = getUuid();
- self._responseHandlers[requestId] = {
- callback: callback,
- result: null
- };
- var message = bufferFromString(self._header + JSON.stringify(self._getRequest(requestId, bytecode)));
- self._ws.send(message);
+ _getRequest(id, bytecode) {
+ return ({
+ 'requestId': { '@type': 'g:UUID', '@value': id },
+ 'op': 'bytecode',
+ 'processor': 'traversal',
+ 'args': {
+ 'gremlin': this._writer.adaptObject(bytecode),
+ 'aliases': { 'g': this.traversalSource }
+ }
});
- });
-};
+ }
-DriverRemoteConnection.prototype._getRequest = function (id, bytecode) {
- return ({
- 'requestId': { '@type': 'g:UUID', '@value': id },
- 'op': 'bytecode',
- 'processor': 'traversal',
- 'args': {
- 'gremlin': this._writer.adaptObject(bytecode),
- 'aliases': { 'g': this.traversalSource }
+ _handleMessage(data) {
+ const response = this._reader.read(JSON.parse(data.toString()));
+ const handler = this._responseHandlers[response.requestId];
+ if (response.status.code >= 400) {
+ // callback in error
+ return handler.callback(
+ new Error(util.format('Server error: %s (%d)', response.status.message, response.status.code)));
}
- });
-};
-
-DriverRemoteConnection.prototype._handleMessage = function (data) {
- var response = this._reader.read(JSON.parse(data.toString()));
- var handler = this._responseHandlers[response.requestId];
- if (response.status.code >= 400) {
- // callback in error
- return handler.callback(
- new Error(util.format('Server error: %s (%d)', response.status.message, response.status.code)));
- }
- switch (response.status.code) {
- case responseStatusCode.noContent:
- return handler.callback(null, { traversers: []});
- case responseStatusCode.partialContent:
- handler.result = handler.result || [];
- handler.result.push.apply(handler.result, response.result.data);
- break;
- default:
- if (handler.result) {
+ switch (response.status.code) {
+ case responseStatusCode.noContent:
+ return handler.callback(null, { traversers: []});
+ case responseStatusCode.partialContent:
+ handler.result = handler.result || [];
handler.result.push.apply(handler.result, response.result.data);
- }
- else {
- handler.result = response.result.data;
- }
- return handler.callback(null, { traversers: handler.result });
+ break;
+ default:
+ if (handler.result) {
+ handler.result.push.apply(handler.result, response.result.data);
+ }
+ else {
+ handler.result = response.result.data;
+ }
+ return handler.callback(null, { traversers: handler.result });
+ }
}
-};
-/**
- * Closes the Connection.
- * @return {Promise}
- */
-DriverRemoteConnection.prototype.close = function (promiseFactory) {
- if (this._closePromise) {
- return this._closePromise;
- }
- var self = this;
- return this._closePromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
- self._ws.on('close', function () {
- self.isOpen = false;
- callback();
+ /**
+ * Closes the Connection.
+ * @return {Promise}
+ */
+ close(promiseFactory) {
+ if (this._closePromise) {
+ return this._closePromise;
+ }
+ const self = this;
+ return this._closePromise = utils.toPromise(promiseFactory, function promiseHandler(callback) {
+ self._ws.on('close', function () {
+ self.isOpen = false;
+ callback();
+ });
+ self._ws.close();
});
- self._ws.close();
- });
-};
+ }
+}
function getUuid() {
- var buffer = crypto.randomBytes(16);
+ const buffer = crypto.randomBytes(16);
//clear the version
buffer[6] &= 0x0f;
//set the version 4
@@ -189,7 +188,7 @@ function getUuid() {
buffer[8] &= 0x3f;
//set the IETF variant
buffer[8] |= 0x80;
- var hex = buffer.toString('hex');
+ const hex = buffer.toString('hex');
return (
hex.substr(0, 8) + '-' +
hex.substr(8, 4) + '-' +
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
index 235375a..37f3d0e 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
@@ -22,60 +22,54 @@
*/
'use strict';
-var t = require('../process/traversal');
-var TraversalStrategy = require('../process/traversal-strategy').TraversalStrategy;
-var utils = require('../utils');
-var inherits = utils.inherits;
+const t = require('../process/traversal');
+const TraversalStrategy = require('../process/traversal-strategy').TraversalStrategy;
-function RemoteConnection(url) {
- this.url = url;
-}
-
-/**
- * @abstract
- * @param {Bytecode} bytecode
- * @param {Function|undefined} promiseFactory
- * @returns {Promise}
- */
-RemoteConnection.prototype.submit = function (bytecode, promiseFactory) {
- throw new Error('submit() was not implemented');
-};
+class RemoteConnection {
+ constructor(url) {
+ this.url = url;
+ }
-/**
- * @extends {Traversal}
- * @constructor
- */
-function RemoteTraversal(traversers, sideEffects) {
- t.Traversal.call(this, null, null, null);
- this.traversers = traversers;
- this.sideEffects = sideEffects;
+ /**
+ * @abstract
+ * @param {Bytecode} bytecode
+ * @param {Function|undefined} promiseFactory
+ * @returns {Promise}
+ */
+ submit(bytecode, promiseFactory) {
+ throw new Error('submit() was not implemented');
+ };
}
-inherits(RemoteTraversal, t.Traversal);
-
-/**
- *
- * @param {RemoteConnection} connection
- * @extends {TraversalStrategy}
- * @constructor
- */
-function RemoteStrategy(connection) {
- TraversalStrategy.call(this);
- this.connection = connection;
+class RemoteTraversal extends t.Traversal {
+ constructor(traversers, sideEffects) {
+ super(null, null, null);
+ this.traversers = traversers;
+ this.sideEffects = sideEffects;
+ }
}
-inherits(RemoteStrategy, TraversalStrategy);
+class RemoteStrategy extends TraversalStrategy {
+ /**
+ * Creates a new instance of RemoteStrategy.
+ * @param {RemoteConnection} connection
+ */
+ constructor(connection) {
+ super();
+ this.connection = connection;
+ }
-/** @override */
-RemoteStrategy.prototype.apply = function (traversal, promiseFactory) {
- if (traversal.traversers) {
- return utils.resolvedPromise(promiseFactory);
+ /** @override */
+ apply(traversal, promiseFactory) {
+ if (traversal.traversers) {
+ return utils.resolvedPromise(promiseFactory);
+ }
+ return this.connection.submit(traversal.getBytecode(), promiseFactory).then(function (remoteTraversal) {
+ traversal.sideEffects = remoteTraversal.sideEffects;
+ traversal.traversers = remoteTraversal.traversers;
+ });
}
- return this.connection.submit(traversal.getBytecode(), promiseFactory).then(function (remoteTraversal) {
- traversal.sideEffects = remoteTraversal.sideEffects;
- traversal.traversers = remoteTraversal.traversers;
- });
-};
+}
module.exports = {
RemoteConnection: RemoteConnection,
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
index 2909718..85a4fc2 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
@@ -22,78 +22,77 @@
*/
'use strict';
-/**
- * Creates a new instance of Bytecode
- * @param {Bytecode} [toClone]
- * @constructor
- */
-function Bytecode(toClone) {
- if (!toClone) {
- this.sourceInstructions = [];
- this.stepInstructions = [];
- }
- else {
- this.sourceInstructions = toClone.sourceInstructions.slice(0);
- this.stepInstructions = toClone.stepInstructions.slice(0);
+class Bytecode {
+ /**
+ * Creates a new instance of Bytecode
+ * @param {Bytecode} [toClone]
+ */
+ constructor(toClone) {
+ if (!toClone) {
+ this.sourceInstructions = [];
+ this.stepInstructions = [];
+ }
+ else {
+ this.sourceInstructions = toClone.sourceInstructions.slice(0);
+ this.stepInstructions = toClone.stepInstructions.slice(0);
+ }
}
-}
-/**
- * Adds a new source instructions
- * @param {String} name
- * @param {Array} values
- * @returns {Bytecode}
- */
-Bytecode.prototype.addSource = function (name, values) {
- if (name === undefined) {
- throw new Error('Name is not defined');
+ /**
+ * Adds a new source instructions
+ * @param {String} name
+ * @param {Array} values
+ * @returns {Bytecode}
+ */
+ addSource(name, values) {
+ if (name === undefined) {
+ throw new Error('Name is not defined');
+ }
+ const instruction = new Array(values.length + 1);
+ instruction[0] = name;
+ for (let i = 0; i < values.length; ++i) {
+ instruction[i + 1] = values[i];
+ }
+ this.sourceInstructions.push(Bytecode._generateInstruction(name, values));
+ return this;
}
- var instruction = new Array(values.length + 1);
- instruction[0] = name;
- for (var i = 0; i < values.length; ++i) {
- instruction[i + 1] = this._convertToArgument(values[i]);
+
+ /**
+ * Adds a new step instructions
+ * @param {String} name
+ * @param {Array} values
+ * @returns {Bytecode}
+ */
+ addStep(name, values) {
+ if (name === undefined) {
+ throw new Error('Name is not defined');
+ }
+ this.stepInstructions.push(Bytecode._generateInstruction(name, values));
+ return this;
}
- this.sourceInstructions.push(this._generateInstruction(name, values));
- return this;
-};
-/**
- * Adds a new step instructions
- * @param {String} name
- * @param {Array} values
- * @returns {Bytecode}
- */
-Bytecode.prototype.addStep = function (name, values) {
- if (name === undefined) {
- throw new Error('Name is not defined');
+ static _generateInstruction(name, values) {
+ const length = (values ? values.length : 0) + 1;
+ const instruction = new Array(length);
+ instruction[0] = name;
+ for (let i = 1; i < length; i++) {
+ instruction[i] = values[i - 1];
+ }
+ return instruction;
}
- this.stepInstructions.push(this._generateInstruction(name, values));
- return this;
-};
-Bytecode.prototype._generateInstruction = function (name, values) {
- var length = (values ? values.length : 0) + 1;
- var instruction = new Array(length);
- instruction[0] = name;
- for (var i = 1; i < length; i++) {
- instruction[i] = this._convertToArgument(values[i - 1]);
+ /**
+ * Returns the JSON representation of the source and step instructions
+ * @returns {String}
+ */
+ toString() {
+ return (
+ (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
+ (this.stepInstructions.length > 0 ? JSON.stringify(this.stepInstructions) : '')
+ );
}
- return instruction;
-};
+}
-/**
- * Returns the JSON representation of the source and step instructions
- * @returns {String}
- */
-Bytecode.prototype.toString = function () {
- return (
- (this.sourceInstructions.length > 0 ? JSON.stringify(this.sourceInstructions) : '') +
- (this.stepInstructions.length > 0 ? JSON.stringify(this.stepInstructions) : '')
- );
-};
-Bytecode.prototype._convertToArgument = function (value) {
- return value;
-};
module.exports = Bytecode;
\ No newline at end of file
[13/47] tinkerpop git commit: Filter out __() static method
Posted by jo...@apache.org.
Filter out __() static method
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/44e65352
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/44e65352
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/44e65352
Branch: refs/heads/master
Commit: 44e653528b8ca142ae2db44252830ff61621b7a1
Parents: 6b3bd9d
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Oct 19 16:03:45 2016 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:14 2018 +0100
----------------------------------------------------------------------
.../javascript/GraphTraversalSourceGenerator.groovy | 1 +
.../gremlin-javascript/process/graph-traversal.js | 10 ----------
2 files changed, 1 insertion(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/44e65352/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
index a8217e2..0ae6079 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -195,6 +195,7 @@ class GraphTraversalSourceGenerator {
__.class.getMethods().
findAll { GraphTraversal.class.equals(it.returnType) }.
findAll { Modifier.isStatic(it.getModifiers()) }.
+ findAll { !it.name.equals("__") }.
collect { SymbolHelper.toJs(it.name) }.
unique().
sort { a, b -> a <=> b }.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/44e65352/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
index 663a24d..7f36e59 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -1080,16 +1080,6 @@
};
/**
- * __() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- statics.__ = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
- return g.__.apply(g, arguments);
- };
-
- /**
* addE() static method
* @param {...Object} args
* @returns {GraphTraversal}
[47/47] tinkerpop git commit: gremlin-javascript pom,
generation update and parse T in test scenarios
Posted by jo...@apache.org.
gremlin-javascript pom, generation update and parse T in test scenarios
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/1fae5d01
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/1fae5d01
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/1fae5d01
Branch: refs/heads/master
Commit: 1fae5d014863c25460f1b4526eb36dc7e2d25f46
Parents: 6923a6a
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Jan 25 11:51:41 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Thu Jan 25 11:51:41 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/pom.xml | 2 +-
.../lib/process/graph-traversal.js | 79 +++++++-------------
.../gremlin-javascript/lib/process/traversal.js | 8 +-
.../javascript/gremlin-javascript/package.json | 2 +-
.../test/cucumber/feature-steps.js | 12 ++-
5 files changed, 43 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1fae5d01/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index f9f0c8e..8868f85 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
<parent>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>tinkerpop</artifactId>
- <version>3.2.8-SNAPSHOT</version>
+ <version>3.3.2-SNAPSHOT</version>
</parent>
<artifactId>gremlin-javascript</artifactId>
<name>Apache TinkerPop :: Gremlin Javascript</name>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1fae5d01/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
index fe1e467..edeb2cb 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
@@ -143,6 +143,16 @@ class GraphTraversalSource {
}
/**
+ * addE GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ addE(...args) {
+ const b = new Bytecode(this.bytecode).addStep('addE', args);
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+
+ /**
* addV GraphTraversalSource step method.
* @param {...Object} args
* @returns {GraphTraversal}
@@ -193,26 +203,6 @@ class GraphTraversal extends Traversal {
}
/**
- * Graph traversal addInE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- addInE(...args) {
- this.bytecode.addStep('addInE', args);
- return this;
- }
-
- /**
- * Graph traversal addOutE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- addOutE(...args) {
- this.bytecode.addStep('addOutE', args);
- return this;
- }
-
- /**
* Graph traversal addV method.
* @param {...Object} args
* @returns {GraphTraversal}
@@ -473,16 +463,6 @@ class GraphTraversal extends Traversal {
}
/**
- * Graph traversal groupV3d0 method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- groupV3d0(...args) {
- this.bytecode.addStep('groupV3d0', args);
- return this;
- }
-
- /**
* Graph traversal has method.
* @param {...Object} args
* @returns {GraphTraversal}
@@ -673,32 +653,22 @@ class GraphTraversal extends Traversal {
}
/**
- * Graph traversal mapKeys method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
- mapKeys(...args) {
- this.bytecode.addStep('mapKeys', args);
- return this;
- }
-
- /**
- * Graph traversal mapValues method.
+ * Graph traversal match method.
* @param {...Object} args
* @returns {GraphTraversal}
*/
- mapValues(...args) {
- this.bytecode.addStep('mapValues', args);
+ match(...args) {
+ this.bytecode.addStep('match', args);
return this;
}
/**
- * Graph traversal match method.
+ * Graph traversal math method.
* @param {...Object} args
* @returns {GraphTraversal}
*/
- match(...args) {
- this.bytecode.addStep('match', args);
+ math(...args) {
+ this.bytecode.addStep('math', args);
return this;
}
@@ -983,6 +953,16 @@ class GraphTraversal extends Traversal {
}
/**
+ * Graph traversal skip method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ skip(...args) {
+ this.bytecode.addStep('skip', args);
+ return this;
+ }
+
+ /**
* Graph traversal store method.
* @param {...Object} args
* @returns {GraphTraversal}
@@ -1166,8 +1146,6 @@ function callOnEmptyTraversal(fnName, args) {
const statics = {
V: (...args) => callOnEmptyTraversal('V', args),
addE: (...args) => callOnEmptyTraversal('addE', args),
- addInE: (...args) => callOnEmptyTraversal('addInE', args),
- addOutE: (...args) => callOnEmptyTraversal('addOutE', args),
addV: (...args) => callOnEmptyTraversal('addV', args),
aggregate: (...args) => callOnEmptyTraversal('aggregate', args),
and: (...args) => callOnEmptyTraversal('and', args),
@@ -1192,7 +1170,6 @@ const statics = {
fold: (...args) => callOnEmptyTraversal('fold', args),
group: (...args) => callOnEmptyTraversal('group', args),
groupCount: (...args) => callOnEmptyTraversal('groupCount', args),
- groupV3d0: (...args) => callOnEmptyTraversal('groupV3d0', args),
has: (...args) => callOnEmptyTraversal('has', args),
hasId: (...args) => callOnEmptyTraversal('hasId', args),
hasKey: (...args) => callOnEmptyTraversal('hasKey', args),
@@ -1212,9 +1189,8 @@ const statics = {
local: (...args) => callOnEmptyTraversal('local', args),
loops: (...args) => callOnEmptyTraversal('loops', args),
map: (...args) => callOnEmptyTraversal('map', args),
- mapKeys: (...args) => callOnEmptyTraversal('mapKeys', args),
- mapValues: (...args) => callOnEmptyTraversal('mapValues', args),
match: (...args) => callOnEmptyTraversal('match', args),
+ math: (...args) => callOnEmptyTraversal('math', args),
max: (...args) => callOnEmptyTraversal('max', args),
mean: (...args) => callOnEmptyTraversal('mean', args),
min: (...args) => callOnEmptyTraversal('min', args),
@@ -1238,6 +1214,7 @@ const statics = {
select: (...args) => callOnEmptyTraversal('select', args),
sideEffect: (...args) => callOnEmptyTraversal('sideEffect', args),
simplePath: (...args) => callOnEmptyTraversal('simplePath', args),
+ skip: (...args) => callOnEmptyTraversal('skip', args),
store: (...args) => callOnEmptyTraversal('store', args),
subgraph: (...args) => callOnEmptyTraversal('subgraph', args),
sum: (...args) => callOnEmptyTraversal('sum', args),
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1fae5d01/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index 4464097..b214d8d 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -257,12 +257,12 @@ module.exports = {
cardinality: toEnum('Cardinality', 'list set single'),
column: toEnum('Column', 'keys values'),
direction: toEnum('Direction', 'BOTH IN OUT'),
- graphSONVersion: toEnum('GraphSONVersion', 'V1_0 V2_0'),
- gryoVersion: toEnum('GryoVersion', 'V1_0'),
+ graphSONVersion: toEnum('GraphSONVersion', 'V1_0 V2_0 V3_0'),
+ gryoVersion: toEnum('GryoVersion', 'V1_0 V3_0'),
operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
- order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
+ order: toEnum('Order', 'decr incr shuffle'),
pick: toEnum('Pick', 'any none'),
- pop: toEnum('Pop', 'all first last'),
+ pop: toEnum('Pop', 'all first last mixed'),
scope: toEnum('Scope', 'global local'),
t: toEnum('T', 'id key label value')
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1fae5d01/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index c668be7..b9e7cdd 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -1,6 +1,6 @@
{
"name": "gremlin-javascript",
- "version": "3.2.8-alpha1",
+ "version": "3.3.2-alpha1",
"description": "JavaScript Gremlin Language Variant",
"author": "Apache TinkerPop team",
"keywords": [
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1fae5d01/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 12bc835..c29789d 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -33,6 +33,7 @@ const utils = require('../../lib/utils');
const Graph = graphModule.Graph;
const Path = graphModule.Path;
const __ = graphTraversalModule.statics;
+const t = traversalModule.t;
// Determines whether the feature maps (m[]), are deserialized as objects (true) or maps (false).
// Use false for GraphSON3.
@@ -50,7 +51,8 @@ const parsers = [
[ 'l\\[(.*)\\]', toArray ],
[ 's\\[(.*)\\]', toArray ],
[ 'm\\[(.+)\\]', toMap ],
- [ 'c\\[(.+)\\]', toLambda ]
+ [ 'c\\[(.+)\\]', toLambda ],
+ [ 't\\[(.+)\\]', toT ]
].map(x => [ new RegExp('^' + x[0] + '$'), x[1] ]);
const ignoreReason = {
@@ -260,6 +262,10 @@ function toPath(value) {
return new Path(new Array(0), parts.map(x => parseValue.call(this, x)));
}
+function toT(value) {
+ return t[value];
+}
+
function toArray(stringList) {
if (stringList === '') {
return new Array(0);
@@ -284,13 +290,13 @@ function parseMapValue(value) {
if (mapAsObject) {
const result = {};
Object.keys(value).forEach(key => {
- result[key] = parseMapValue.call(this, value[key]);
+ result[parseMapValue.call(this, key)] = parseMapValue.call(this, value[key]);
});
return result;
}
const map = new Map();
Object.keys(value).forEach(key => {
- map.set(key, parseMapValue.call(this, value[key]));
+ map.set(parseMapValue.call(this, key), parseMapValue.call(this, value[key]));
});
return map;
}
[27/47] tinkerpop git commit: Traversal iterate() method
Posted by jo...@apache.org.
Traversal iterate() method
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/219ead0e
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/219ead0e
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/219ead0e
Branch: refs/heads/master
Commit: 219ead0ebe728a5694a857da2f221f7e3f3e6237
Parents: 53a7f27
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Nov 27 12:22:08 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:16 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/glv/TraversalSource.template | 12 +++++++++++
.../gremlin-javascript/lib/process/traversal.js | 12 +++++++++++
.../javascript/gremlin-javascript/package.json | 2 +-
.../test/unit/traversal-test.js | 21 ++++++++++++++++++--
4 files changed, 44 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/219ead0e/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index f75765f..0d45e90 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -58,6 +58,18 @@ Traversal.prototype.toList = function () {
};
/**
+ * Iterates all Traverser instances in the traversal.
+ * @returns {Promise}
+ */
+Traversal.prototype.iterate = function () {
+ return this._applyStrategies().then(() => {
+ let it;
+ while ((it = this._getNext()) && !it.done) {
+ }
+ });
+};
+
+/**
* Async iterator method implementation.
* Returns a promise containing an iterator item.
* @returns {Promise.<{value, done}>}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/219ead0e/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index ebf8755..d887fe0 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -58,6 +58,18 @@ Traversal.prototype.toList = function () {
};
/**
+ * Iterates all Traverser instances in the traversal.
+ * @returns {Promise}
+ */
+Traversal.prototype.iterate = function () {
+ return this._applyStrategies().then(() => {
+ let it;
+ while ((it = this._getNext()) && !it.done) {
+ }
+ });
+};
+
+/**
* Async iterator method implementation.
* Returns a promise containing an iterator item.
* @returns {Promise.<{value, done}>}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/219ead0e/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index aae9eb9..7c4a3d6 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -30,7 +30,7 @@
},
"scripts": {
"test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
- "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
+ "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/AddVertex.feature",
"unit-test": "./node_modules/.bin/mocha test/unit"
},
"engines": {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/219ead0e/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
index 635c7e8..2be504b 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
@@ -32,7 +32,6 @@ const TraversalStrategies = require('../../lib/process/traversal-strategy').Trav
describe('Traversal', function () {
describe('#getByteCode()', function () {
-
it('should add steps for with a string parameter', function () {
var g = new graph.Graph().traversal();
var bytecode = g.V().out('created').getBytecode();
@@ -61,7 +60,6 @@ describe('Traversal', function () {
});
describe('#next()', function () {
-
it('should apply the strategies and return a Promise with the iterator item', function () {
var strategyMock = {
apply: function (traversal) {
@@ -175,4 +173,23 @@ describe('Traversal', function () {
});
});
});
+
+ describe('#iterate()', function () {
+ it('should apply the strategies and return a Promise', function () {
+ let applied = false;
+ const strategyMock = {
+ apply: function (traversal) {
+ applied = true;
+ traversal.traversers = [ new t.Traverser('a', 1), new t.Traverser('b', 1) ];
+ return utils.resolvedPromise();
+ }
+ };
+ const strategies = new TraversalStrategies();
+ strategies.addStrategy(strategyMock);
+ const traversal = new t.Traversal(null, strategies, null);
+ return traversal.iterate().then(() => {
+ assert.strictEqual(applied, true);
+ });
+ });
+ });
});
\ No newline at end of file
[11/47] tinkerpop git commit: Graph,
traversalStrategies and graph as Traversal properties
Posted by jo...@apache.org.
Graph, traversalStrategies and graph as Traversal properties
Expose those properties as in the Python GLV and the Java implementation. Previously, those properties where exposed using the private notation (ie: _graph).
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6b3bd9d8
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6b3bd9d8
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6b3bd9d8
Branch: refs/heads/master
Commit: 6b3bd9d89d56f549a1b2dd67c125264918fc56b9
Parents: 10c7155
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Tue Oct 18 16:22:23 2016 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:14 2018 +0100
----------------------------------------------------------------------
.../GraphTraversalSourceGenerator.groovy | 23 +-
.../javascript/TraversalSourceGenerator.groovy | 12 +-
.../process/graph-traversal.js | 253 ++++++++++---------
.../gremlin-javascript/process/traversal.js | 12 +-
4 files changed, 151 insertions(+), 149 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6b3bd9d8/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
index b569292..a8217e2 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -80,9 +80,9 @@ class GraphTraversalSourceGenerator {
* @constructor
*/
function GraphTraversalSource(graph, traversalStrategies, bytecode) {
- this._graph = graph;
- this._traversalStrategies = traversalStrategies;
- this._bytecode = bytecode || new Bytecode();
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode || new Bytecode();
}
/**
@@ -90,9 +90,9 @@ class GraphTraversalSourceGenerator {
* @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
- var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+ var traversalStrategy = new t.TraversalStrategies(this.traversalStrategies);
traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
- return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+ return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
};
/**
@@ -100,7 +100,7 @@ class GraphTraversalSourceGenerator {
* @returns {string}
*/
GraphTraversalSource.prototype.toString = function () {
- return 'graphtraversalsource[' + this._graph.toString() + ']';
+ return 'graphtraversalsource[' + this.graph.toString() + ']';
};
""")
GraphTraversalSource.getMethods(). // SOURCE STEPS
@@ -122,8 +122,8 @@ class GraphTraversalSourceGenerator {
* @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.${method} = function (args) {
- var b = new Bytecode(this._bytecode).addSource('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addSource('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
""")
}
@@ -141,8 +141,8 @@ class GraphTraversalSourceGenerator {
* @returns {GraphTraversal}
*/
GraphTraversalSource.prototype.${method} = function (args) {
- var b = new Bytecode(this._bytecode).addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
- return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
""")
}
@@ -153,6 +153,7 @@ class GraphTraversalSourceGenerator {
"""
/**
* Represents a graph traversal.
+ * @extends Traversal
* @constructor
*/
function GraphTraversal(graph, traversalStrategies, bytecode) {
@@ -175,7 +176,7 @@ class GraphTraversalSourceGenerator {
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.${method} = function (args) {
- this._bytecode.addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('${SymbolHelper.toJava(method)}', parseArgs.apply(null, arguments));
return this;
};
""")
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6b3bd9d8/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
index 5b07a32..46f65a4 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -61,22 +61,22 @@ class TraversalSourceGenerator {
"use strict";
function Traversal(graph, traversalStrategies, bytecode) {
- this._graph = graph;
- this._traversalStrategies = traversalStrategies;
- this._bytecode = bytecode;
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode;
this.traversers = null;
this.sideEffects = null;
}
/** @returns {Bytecode} */
Traversal.prototype.getBytecode = function () {
- return this._bytecode;
+ return this.bytecode;
};
/** @param {Function} callback */
Traversal.prototype.list = function (callback) {
var self = this;
- this._traversalStrategies.applyStrategies(this, function (err) {
+ this.traversalStrategies.applyStrategies(this, function (err) {
if (err) {
return callback(err);
}
@@ -96,7 +96,7 @@ class TraversalSourceGenerator {
* @returns {String}
*/
Traversal.prototype.toString = function () {
- return this._bytecode.toString();
+ return this.bytecode.toString();
};
""");
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6b3bd9d8/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
index 1a6356b..663a24d 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -37,9 +37,9 @@
* @constructor
*/
function GraphTraversalSource(graph, traversalStrategies, bytecode) {
- this._graph = graph;
- this._traversalStrategies = traversalStrategies;
- this._bytecode = bytecode || new Bytecode();
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode || new Bytecode();
}
/**
@@ -47,9 +47,9 @@
* @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
- var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
+ var traversalStrategy = new t.TraversalStrategies(this.traversalStrategies);
traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
- return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+ return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
};
/**
@@ -57,7 +57,7 @@
* @returns {string}
*/
GraphTraversalSource.prototype.toString = function () {
- return 'graphtraversalsource[' + this._graph.toString() + ']';
+ return 'graphtraversalsource[' + this.graph.toString() + ']';
};
/**
@@ -66,8 +66,8 @@
* @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.withBulk = function (args) {
- var b = new Bytecode(this._bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
/**
@@ -76,8 +76,8 @@
* @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.withComputer = function (args) {
- var b = new Bytecode(this._bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
/**
@@ -86,8 +86,8 @@
* @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.withPath = function (args) {
- var b = new Bytecode(this._bytecode).addSource('withPath', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
/**
@@ -96,8 +96,8 @@
* @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.withSack = function (args) {
- var b = new Bytecode(this._bytecode).addSource('withSack', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
/**
@@ -106,8 +106,8 @@
* @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.withSideEffect = function (args) {
- var b = new Bytecode(this._bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
/**
@@ -116,8 +116,8 @@
* @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.withStrategies = function (args) {
- var b = new Bytecode(this._bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
/**
@@ -126,8 +126,8 @@
* @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.withoutStrategies = function (args) {
- var b = new Bytecode(this._bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
/**
@@ -136,8 +136,8 @@
* @returns {GraphTraversal}
*/
GraphTraversalSource.prototype.E = function (args) {
- var b = new Bytecode(this._bytecode).addStep('E', parseArgs.apply(null, arguments));
- return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
/**
@@ -146,8 +146,8 @@
* @returns {GraphTraversal}
*/
GraphTraversalSource.prototype.V = function (args) {
- var b = new Bytecode(this._bytecode).addStep('V', parseArgs.apply(null, arguments));
- return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
/**
@@ -156,8 +156,8 @@
* @returns {GraphTraversal}
*/
GraphTraversalSource.prototype.addV = function (args) {
- var b = new Bytecode(this._bytecode).addStep('addV', parseArgs.apply(null, arguments));
- return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
/**
@@ -166,12 +166,13 @@
* @returns {GraphTraversal}
*/
GraphTraversalSource.prototype.inject = function (args) {
- var b = new Bytecode(this._bytecode).addStep('inject', parseArgs.apply(null, arguments));
- return new GraphTraversal(this._graph, new t.TraversalStrategies(this._traversalStrategies), b);
+ var b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new t.TraversalStrategies(this.traversalStrategies), b);
};
/**
* Represents a graph traversal.
+ * @extends Traversal
* @constructor
*/
function GraphTraversal(graph, traversalStrategies, bytecode) {
@@ -185,7 +186,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.V = function (args) {
- this._bytecode.addStep('V', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('V', parseArgs.apply(null, arguments));
return this;
};
@@ -194,7 +195,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.addE = function (args) {
- this._bytecode.addStep('addE', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
return this;
};
@@ -203,7 +204,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.addInE = function (args) {
- this._bytecode.addStep('addInE', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
return this;
};
@@ -212,7 +213,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.addOutE = function (args) {
- this._bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
return this;
};
@@ -221,7 +222,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.addV = function (args) {
- this._bytecode.addStep('addV', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
return this;
};
@@ -230,7 +231,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.aggregate = function (args) {
- this._bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
return this;
};
@@ -239,7 +240,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.and = function (args) {
- this._bytecode.addStep('and', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('and', parseArgs.apply(null, arguments));
return this;
};
@@ -248,7 +249,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.as = function (args) {
- this._bytecode.addStep('as', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('as', parseArgs.apply(null, arguments));
return this;
};
@@ -257,7 +258,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.barrier = function (args) {
- this._bytecode.addStep('barrier', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
return this;
};
@@ -266,7 +267,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.both = function (args) {
- this._bytecode.addStep('both', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('both', parseArgs.apply(null, arguments));
return this;
};
@@ -275,7 +276,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.bothE = function (args) {
- this._bytecode.addStep('bothE', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
return this;
};
@@ -284,7 +285,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.bothV = function (args) {
- this._bytecode.addStep('bothV', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
return this;
};
@@ -293,7 +294,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.branch = function (args) {
- this._bytecode.addStep('branch', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
return this;
};
@@ -302,7 +303,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.by = function (args) {
- this._bytecode.addStep('by', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('by', parseArgs.apply(null, arguments));
return this;
};
@@ -311,7 +312,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.cap = function (args) {
- this._bytecode.addStep('cap', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
return this;
};
@@ -320,7 +321,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.choose = function (args) {
- this._bytecode.addStep('choose', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
return this;
};
@@ -329,7 +330,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.coalesce = function (args) {
- this._bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
return this;
};
@@ -338,7 +339,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.coin = function (args) {
- this._bytecode.addStep('coin', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
return this;
};
@@ -347,7 +348,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.constant = function (args) {
- this._bytecode.addStep('constant', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
return this;
};
@@ -356,7 +357,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.count = function (args) {
- this._bytecode.addStep('count', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('count', parseArgs.apply(null, arguments));
return this;
};
@@ -365,7 +366,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.cyclicPath = function (args) {
- this._bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
return this;
};
@@ -374,7 +375,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.dedup = function (args) {
- this._bytecode.addStep('dedup', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
return this;
};
@@ -383,7 +384,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.drop = function (args) {
- this._bytecode.addStep('drop', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
return this;
};
@@ -392,7 +393,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.emit = function (args) {
- this._bytecode.addStep('emit', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
return this;
};
@@ -401,7 +402,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.filter = function (args) {
- this._bytecode.addStep('filter', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
return this;
};
@@ -410,7 +411,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.flatMap = function (args) {
- this._bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
return this;
};
@@ -419,7 +420,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.fold = function (args) {
- this._bytecode.addStep('fold', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
return this;
};
@@ -428,7 +429,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.from_ = function (args) {
- this._bytecode.addStep('from', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('from', parseArgs.apply(null, arguments));
return this;
};
@@ -437,7 +438,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.group = function (args) {
- this._bytecode.addStep('group', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('group', parseArgs.apply(null, arguments));
return this;
};
@@ -446,7 +447,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.groupCount = function (args) {
- this._bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
return this;
};
@@ -455,7 +456,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.groupV3d0 = function (args) {
- this._bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
return this;
};
@@ -464,7 +465,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.has = function (args) {
- this._bytecode.addStep('has', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('has', parseArgs.apply(null, arguments));
return this;
};
@@ -473,7 +474,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.hasId = function (args) {
- this._bytecode.addStep('hasId', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
return this;
};
@@ -482,7 +483,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.hasKey = function (args) {
- this._bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
return this;
};
@@ -491,7 +492,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.hasLabel = function (args) {
- this._bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
return this;
};
@@ -500,7 +501,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.hasNot = function (args) {
- this._bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
return this;
};
@@ -509,7 +510,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.hasValue = function (args) {
- this._bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
return this;
};
@@ -518,7 +519,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.id = function (args) {
- this._bytecode.addStep('id', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('id', parseArgs.apply(null, arguments));
return this;
};
@@ -527,7 +528,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.identity = function (args) {
- this._bytecode.addStep('identity', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
return this;
};
@@ -536,7 +537,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.inE = function (args) {
- this._bytecode.addStep('inE', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
return this;
};
@@ -545,7 +546,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.inV = function (args) {
- this._bytecode.addStep('inV', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
return this;
};
@@ -554,7 +555,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.in_ = function (args) {
- this._bytecode.addStep('in', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('in', parseArgs.apply(null, arguments));
return this;
};
@@ -563,7 +564,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.inject = function (args) {
- this._bytecode.addStep('inject', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
return this;
};
@@ -572,7 +573,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.is = function (args) {
- this._bytecode.addStep('is', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('is', parseArgs.apply(null, arguments));
return this;
};
@@ -581,7 +582,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.key = function (args) {
- this._bytecode.addStep('key', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('key', parseArgs.apply(null, arguments));
return this;
};
@@ -590,7 +591,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.label = function (args) {
- this._bytecode.addStep('label', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('label', parseArgs.apply(null, arguments));
return this;
};
@@ -599,7 +600,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.limit = function (args) {
- this._bytecode.addStep('limit', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
return this;
};
@@ -608,7 +609,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.local = function (args) {
- this._bytecode.addStep('local', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('local', parseArgs.apply(null, arguments));
return this;
};
@@ -617,7 +618,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.loops = function (args) {
- this._bytecode.addStep('loops', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
return this;
};
@@ -626,7 +627,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.map = function (args) {
- this._bytecode.addStep('map', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('map', parseArgs.apply(null, arguments));
return this;
};
@@ -635,7 +636,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.mapKeys = function (args) {
- this._bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
return this;
};
@@ -644,7 +645,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.mapValues = function (args) {
- this._bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
return this;
};
@@ -653,7 +654,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.match = function (args) {
- this._bytecode.addStep('match', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('match', parseArgs.apply(null, arguments));
return this;
};
@@ -662,7 +663,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.max = function (args) {
- this._bytecode.addStep('max', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('max', parseArgs.apply(null, arguments));
return this;
};
@@ -671,7 +672,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.mean = function (args) {
- this._bytecode.addStep('mean', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
return this;
};
@@ -680,7 +681,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.min = function (args) {
- this._bytecode.addStep('min', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('min', parseArgs.apply(null, arguments));
return this;
};
@@ -689,7 +690,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.not = function (args) {
- this._bytecode.addStep('not', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('not', parseArgs.apply(null, arguments));
return this;
};
@@ -698,7 +699,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.option = function (args) {
- this._bytecode.addStep('option', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('option', parseArgs.apply(null, arguments));
return this;
};
@@ -707,7 +708,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.optional = function (args) {
- this._bytecode.addStep('optional', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
return this;
};
@@ -716,7 +717,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.or = function (args) {
- this._bytecode.addStep('or', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('or', parseArgs.apply(null, arguments));
return this;
};
@@ -725,7 +726,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.order = function (args) {
- this._bytecode.addStep('order', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('order', parseArgs.apply(null, arguments));
return this;
};
@@ -734,7 +735,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.otherV = function (args) {
- this._bytecode.addStep('otherV', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
return this;
};
@@ -743,7 +744,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.out = function (args) {
- this._bytecode.addStep('out', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('out', parseArgs.apply(null, arguments));
return this;
};
@@ -752,7 +753,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.outE = function (args) {
- this._bytecode.addStep('outE', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
return this;
};
@@ -761,7 +762,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.outV = function (args) {
- this._bytecode.addStep('outV', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
return this;
};
@@ -770,7 +771,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.pageRank = function (args) {
- this._bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
return this;
};
@@ -779,7 +780,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.path = function (args) {
- this._bytecode.addStep('path', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('path', parseArgs.apply(null, arguments));
return this;
};
@@ -788,7 +789,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.peerPressure = function (args) {
- this._bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
return this;
};
@@ -797,7 +798,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.profile = function (args) {
- this._bytecode.addStep('profile', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
return this;
};
@@ -806,7 +807,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.program = function (args) {
- this._bytecode.addStep('program', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('program', parseArgs.apply(null, arguments));
return this;
};
@@ -815,7 +816,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.project = function (args) {
- this._bytecode.addStep('project', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('project', parseArgs.apply(null, arguments));
return this;
};
@@ -824,7 +825,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.properties = function (args) {
- this._bytecode.addStep('properties', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
return this;
};
@@ -833,7 +834,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.property = function (args) {
- this._bytecode.addStep('property', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('property', parseArgs.apply(null, arguments));
return this;
};
@@ -842,7 +843,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.propertyMap = function (args) {
- this._bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
return this;
};
@@ -851,7 +852,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.range = function (args) {
- this._bytecode.addStep('range', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('range', parseArgs.apply(null, arguments));
return this;
};
@@ -860,7 +861,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.repeat = function (args) {
- this._bytecode.addStep('repeat', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
return this;
};
@@ -869,7 +870,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.sack = function (args) {
- this._bytecode.addStep('sack', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
return this;
};
@@ -878,7 +879,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.sample = function (args) {
- this._bytecode.addStep('sample', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
return this;
};
@@ -887,7 +888,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.select = function (args) {
- this._bytecode.addStep('select', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('select', parseArgs.apply(null, arguments));
return this;
};
@@ -896,7 +897,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.sideEffect = function (args) {
- this._bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
return this;
};
@@ -905,7 +906,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.simplePath = function (args) {
- this._bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
return this;
};
@@ -914,7 +915,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.store = function (args) {
- this._bytecode.addStep('store', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('store', parseArgs.apply(null, arguments));
return this;
};
@@ -923,7 +924,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.subgraph = function (args) {
- this._bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
return this;
};
@@ -932,7 +933,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.sum = function (args) {
- this._bytecode.addStep('sum', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
return this;
};
@@ -941,7 +942,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.tail = function (args) {
- this._bytecode.addStep('tail', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
return this;
};
@@ -950,7 +951,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.timeLimit = function (args) {
- this._bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
return this;
};
@@ -959,7 +960,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.times = function (args) {
- this._bytecode.addStep('times', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('times', parseArgs.apply(null, arguments));
return this;
};
@@ -968,7 +969,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.to = function (args) {
- this._bytecode.addStep('to', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('to', parseArgs.apply(null, arguments));
return this;
};
@@ -977,7 +978,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.toE = function (args) {
- this._bytecode.addStep('toE', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
return this;
};
@@ -986,7 +987,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.toV = function (args) {
- this._bytecode.addStep('toV', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
return this;
};
@@ -995,7 +996,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.tree = function (args) {
- this._bytecode.addStep('tree', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
return this;
};
@@ -1004,7 +1005,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.unfold = function (args) {
- this._bytecode.addStep('unfold', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
return this;
};
@@ -1013,7 +1014,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.union = function (args) {
- this._bytecode.addStep('union', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('union', parseArgs.apply(null, arguments));
return this;
};
@@ -1022,7 +1023,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.until = function (args) {
- this._bytecode.addStep('until', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('until', parseArgs.apply(null, arguments));
return this;
};
@@ -1031,7 +1032,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.value = function (args) {
- this._bytecode.addStep('value', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('value', parseArgs.apply(null, arguments));
return this;
};
@@ -1040,7 +1041,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.valueMap = function (args) {
- this._bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
return this;
};
@@ -1049,7 +1050,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.values = function (args) {
- this._bytecode.addStep('values', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('values', parseArgs.apply(null, arguments));
return this;
};
@@ -1058,7 +1059,7 @@
* @returns {GraphTraversal}
*/
GraphTraversal.prototype.where = function (args) {
- this._bytecode.addStep('where', parseArgs.apply(null, arguments));
+ this.bytecode.addStep('where', parseArgs.apply(null, arguments));
return this;
};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6b3bd9d8/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index ff2927e..a7a9bb7 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -24,22 +24,22 @@
"use strict";
function Traversal(graph, traversalStrategies, bytecode) {
- this._graph = graph;
- this._traversalStrategies = traversalStrategies;
- this._bytecode = bytecode;
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode;
this.traversers = null;
this.sideEffects = null;
}
/** @returns {Bytecode} */
Traversal.prototype.getBytecode = function () {
- return this._bytecode;
+ return this.bytecode;
};
/** @param {Function} callback */
Traversal.prototype.list = function (callback) {
var self = this;
- this._traversalStrategies.applyStrategies(this, function (err) {
+ this.traversalStrategies.applyStrategies(this, function (err) {
if (err) {
return callback(err);
}
@@ -59,7 +59,7 @@
* @returns {String}
*/
Traversal.prototype.toString = function () {
- return this._bytecode.toString();
+ return this.bytecode.toString();
};
/**
[37/47] tinkerpop git commit: Move generation script to groovy file
Posted by jo...@apache.org.
Move generation script to groovy file
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2afd9716
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2afd9716
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2afd9716
Branch: refs/heads/master
Commit: 2afd97165500617a4217e46d48c690df45c83686
Parents: 843a727
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Jan 8 11:27:03 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:17 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/glv/generate.groovy | 107 +++++++++++++++++++
gremlin-javascript/pom.xml | 99 +++--------------
.../javascript/gremlin-javascript/package.json | 2 +-
3 files changed, 120 insertions(+), 88 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2afd9716/gremlin-javascript/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/generate.groovy b/gremlin-javascript/glv/generate.groovy
new file mode 100644
index 0000000..8fd22e3
--- /dev/null
+++ b/gremlin-javascript/glv/generate.groovy
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import groovy.text.GStringTemplateEngine
+import org.apache.tinkerpop.gremlin.jsr223.CoreImports
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
+import org.apache.tinkerpop.gremlin.process.traversal.P
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
+import java.lang.reflect.Modifier
+
+def toJsMap = ["in": "in_",
+ "from": "from_"]
+
+def toJs = { symbol -> toJsMap.getOrDefault(symbol, symbol) }
+
+def decapitalize = {
+ String string = it;
+ if (string == null || string.length() == 0) {
+ return string;
+ }
+ def c = string.toCharArray();
+ c[0] = Character.toLowerCase(c[0]);
+ return new String(c);
+}
+
+def determineVersion = {
+ def env = System.getenv()
+ def mavenVersion = env.containsKey("TP_RELEASE_VERSION") ? env.get("JS_RELEASE_VERSION") : project.version
+ return mavenVersion.replace("-SNAPSHOT", "-alpha1")
+}
+
+def binding = ["enums": CoreImports.getClassImports()
+ .findAll { Enum.class.isAssignableFrom(it) }
+ .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() },
+ "pmethods": P.class.getMethods().
+ findAll { Modifier.isStatic(it.getModifiers()) }.
+ findAll { P.class.isAssignableFrom(it.returnType) }.
+ collect { it.name }.
+ unique().
+ sort { a, b -> a <=> b },
+ "sourceStepMethods": GraphTraversalSource.getMethods(). // SOURCE STEPS
+ findAll { GraphTraversalSource.class.equals(it.returnType) }.
+ findAll {
+ !it.name.equals("clone") &&
+ // Use hardcoded name to be for forward-compatibility
+ !it.name.equals("withBindings") &&
+ !it.name.equals(TraversalSource.Symbols.withRemote) &&
+ !it.name.equals(TraversalSource.Symbols.withComputer)
+ }.
+ collect { it.name }.
+ unique().
+ sort { a, b -> a <=> b },
+ "sourceSpawnMethods": GraphTraversalSource.getMethods(). // SPAWN STEPS
+ findAll { GraphTraversal.class.equals(it.returnType) }.
+ collect { it.name }.
+ unique().
+ sort { a, b -> a <=> b },
+ "graphStepMethods": GraphTraversal.getMethods().
+ findAll { GraphTraversal.class.equals(it.returnType) }.
+ findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
+ collect { it.name }.
+ unique().
+ sort { a, b -> a <=> b },
+ "anonStepMethods": __.class.getMethods().
+ findAll { GraphTraversal.class.equals(it.returnType) }.
+ findAll { Modifier.isStatic(it.getModifiers()) }.
+ findAll { !it.name.equals("__") && !it.name.equals("start") }.
+ collect { it.name }.
+ unique().
+ sort { a, b -> a <=> b },
+ "toJs": toJs,
+ "version": determineVersion(),
+ "decapitalize": decapitalize]
+
+def engine = new GStringTemplateEngine()
+def graphTraversalTemplate = engine.createTemplate(new File("${project.basedir}/glv/GraphTraversalSource.template"))
+ .make(binding)
+def graphTraversalFile =
+ new File("${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js")
+graphTraversalFile.newWriter().withWriter{ it << graphTraversalTemplate }
+
+def traversalTemplate = engine.createTemplate(new File("${project.basedir}/glv/TraversalSource.template")).make(binding)
+def traversalFile = new File("${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/traversal.js")
+traversalFile.newWriter().withWriter{ it << traversalTemplate }
+
+def packageJsonTemplate = engine.createTemplate(new File("${project.basedir}/glv/PackageJson.template")).make(binding)
+def packageJsonFile = new File("${project.basedir}/src/main/javascript/gremlin-javascript/package.json")
+packageJsonFile.newWriter().withWriter{ it << packageJsonTemplate }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2afd9716/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index aa219ab..0825ba6 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
<parent>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>tinkerpop</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.2.8-SNAPSHOT</version>
</parent>
<artifactId>gremlin-javascript</artifactId>
<name>Apache TinkerPop :: Gremlin Javascript</name>
@@ -106,93 +106,18 @@ limitations under the License.
<goal>execute</goal>
</goals>
<configuration>
+ <properties>
+ <property>
+ <name>projectBaseDir</name>
+ <value>${project.basedir}</value>
+ </property>
+ <property>
+ <name>projectVersion</name>
+ <value>${project.version}</value>
+ </property>
+ </properties>
<scripts>
- <script><![CDATA[
-import org.apache.tinkerpop.gremlin.jsr223.CoreImports
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
-import org.apache.tinkerpop.gremlin.process.traversal.P
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
-import java.lang.reflect.Modifier
-
-def toJsMap = ["in": "in_",
- "from": "from_"]
-
-def toJs = { symbol -> toJsMap.getOrDefault(symbol, symbol) }
-
-def decapitalize = {
- String string = it;
- if (string == null || string.length() == 0) {
- return string;
- }
- def c = string.toCharArray();
- c[0] = Character.toLowerCase(c[0]);
- return new String(c);
-}
-
-def determineVersion = {
- def env = System.getenv()
- def mavenVersion = env.containsKey("TP_RELEASE_VERSION") ? env.get("JS_RELEASE_VERSION") : '${project.version}'
- return mavenVersion.replace("-SNAPSHOT", "-alpha1")
-}
-
-def binding = ["enums": CoreImports.getClassImports()
- .findAll { Enum.class.isAssignableFrom(it) }
- .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() },
- "pmethods": P.class.getMethods().
- findAll { Modifier.isStatic(it.getModifiers()) }.
- findAll { P.class.isAssignableFrom(it.returnType) }.
- collect { it.name }.
- unique().
- sort { a, b -> a <=> b },
- "sourceStepMethods": GraphTraversalSource.getMethods(). // SOURCE STEPS
- findAll { GraphTraversalSource.class.equals(it.returnType) }.
- findAll {
- !it.name.equals("clone") &&
- // Use hardcoded name to be for forward-compatibility
- !it.name.equals("withBindings") &&
- !it.name.equals(TraversalSource.Symbols.withRemote) &&
- !it.name.equals(TraversalSource.Symbols.withComputer)
- }.
- collect { it.name }.
- unique().
- sort { a, b -> a <=> b },
- "sourceSpawnMethods": GraphTraversalSource.getMethods(). // SPAWN STEPS
- findAll { GraphTraversal.class.equals(it.returnType) }.
- collect { it.name }.
- unique().
- sort { a, b -> a <=> b },
- "graphStepMethods": GraphTraversal.getMethods().
- findAll { GraphTraversal.class.equals(it.returnType) }.
- findAll { !it.name.equals("clone") && !it.name.equals("iterate") }.
- collect { it.name }.
- unique().
- sort { a, b -> a <=> b },
- "anonStepMethods": __.class.getMethods().
- findAll { GraphTraversal.class.equals(it.returnType) }.
- findAll { Modifier.isStatic(it.getModifiers()) }.
- findAll { !it.name.equals("__") && !it.name.equals("start") }.
- collect { it.name }.
- unique().
- sort { a, b -> a <=> b },
- "toJs": toJs,
- "version": determineVersion(),
- "decapitalize": decapitalize]
-
-def engine = new groovy.text.GStringTemplateEngine()
-def graphTraversalTemplate = engine.createTemplate(new File('${project.basedir}/glv/GraphTraversalSource.template')).make(binding)
-def graphTraversalFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js')
-graphTraversalFile.newWriter().withWriter{ it << graphTraversalTemplate }
-
-def traversalTemplate = engine.createTemplate(new File('${project.basedir}/glv/TraversalSource.template')).make(binding)
-def traversalFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/lib/process/traversal.js')
-traversalFile.newWriter().withWriter{ it << traversalTemplate }
-
-def packageJsonTemplate = engine.createTemplate(new File('${project.basedir}/glv/PackageJson.template')).make(binding)
-def packageJsonFile = new File('${project.basedir}/src/main/javascript/gremlin-javascript/package.json')
-packageJsonFile.newWriter().withWriter{ it << packageJsonTemplate }
-]]> </script>
+ <script>${project.basedir}/glv/generate.groovy</script>
</scripts>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2afd9716/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index aae9eb9..604354c 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -1,6 +1,6 @@
{
"name": "gremlin-javascript",
- "version": "3.2.7-alpha1",
+ "version": "3.2.8-alpha1",
"description": "JavaScript Gremlin Language Variant",
"author": "Apache TinkerPop team",
"keywords": [
[43/47] tinkerpop git commit: Use rest parameters and compact syntax
for statics
Posted by jo...@apache.org.
Use rest parameters and compact syntax for statics
- Use rest parameters
- Use a more compact declaration for methods on statics
- Bump engine to Node.js >= 6
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d37a3d8c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d37a3d8c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d37a3d8c
Branch: refs/heads/master
Commit: d37a3d8c9635d33cbd94c5e85959b89be12405d4
Parents: af718f7
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Jan 22 12:47:04 2018 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Mon Jan 22 15:31:27 2018 +0100
----------------------------------------------------------------------
.../glv/GraphTraversalSource.template | 32 +-
gremlin-javascript/glv/PackageJson.template | 9 +-
gremlin-javascript/glv/TraversalSource.template | 5 +-
gremlin-javascript/pom.xml | 4 +-
.../gremlin-javascript/lib/process/bytecode.js | 4 +-
.../lib/process/graph-traversal.js | 1440 ++++--------------
.../lib/process/traversal-strategy.js | 2 +-
.../gremlin-javascript/lib/process/traversal.js | 53 +-
.../javascript/gremlin-javascript/lib/utils.js | 4 -
.../javascript/gremlin-javascript/package.json | 9 +-
10 files changed, 370 insertions(+), 1192 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d37a3d8c/gremlin-javascript/glv/GraphTraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/GraphTraversalSource.template b/gremlin-javascript/glv/GraphTraversalSource.template
index 812cfcf..58be16c 100644
--- a/gremlin-javascript/glv/GraphTraversalSource.template
+++ b/gremlin-javascript/glv/GraphTraversalSource.template
@@ -27,7 +27,6 @@ const remote = require('../driver/remote-connection');
const utils = require('../utils');
const Bytecode = require('./bytecode');
const TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
-const parseArgs = utils.parseArgs;
/**
@@ -68,8 +67,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversalSource}
*/
- <%= toJs.call(method) %>(args) {
- const b = new Bytecode(this.bytecode).addSource('<%= method %>', parseArgs.apply(null, arguments));
+ <%= toJs.call(method) %>(...args) {
+ const b = new Bytecode(this.bytecode).addSource('<%= method %>', args);
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
<%
@@ -80,8 +79,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- <%= toJs.call(method) %>(args) {
- const b = new Bytecode(this.bytecode).addStep('<%= method %>', parseArgs.apply(null, arguments));
+ <%= toJs.call(method) %>(...args) {
+ const b = new Bytecode(this.bytecode).addStep('<%= method %>', args);
return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
<% } %>
@@ -100,29 +99,26 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- <%= toJs.call(method) %>(args) {
- this.bytecode.addStep('<%= method %>', parseArgs.apply(null, arguments));
+ <%= toJs.call(method) %>(...args) {
+ this.bytecode.addStep('<%= method %>', args);
return this;
}
<% } %>
}
+function callOnEmptyTraversal(fnName, args) {
+ const g = new GraphTraversal(null, null, new Bytecode());
+ return g[fnName].apply(g, args);
+}
+
/**
* Contains the static method definitions
* @type {Object}
*/
-const statics = {};
-<% anonStepMethods.each{ method -> %>
-/**
- * <%= method %>() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.<%= toJs.call(method) %> = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.<%= toJs.call(method) %>.apply(g, arguments);
+const statics = {<% anonStepMethods.eachWithIndex { method, i -> %>
+ <%= toJs.call(method) %>: (...args) => callOnEmptyTraversal('<%= toJs.call(method) %>', args)<%= i < anonStepMethods.size() - 1 ? "," : ""%><% } %>
};
-<% } %>
+
module.exports = {
GraphTraversal,
GraphTraversalSource,
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d37a3d8c/gremlin-javascript/glv/PackageJson.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template
index 1b54a87..c929e75 100644
--- a/gremlin-javascript/glv/PackageJson.template
+++ b/gremlin-javascript/glv/PackageJson.template
@@ -44,15 +44,16 @@
"type": "git",
"url": "https://github.com/apache/tinkerpop.git"
},
+ "homepage": "https://tinkerpop.apache.org/",
"bugs": {
"url": "https://issues.apache.org/jira/browse/TINKERPOP"
},
"scripts": {
- "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
- "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
- "unit-test": "./node_modules/.bin/mocha test/unit"
+ "test": "mocha test/unit test/integration -t 5000",
+ "features": "cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
+ "unit-test": "mocha test/unit"
},
"engines": {
- "node": ">=4"
+ "node": ">=6"
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d37a3d8c/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index 3f289e4..6965110 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -23,7 +23,6 @@
'use strict';
const utils = require('../utils');
-const parseArgs = utils.parseArgs;
const itemDone = Object.freeze({ value: null, done: true });
class Traversal {
@@ -143,8 +142,8 @@ class P {
}
<% pmethods.each{ method -> %>
/** @param {...Object} args */
- static <%= toJs.call(method) %>(args) {
- return createP('<%= method %>', parseArgs.apply(null, arguments));
+ static <%= toJs.call(method) %>(...args) {
+ return createP('<%= method %>', args);
}
<% } %>
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d37a3d8c/gremlin-javascript/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-javascript/pom.xml b/gremlin-javascript/pom.xml
index e55bc1e..f9f0c8e 100644
--- a/gremlin-javascript/pom.xml
+++ b/gremlin-javascript/pom.xml
@@ -243,7 +243,7 @@ limitations under the License.
<configuration>
<skip>${skipIntegrationTests}</skip>
<workingDirectory>src/main/javascript/gremlin-javascript</workingDirectory>
- <nodeVersion>v4.8.3</nodeVersion>
+ <nodeVersion>v6.12.3</nodeVersion>
</configuration>
</plugin>
<!--
@@ -291,7 +291,7 @@ limitations under the License.
<configuration>
<skip>${skipIntegrationTests}</skip>
<workingDirectory>src/main/javascript/gremlin-javascript</workingDirectory>
- <nodeVersion>v4.8.3</nodeVersion>
+ <nodeVersion>v6.12.3</nodeVersion>
</configuration>
</plugin>
</plugins>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d37a3d8c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
index 85a4fc2..0f5ba15 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/bytecode.js
@@ -33,8 +33,8 @@ class Bytecode {
this.stepInstructions = [];
}
else {
- this.sourceInstructions = toClone.sourceInstructions.slice(0);
- this.stepInstructions = toClone.stepInstructions.slice(0);
+ this.sourceInstructions = [...toClone.sourceInstructions];
+ this.stepInstructions = [...toClone.stepInstructions];
}
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d37a3d8c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
index 6dcd8f6..fe1e467 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
@@ -27,7 +27,6 @@ const remote = require('../driver/remote-connection');
const utils = require('../utils');
const Bytecode = require('./bytecode');
const TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
-const parseArgs = utils.parseArgs;
/**
@@ -68,8 +67,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversalSource}
*/
- withBulk(args) {
- const b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
+ withBulk(...args) {
+ const b = new Bytecode(this.bytecode).addSource('withBulk', args);
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
@@ -78,8 +77,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversalSource}
*/
- withPath(args) {
- const b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
+ withPath(...args) {
+ const b = new Bytecode(this.bytecode).addSource('withPath', args);
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
@@ -88,8 +87,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversalSource}
*/
- withSack(args) {
- const b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
+ withSack(...args) {
+ const b = new Bytecode(this.bytecode).addSource('withSack', args);
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
@@ -98,8 +97,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversalSource}
*/
- withSideEffect(args) {
- const b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
+ withSideEffect(...args) {
+ const b = new Bytecode(this.bytecode).addSource('withSideEffect', args);
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
@@ -108,8 +107,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversalSource}
*/
- withStrategies(args) {
- const b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
+ withStrategies(...args) {
+ const b = new Bytecode(this.bytecode).addSource('withStrategies', args);
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
@@ -118,8 +117,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversalSource}
*/
- withoutStrategies(args) {
- const b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
+ withoutStrategies(...args) {
+ const b = new Bytecode(this.bytecode).addSource('withoutStrategies', args);
return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
@@ -128,8 +127,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- E(args) {
- const b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
+ E(...args) {
+ const b = new Bytecode(this.bytecode).addStep('E', args);
return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
@@ -138,8 +137,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- V(args) {
- const b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
+ V(...args) {
+ const b = new Bytecode(this.bytecode).addStep('V', args);
return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
@@ -148,8 +147,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- addV(args) {
- const b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
+ addV(...args) {
+ const b = new Bytecode(this.bytecode).addStep('addV', args);
return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
@@ -158,8 +157,8 @@ class GraphTraversalSource {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- inject(args) {
- const b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
+ inject(...args) {
+ const b = new Bytecode(this.bytecode).addStep('inject', args);
return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
}
@@ -178,8 +177,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- V(args) {
- this.bytecode.addStep('V', parseArgs.apply(null, arguments));
+ V(...args) {
+ this.bytecode.addStep('V', args);
return this;
}
@@ -188,8 +187,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- addE(args) {
- this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
+ addE(...args) {
+ this.bytecode.addStep('addE', args);
return this;
}
@@ -198,8 +197,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- addInE(args) {
- this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
+ addInE(...args) {
+ this.bytecode.addStep('addInE', args);
return this;
}
@@ -208,8 +207,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- addOutE(args) {
- this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
+ addOutE(...args) {
+ this.bytecode.addStep('addOutE', args);
return this;
}
@@ -218,8 +217,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- addV(args) {
- this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
+ addV(...args) {
+ this.bytecode.addStep('addV', args);
return this;
}
@@ -228,8 +227,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- aggregate(args) {
- this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
+ aggregate(...args) {
+ this.bytecode.addStep('aggregate', args);
return this;
}
@@ -238,8 +237,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- and(args) {
- this.bytecode.addStep('and', parseArgs.apply(null, arguments));
+ and(...args) {
+ this.bytecode.addStep('and', args);
return this;
}
@@ -248,8 +247,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- as(args) {
- this.bytecode.addStep('as', parseArgs.apply(null, arguments));
+ as(...args) {
+ this.bytecode.addStep('as', args);
return this;
}
@@ -258,8 +257,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- barrier(args) {
- this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
+ barrier(...args) {
+ this.bytecode.addStep('barrier', args);
return this;
}
@@ -268,8 +267,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- both(args) {
- this.bytecode.addStep('both', parseArgs.apply(null, arguments));
+ both(...args) {
+ this.bytecode.addStep('both', args);
return this;
}
@@ -278,8 +277,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- bothE(args) {
- this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
+ bothE(...args) {
+ this.bytecode.addStep('bothE', args);
return this;
}
@@ -288,8 +287,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- bothV(args) {
- this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
+ bothV(...args) {
+ this.bytecode.addStep('bothV', args);
return this;
}
@@ -298,8 +297,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- branch(args) {
- this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
+ branch(...args) {
+ this.bytecode.addStep('branch', args);
return this;
}
@@ -308,8 +307,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- by(args) {
- this.bytecode.addStep('by', parseArgs.apply(null, arguments));
+ by(...args) {
+ this.bytecode.addStep('by', args);
return this;
}
@@ -318,8 +317,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- cap(args) {
- this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
+ cap(...args) {
+ this.bytecode.addStep('cap', args);
return this;
}
@@ -328,8 +327,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- choose(args) {
- this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
+ choose(...args) {
+ this.bytecode.addStep('choose', args);
return this;
}
@@ -338,8 +337,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- coalesce(args) {
- this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
+ coalesce(...args) {
+ this.bytecode.addStep('coalesce', args);
return this;
}
@@ -348,8 +347,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- coin(args) {
- this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
+ coin(...args) {
+ this.bytecode.addStep('coin', args);
return this;
}
@@ -358,8 +357,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- constant(args) {
- this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
+ constant(...args) {
+ this.bytecode.addStep('constant', args);
return this;
}
@@ -368,8 +367,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- count(args) {
- this.bytecode.addStep('count', parseArgs.apply(null, arguments));
+ count(...args) {
+ this.bytecode.addStep('count', args);
return this;
}
@@ -378,8 +377,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- cyclicPath(args) {
- this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
+ cyclicPath(...args) {
+ this.bytecode.addStep('cyclicPath', args);
return this;
}
@@ -388,8 +387,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- dedup(args) {
- this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
+ dedup(...args) {
+ this.bytecode.addStep('dedup', args);
return this;
}
@@ -398,8 +397,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- drop(args) {
- this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
+ drop(...args) {
+ this.bytecode.addStep('drop', args);
return this;
}
@@ -408,8 +407,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- emit(args) {
- this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
+ emit(...args) {
+ this.bytecode.addStep('emit', args);
return this;
}
@@ -418,8 +417,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- filter(args) {
- this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
+ filter(...args) {
+ this.bytecode.addStep('filter', args);
return this;
}
@@ -428,8 +427,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- flatMap(args) {
- this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
+ flatMap(...args) {
+ this.bytecode.addStep('flatMap', args);
return this;
}
@@ -438,8 +437,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- fold(args) {
- this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
+ fold(...args) {
+ this.bytecode.addStep('fold', args);
return this;
}
@@ -448,8 +447,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- from_(args) {
- this.bytecode.addStep('from', parseArgs.apply(null, arguments));
+ from_(...args) {
+ this.bytecode.addStep('from', args);
return this;
}
@@ -458,8 +457,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- group(args) {
- this.bytecode.addStep('group', parseArgs.apply(null, arguments));
+ group(...args) {
+ this.bytecode.addStep('group', args);
return this;
}
@@ -468,8 +467,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- groupCount(args) {
- this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
+ groupCount(...args) {
+ this.bytecode.addStep('groupCount', args);
return this;
}
@@ -478,8 +477,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- groupV3d0(args) {
- this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
+ groupV3d0(...args) {
+ this.bytecode.addStep('groupV3d0', args);
return this;
}
@@ -488,8 +487,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- has(args) {
- this.bytecode.addStep('has', parseArgs.apply(null, arguments));
+ has(...args) {
+ this.bytecode.addStep('has', args);
return this;
}
@@ -498,8 +497,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- hasId(args) {
- this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
+ hasId(...args) {
+ this.bytecode.addStep('hasId', args);
return this;
}
@@ -508,8 +507,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- hasKey(args) {
- this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
+ hasKey(...args) {
+ this.bytecode.addStep('hasKey', args);
return this;
}
@@ -518,8 +517,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- hasLabel(args) {
- this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
+ hasLabel(...args) {
+ this.bytecode.addStep('hasLabel', args);
return this;
}
@@ -528,8 +527,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- hasNot(args) {
- this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
+ hasNot(...args) {
+ this.bytecode.addStep('hasNot', args);
return this;
}
@@ -538,8 +537,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- hasValue(args) {
- this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
+ hasValue(...args) {
+ this.bytecode.addStep('hasValue', args);
return this;
}
@@ -548,8 +547,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- id(args) {
- this.bytecode.addStep('id', parseArgs.apply(null, arguments));
+ id(...args) {
+ this.bytecode.addStep('id', args);
return this;
}
@@ -558,8 +557,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- identity(args) {
- this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
+ identity(...args) {
+ this.bytecode.addStep('identity', args);
return this;
}
@@ -568,8 +567,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- in_(args) {
- this.bytecode.addStep('in', parseArgs.apply(null, arguments));
+ in_(...args) {
+ this.bytecode.addStep('in', args);
return this;
}
@@ -578,8 +577,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- inE(args) {
- this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
+ inE(...args) {
+ this.bytecode.addStep('inE', args);
return this;
}
@@ -588,8 +587,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- inV(args) {
- this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
+ inV(...args) {
+ this.bytecode.addStep('inV', args);
return this;
}
@@ -598,8 +597,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- inject(args) {
- this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
+ inject(...args) {
+ this.bytecode.addStep('inject', args);
return this;
}
@@ -608,8 +607,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- is(args) {
- this.bytecode.addStep('is', parseArgs.apply(null, arguments));
+ is(...args) {
+ this.bytecode.addStep('is', args);
return this;
}
@@ -618,8 +617,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- key(args) {
- this.bytecode.addStep('key', parseArgs.apply(null, arguments));
+ key(...args) {
+ this.bytecode.addStep('key', args);
return this;
}
@@ -628,8 +627,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- label(args) {
- this.bytecode.addStep('label', parseArgs.apply(null, arguments));
+ label(...args) {
+ this.bytecode.addStep('label', args);
return this;
}
@@ -638,8 +637,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- limit(args) {
- this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
+ limit(...args) {
+ this.bytecode.addStep('limit', args);
return this;
}
@@ -648,8 +647,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- local(args) {
- this.bytecode.addStep('local', parseArgs.apply(null, arguments));
+ local(...args) {
+ this.bytecode.addStep('local', args);
return this;
}
@@ -658,8 +657,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- loops(args) {
- this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
+ loops(...args) {
+ this.bytecode.addStep('loops', args);
return this;
}
@@ -668,8 +667,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- map(args) {
- this.bytecode.addStep('map', parseArgs.apply(null, arguments));
+ map(...args) {
+ this.bytecode.addStep('map', args);
return this;
}
@@ -678,8 +677,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- mapKeys(args) {
- this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
+ mapKeys(...args) {
+ this.bytecode.addStep('mapKeys', args);
return this;
}
@@ -688,8 +687,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- mapValues(args) {
- this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
+ mapValues(...args) {
+ this.bytecode.addStep('mapValues', args);
return this;
}
@@ -698,8 +697,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- match(args) {
- this.bytecode.addStep('match', parseArgs.apply(null, arguments));
+ match(...args) {
+ this.bytecode.addStep('match', args);
return this;
}
@@ -708,8 +707,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- max(args) {
- this.bytecode.addStep('max', parseArgs.apply(null, arguments));
+ max(...args) {
+ this.bytecode.addStep('max', args);
return this;
}
@@ -718,8 +717,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- mean(args) {
- this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
+ mean(...args) {
+ this.bytecode.addStep('mean', args);
return this;
}
@@ -728,8 +727,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- min(args) {
- this.bytecode.addStep('min', parseArgs.apply(null, arguments));
+ min(...args) {
+ this.bytecode.addStep('min', args);
return this;
}
@@ -738,8 +737,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- not(args) {
- this.bytecode.addStep('not', parseArgs.apply(null, arguments));
+ not(...args) {
+ this.bytecode.addStep('not', args);
return this;
}
@@ -748,8 +747,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- option(args) {
- this.bytecode.addStep('option', parseArgs.apply(null, arguments));
+ option(...args) {
+ this.bytecode.addStep('option', args);
return this;
}
@@ -758,8 +757,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- optional(args) {
- this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
+ optional(...args) {
+ this.bytecode.addStep('optional', args);
return this;
}
@@ -768,8 +767,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- or(args) {
- this.bytecode.addStep('or', parseArgs.apply(null, arguments));
+ or(...args) {
+ this.bytecode.addStep('or', args);
return this;
}
@@ -778,8 +777,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- order(args) {
- this.bytecode.addStep('order', parseArgs.apply(null, arguments));
+ order(...args) {
+ this.bytecode.addStep('order', args);
return this;
}
@@ -788,8 +787,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- otherV(args) {
- this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
+ otherV(...args) {
+ this.bytecode.addStep('otherV', args);
return this;
}
@@ -798,8 +797,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- out(args) {
- this.bytecode.addStep('out', parseArgs.apply(null, arguments));
+ out(...args) {
+ this.bytecode.addStep('out', args);
return this;
}
@@ -808,8 +807,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- outE(args) {
- this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
+ outE(...args) {
+ this.bytecode.addStep('outE', args);
return this;
}
@@ -818,8 +817,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- outV(args) {
- this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
+ outV(...args) {
+ this.bytecode.addStep('outV', args);
return this;
}
@@ -828,8 +827,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- pageRank(args) {
- this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
+ pageRank(...args) {
+ this.bytecode.addStep('pageRank', args);
return this;
}
@@ -838,8 +837,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- path(args) {
- this.bytecode.addStep('path', parseArgs.apply(null, arguments));
+ path(...args) {
+ this.bytecode.addStep('path', args);
return this;
}
@@ -848,8 +847,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- peerPressure(args) {
- this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
+ peerPressure(...args) {
+ this.bytecode.addStep('peerPressure', args);
return this;
}
@@ -858,8 +857,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- profile(args) {
- this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
+ profile(...args) {
+ this.bytecode.addStep('profile', args);
return this;
}
@@ -868,8 +867,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- program(args) {
- this.bytecode.addStep('program', parseArgs.apply(null, arguments));
+ program(...args) {
+ this.bytecode.addStep('program', args);
return this;
}
@@ -878,8 +877,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- project(args) {
- this.bytecode.addStep('project', parseArgs.apply(null, arguments));
+ project(...args) {
+ this.bytecode.addStep('project', args);
return this;
}
@@ -888,8 +887,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- properties(args) {
- this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
+ properties(...args) {
+ this.bytecode.addStep('properties', args);
return this;
}
@@ -898,8 +897,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- property(args) {
- this.bytecode.addStep('property', parseArgs.apply(null, arguments));
+ property(...args) {
+ this.bytecode.addStep('property', args);
return this;
}
@@ -908,8 +907,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- propertyMap(args) {
- this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
+ propertyMap(...args) {
+ this.bytecode.addStep('propertyMap', args);
return this;
}
@@ -918,8 +917,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- range(args) {
- this.bytecode.addStep('range', parseArgs.apply(null, arguments));
+ range(...args) {
+ this.bytecode.addStep('range', args);
return this;
}
@@ -928,8 +927,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- repeat(args) {
- this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
+ repeat(...args) {
+ this.bytecode.addStep('repeat', args);
return this;
}
@@ -938,8 +937,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- sack(args) {
- this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
+ sack(...args) {
+ this.bytecode.addStep('sack', args);
return this;
}
@@ -948,8 +947,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- sample(args) {
- this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
+ sample(...args) {
+ this.bytecode.addStep('sample', args);
return this;
}
@@ -958,8 +957,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- select(args) {
- this.bytecode.addStep('select', parseArgs.apply(null, arguments));
+ select(...args) {
+ this.bytecode.addStep('select', args);
return this;
}
@@ -968,8 +967,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- sideEffect(args) {
- this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
+ sideEffect(...args) {
+ this.bytecode.addStep('sideEffect', args);
return this;
}
@@ -978,8 +977,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- simplePath(args) {
- this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
+ simplePath(...args) {
+ this.bytecode.addStep('simplePath', args);
return this;
}
@@ -988,8 +987,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- store(args) {
- this.bytecode.addStep('store', parseArgs.apply(null, arguments));
+ store(...args) {
+ this.bytecode.addStep('store', args);
return this;
}
@@ -998,8 +997,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- subgraph(args) {
- this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
+ subgraph(...args) {
+ this.bytecode.addStep('subgraph', args);
return this;
}
@@ -1008,8 +1007,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- sum(args) {
- this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
+ sum(...args) {
+ this.bytecode.addStep('sum', args);
return this;
}
@@ -1018,8 +1017,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- tail(args) {
- this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
+ tail(...args) {
+ this.bytecode.addStep('tail', args);
return this;
}
@@ -1028,8 +1027,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- timeLimit(args) {
- this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
+ timeLimit(...args) {
+ this.bytecode.addStep('timeLimit', args);
return this;
}
@@ -1038,8 +1037,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- times(args) {
- this.bytecode.addStep('times', parseArgs.apply(null, arguments));
+ times(...args) {
+ this.bytecode.addStep('times', args);
return this;
}
@@ -1048,8 +1047,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- to(args) {
- this.bytecode.addStep('to', parseArgs.apply(null, arguments));
+ to(...args) {
+ this.bytecode.addStep('to', args);
return this;
}
@@ -1058,8 +1057,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- toE(args) {
- this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
+ toE(...args) {
+ this.bytecode.addStep('toE', args);
return this;
}
@@ -1068,8 +1067,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- toV(args) {
- this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
+ toV(...args) {
+ this.bytecode.addStep('toV', args);
return this;
}
@@ -1078,8 +1077,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- tree(args) {
- this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
+ tree(...args) {
+ this.bytecode.addStep('tree', args);
return this;
}
@@ -1088,8 +1087,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- unfold(args) {
- this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
+ unfold(...args) {
+ this.bytecode.addStep('unfold', args);
return this;
}
@@ -1098,8 +1097,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- union(args) {
- this.bytecode.addStep('union', parseArgs.apply(null, arguments));
+ union(...args) {
+ this.bytecode.addStep('union', args);
return this;
}
@@ -1108,8 +1107,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- until(args) {
- this.bytecode.addStep('until', parseArgs.apply(null, arguments));
+ until(...args) {
+ this.bytecode.addStep('until', args);
return this;
}
@@ -1118,8 +1117,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- value(args) {
- this.bytecode.addStep('value', parseArgs.apply(null, arguments));
+ value(...args) {
+ this.bytecode.addStep('value', args);
return this;
}
@@ -1128,8 +1127,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- valueMap(args) {
- this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
+ valueMap(...args) {
+ this.bytecode.addStep('valueMap', args);
return this;
}
@@ -1138,8 +1137,8 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- values(args) {
- this.bytecode.addStep('values', parseArgs.apply(null, arguments));
+ values(...args) {
+ this.bytecode.addStep('values', args);
return this;
}
@@ -1148,927 +1147,114 @@ class GraphTraversal extends Traversal {
* @param {...Object} args
* @returns {GraphTraversal}
*/
- where(args) {
- this.bytecode.addStep('where', parseArgs.apply(null, arguments));
+ where(...args) {
+ this.bytecode.addStep('where', args);
return this;
}
}
-/**
- * Contains the static method definitions
- * @type {Object}
- */
-const statics = {};
-
-/**
- * V() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.V = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.V.apply(g, arguments);
-};
-
-/**
- * addE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.addE = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.addE.apply(g, arguments);
-};
-
-/**
- * addInE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.addInE = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.addInE.apply(g, arguments);
-};
-
-/**
- * addOutE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.addOutE = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.addOutE.apply(g, arguments);
-};
-
-/**
- * addV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.addV = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.addV.apply(g, arguments);
-};
-
-/**
- * aggregate() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.aggregate = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.aggregate.apply(g, arguments);
-};
-
-/**
- * and() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.and = function (args) {
+function callOnEmptyTraversal(fnName, args) {
const g = new GraphTraversal(null, null, new Bytecode());
- return g.and.apply(g, arguments);
-};
-
-/**
- * as() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.as = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.as.apply(g, arguments);
-};
-
-/**
- * barrier() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.barrier = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.barrier.apply(g, arguments);
-};
-
-/**
- * both() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.both = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.both.apply(g, arguments);
-};
-
-/**
- * bothE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.bothE = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.bothE.apply(g, arguments);
-};
-
-/**
- * bothV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.bothV = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.bothV.apply(g, arguments);
-};
-
-/**
- * branch() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.branch = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.branch.apply(g, arguments);
-};
-
-/**
- * cap() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.cap = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.cap.apply(g, arguments);
-};
-
-/**
- * choose() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.choose = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.choose.apply(g, arguments);
-};
-
-/**
- * coalesce() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.coalesce = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.coalesce.apply(g, arguments);
-};
-
-/**
- * coin() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.coin = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.coin.apply(g, arguments);
-};
-
-/**
- * constant() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.constant = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.constant.apply(g, arguments);
-};
-
-/**
- * count() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.count = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.count.apply(g, arguments);
-};
-
-/**
- * cyclicPath() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.cyclicPath = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.cyclicPath.apply(g, arguments);
-};
-
-/**
- * dedup() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.dedup = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.dedup.apply(g, arguments);
-};
-
-/**
- * drop() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.drop = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.drop.apply(g, arguments);
-};
-
-/**
- * emit() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.emit = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.emit.apply(g, arguments);
-};
-
-/**
- * filter() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.filter = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.filter.apply(g, arguments);
-};
-
-/**
- * flatMap() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.flatMap = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.flatMap.apply(g, arguments);
-};
-
-/**
- * fold() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.fold = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.fold.apply(g, arguments);
-};
-
-/**
- * group() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.group = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.group.apply(g, arguments);
-};
-
-/**
- * groupCount() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.groupCount = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.groupCount.apply(g, arguments);
-};
-
-/**
- * groupV3d0() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.groupV3d0 = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.groupV3d0.apply(g, arguments);
-};
-
-/**
- * has() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.has = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.has.apply(g, arguments);
-};
-
-/**
- * hasId() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.hasId = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.hasId.apply(g, arguments);
-};
-
-/**
- * hasKey() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.hasKey = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.hasKey.apply(g, arguments);
-};
-
-/**
- * hasLabel() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.hasLabel = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.hasLabel.apply(g, arguments);
-};
-
-/**
- * hasNot() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.hasNot = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.hasNot.apply(g, arguments);
-};
-
-/**
- * hasValue() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.hasValue = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.hasValue.apply(g, arguments);
-};
-
-/**
- * id() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.id = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.id.apply(g, arguments);
-};
-
-/**
- * identity() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.identity = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.identity.apply(g, arguments);
-};
-
-/**
- * in() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.in_ = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.in_.apply(g, arguments);
-};
-
-/**
- * inE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.inE = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.inE.apply(g, arguments);
-};
-
-/**
- * inV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.inV = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.inV.apply(g, arguments);
-};
-
-/**
- * inject() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.inject = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.inject.apply(g, arguments);
-};
-
-/**
- * is() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.is = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.is.apply(g, arguments);
-};
-
-/**
- * key() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.key = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.key.apply(g, arguments);
-};
-
-/**
- * label() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.label = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.label.apply(g, arguments);
-};
-
-/**
- * limit() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.limit = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.limit.apply(g, arguments);
-};
-
-/**
- * local() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.local = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.local.apply(g, arguments);
-};
-
-/**
- * loops() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.loops = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.loops.apply(g, arguments);
-};
-
-/**
- * map() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.map = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.map.apply(g, arguments);
-};
-
-/**
- * mapKeys() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.mapKeys = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.mapKeys.apply(g, arguments);
-};
-
-/**
- * mapValues() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.mapValues = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.mapValues.apply(g, arguments);
-};
-
-/**
- * match() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.match = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.match.apply(g, arguments);
-};
-
-/**
- * max() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.max = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.max.apply(g, arguments);
-};
-
-/**
- * mean() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.mean = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.mean.apply(g, arguments);
-};
-
-/**
- * min() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.min = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.min.apply(g, arguments);
-};
-
-/**
- * not() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.not = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.not.apply(g, arguments);
-};
-
-/**
- * optional() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.optional = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.optional.apply(g, arguments);
-};
-
-/**
- * or() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.or = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.or.apply(g, arguments);
-};
-
-/**
- * order() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.order = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.order.apply(g, arguments);
-};
-
-/**
- * otherV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.otherV = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.otherV.apply(g, arguments);
-};
-
-/**
- * out() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.out = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.out.apply(g, arguments);
-};
-
-/**
- * outE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.outE = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.outE.apply(g, arguments);
-};
-
-/**
- * outV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.outV = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.outV.apply(g, arguments);
-};
-
-/**
- * path() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.path = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.path.apply(g, arguments);
-};
-
-/**
- * project() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.project = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.project.apply(g, arguments);
-};
-
-/**
- * properties() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.properties = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.properties.apply(g, arguments);
-};
-
-/**
- * property() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.property = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.property.apply(g, arguments);
-};
-
-/**
- * propertyMap() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.propertyMap = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.propertyMap.apply(g, arguments);
-};
-
-/**
- * range() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.range = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.range.apply(g, arguments);
-};
-
-/**
- * repeat() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.repeat = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.repeat.apply(g, arguments);
-};
-
-/**
- * sack() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.sack = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.sack.apply(g, arguments);
-};
-
-/**
- * sample() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.sample = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.sample.apply(g, arguments);
-};
-
-/**
- * select() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.select = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.select.apply(g, arguments);
-};
-
-/**
- * sideEffect() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.sideEffect = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.sideEffect.apply(g, arguments);
-};
-
-/**
- * simplePath() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.simplePath = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.simplePath.apply(g, arguments);
-};
-
-/**
- * store() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.store = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.store.apply(g, arguments);
-};
-
-/**
- * subgraph() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.subgraph = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.subgraph.apply(g, arguments);
-};
-
-/**
- * sum() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.sum = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.sum.apply(g, arguments);
-};
-
-/**
- * tail() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.tail = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.tail.apply(g, arguments);
-};
-
-/**
- * timeLimit() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.timeLimit = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.timeLimit.apply(g, arguments);
-};
-
-/**
- * times() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.times = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.times.apply(g, arguments);
-};
-
-/**
- * to() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.to = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.to.apply(g, arguments);
-};
-
-/**
- * toE() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.toE = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.toE.apply(g, arguments);
-};
-
-/**
- * toV() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.toV = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.toV.apply(g, arguments);
-};
-
-/**
- * tree() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.tree = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.tree.apply(g, arguments);
-};
-
-/**
- * unfold() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.unfold = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.unfold.apply(g, arguments);
-};
-
-/**
- * union() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.union = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.union.apply(g, arguments);
-};
-
-/**
- * until() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.until = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.until.apply(g, arguments);
-};
-
-/**
- * value() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.value = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.value.apply(g, arguments);
-};
-
-/**
- * valueMap() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.valueMap = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.valueMap.apply(g, arguments);
-};
-
-/**
- * values() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-statics.values = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.values.apply(g, arguments);
-};
+ return g[fnName].apply(g, args);
+}
/**
- * where() static method
- * @param {...Object} args
- * @returns {GraphTraversal}
+ * Contains the static method definitions
+ * @type {Object}
*/
-statics.where = function (args) {
- const g = new GraphTraversal(null, null, new Bytecode());
- return g.where.apply(g, arguments);
+const statics = {
+ V: (...args) => callOnEmptyTraversal('V', args),
+ addE: (...args) => callOnEmptyTraversal('addE', args),
+ addInE: (...args) => callOnEmptyTraversal('addInE', args),
+ addOutE: (...args) => callOnEmptyTraversal('addOutE', args),
+ addV: (...args) => callOnEmptyTraversal('addV', args),
+ aggregate: (...args) => callOnEmptyTraversal('aggregate', args),
+ and: (...args) => callOnEmptyTraversal('and', args),
+ as: (...args) => callOnEmptyTraversal('as', args),
+ barrier: (...args) => callOnEmptyTraversal('barrier', args),
+ both: (...args) => callOnEmptyTraversal('both', args),
+ bothE: (...args) => callOnEmptyTraversal('bothE', args),
+ bothV: (...args) => callOnEmptyTraversal('bothV', args),
+ branch: (...args) => callOnEmptyTraversal('branch', args),
+ cap: (...args) => callOnEmptyTraversal('cap', args),
+ choose: (...args) => callOnEmptyTraversal('choose', args),
+ coalesce: (...args) => callOnEmptyTraversal('coalesce', args),
+ coin: (...args) => callOnEmptyTraversal('coin', args),
+ constant: (...args) => callOnEmptyTraversal('constant', args),
+ count: (...args) => callOnEmptyTraversal('count', args),
+ cyclicPath: (...args) => callOnEmptyTraversal('cyclicPath', args),
+ dedup: (...args) => callOnEmptyTraversal('dedup', args),
+ drop: (...args) => callOnEmptyTraversal('drop', args),
+ emit: (...args) => callOnEmptyTraversal('emit', args),
+ filter: (...args) => callOnEmptyTraversal('filter', args),
+ flatMap: (...args) => callOnEmptyTraversal('flatMap', args),
+ fold: (...args) => callOnEmptyTraversal('fold', args),
+ group: (...args) => callOnEmptyTraversal('group', args),
+ groupCount: (...args) => callOnEmptyTraversal('groupCount', args),
+ groupV3d0: (...args) => callOnEmptyTraversal('groupV3d0', args),
+ has: (...args) => callOnEmptyTraversal('has', args),
+ hasId: (...args) => callOnEmptyTraversal('hasId', args),
+ hasKey: (...args) => callOnEmptyTraversal('hasKey', args),
+ hasLabel: (...args) => callOnEmptyTraversal('hasLabel', args),
+ hasNot: (...args) => callOnEmptyTraversal('hasNot', args),
+ hasValue: (...args) => callOnEmptyTraversal('hasValue', args),
+ id: (...args) => callOnEmptyTraversal('id', args),
+ identity: (...args) => callOnEmptyTraversal('identity', args),
+ in_: (...args) => callOnEmptyTraversal('in_', args),
+ inE: (...args) => callOnEmptyTraversal('inE', args),
+ inV: (...args) => callOnEmptyTraversal('inV', args),
+ inject: (...args) => callOnEmptyTraversal('inject', args),
+ is: (...args) => callOnEmptyTraversal('is', args),
+ key: (...args) => callOnEmptyTraversal('key', args),
+ label: (...args) => callOnEmptyTraversal('label', args),
+ limit: (...args) => callOnEmptyTraversal('limit', args),
+ local: (...args) => callOnEmptyTraversal('local', args),
+ loops: (...args) => callOnEmptyTraversal('loops', args),
+ map: (...args) => callOnEmptyTraversal('map', args),
+ mapKeys: (...args) => callOnEmptyTraversal('mapKeys', args),
+ mapValues: (...args) => callOnEmptyTraversal('mapValues', args),
+ match: (...args) => callOnEmptyTraversal('match', args),
+ max: (...args) => callOnEmptyTraversal('max', args),
+ mean: (...args) => callOnEmptyTraversal('mean', args),
+ min: (...args) => callOnEmptyTraversal('min', args),
+ not: (...args) => callOnEmptyTraversal('not', args),
+ optional: (...args) => callOnEmptyTraversal('optional', args),
+ or: (...args) => callOnEmptyTraversal('or', args),
+ order: (...args) => callOnEmptyTraversal('order', args),
+ otherV: (...args) => callOnEmptyTraversal('otherV', args),
+ out: (...args) => callOnEmptyTraversal('out', args),
+ outE: (...args) => callOnEmptyTraversal('outE', args),
+ outV: (...args) => callOnEmptyTraversal('outV', args),
+ path: (...args) => callOnEmptyTraversal('path', args),
+ project: (...args) => callOnEmptyTraversal('project', args),
+ properties: (...args) => callOnEmptyTraversal('properties', args),
+ property: (...args) => callOnEmptyTraversal('property', args),
+ propertyMap: (...args) => callOnEmptyTraversal('propertyMap', args),
+ range: (...args) => callOnEmptyTraversal('range', args),
+ repeat: (...args) => callOnEmptyTraversal('repeat', args),
+ sack: (...args) => callOnEmptyTraversal('sack', args),
+ sample: (...args) => callOnEmptyTraversal('sample', args),
+ select: (...args) => callOnEmptyTraversal('select', args),
+ sideEffect: (...args) => callOnEmptyTraversal('sideEffect', args),
+ simplePath: (...args) => callOnEmptyTraversal('simplePath', args),
+ store: (...args) => callOnEmptyTraversal('store', args),
+ subgraph: (...args) => callOnEmptyTraversal('subgraph', args),
+ sum: (...args) => callOnEmptyTraversal('sum', args),
+ tail: (...args) => callOnEmptyTraversal('tail', args),
+ timeLimit: (...args) => callOnEmptyTraversal('timeLimit', args),
+ times: (...args) => callOnEmptyTraversal('times', args),
+ to: (...args) => callOnEmptyTraversal('to', args),
+ toE: (...args) => callOnEmptyTraversal('toE', args),
+ toV: (...args) => callOnEmptyTraversal('toV', args),
+ tree: (...args) => callOnEmptyTraversal('tree', args),
+ unfold: (...args) => callOnEmptyTraversal('unfold', args),
+ union: (...args) => callOnEmptyTraversal('union', args),
+ until: (...args) => callOnEmptyTraversal('until', args),
+ value: (...args) => callOnEmptyTraversal('value', args),
+ valueMap: (...args) => callOnEmptyTraversal('valueMap', args),
+ values: (...args) => callOnEmptyTraversal('values', args),
+ where: (...args) => callOnEmptyTraversal('where', args)
};
module.exports = {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d37a3d8c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
index d3d97b8..1037f57 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
@@ -33,7 +33,7 @@ class TraversalStrategies {
constructor(parent) {
if (parent) {
// Clone the strategies
- this.strategies = parent.strategies.slice(0);
+ this.strategies = [...parent.strategies];
}
else {
this.strategies = [];
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d37a3d8c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index a8d066a..4464097 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -23,7 +23,6 @@
'use strict';
const utils = require('../utils');
-const parseArgs = utils.parseArgs;
const itemDone = Object.freeze({ value: null, done: true });
class Traversal {
@@ -143,68 +142,68 @@ class P {
}
/** @param {...Object} args */
- static between(args) {
- return createP('between', parseArgs.apply(null, arguments));
+ static between(...args) {
+ return createP('between', args);
}
/** @param {...Object} args */
- static eq(args) {
- return createP('eq', parseArgs.apply(null, arguments));
+ static eq(...args) {
+ return createP('eq', args);
}
/** @param {...Object} args */
- static gt(args) {
- return createP('gt', parseArgs.apply(null, arguments));
+ static gt(...args) {
+ return createP('gt', args);
}
/** @param {...Object} args */
- static gte(args) {
- return createP('gte', parseArgs.apply(null, arguments));
+ static gte(...args) {
+ return createP('gte', args);
}
/** @param {...Object} args */
- static inside(args) {
- return createP('inside', parseArgs.apply(null, arguments));
+ static inside(...args) {
+ return createP('inside', args);
}
/** @param {...Object} args */
- static lt(args) {
- return createP('lt', parseArgs.apply(null, arguments));
+ static lt(...args) {
+ return createP('lt', args);
}
/** @param {...Object} args */
- static lte(args) {
- return createP('lte', parseArgs.apply(null, arguments));
+ static lte(...args) {
+ return createP('lte', args);
}
/** @param {...Object} args */
- static neq(args) {
- return createP('neq', parseArgs.apply(null, arguments));
+ static neq(...args) {
+ return createP('neq', args);
}
/** @param {...Object} args */
- static not(args) {
- return createP('not', parseArgs.apply(null, arguments));
+ static not(...args) {
+ return createP('not', args);
}
/** @param {...Object} args */
- static outside(args) {
- return createP('outside', parseArgs.apply(null, arguments));
+ static outside(...args) {
+ return createP('outside', args);
}
/** @param {...Object} args */
- static test(args) {
- return createP('test', parseArgs.apply(null, arguments));
+ static test(...args) {
+ return createP('test', args);
}
/** @param {...Object} args */
- static within(args) {
- return createP('within', parseArgs.apply(null, arguments));
+ static within(...args) {
+ return createP('within', args);
}
/** @param {...Object} args */
- static without(args) {
- return createP('without', parseArgs.apply(null, arguments));
+ static without(...args) {
+ return createP('without', args);
}
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d37a3d8c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
index c864efd..e3a001c 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
@@ -23,10 +23,6 @@
*/
'use strict';
-exports.parseArgs = function parseArgs() {
- return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
-};
-
exports.toLong = function toLong(value) {
return new Long(value);
};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d37a3d8c/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index 604354c..c668be7 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -25,15 +25,16 @@
"type": "git",
"url": "https://github.com/apache/tinkerpop.git"
},
+ "homepage": "https://tinkerpop.apache.org/",
"bugs": {
"url": "https://issues.apache.org/jira/browse/TINKERPOP"
},
"scripts": {
- "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
- "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
- "unit-test": "./node_modules/.bin/mocha test/unit"
+ "test": "mocha test/unit test/integration -t 5000",
+ "features": "cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
+ "unit-test": "mocha test/unit"
},
"engines": {
- "node": ">=4"
+ "node": ">=6"
}
}
\ No newline at end of file
[06/47] tinkerpop git commit: Update Javascript GLV
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
new file mode 100644
index 0000000..5ee734a1
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
@@ -0,0 +1,2095 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var t = require('./traversal.js');
+var remote = require('../driver/remote-connection');
+var utils = require('../utils');
+var Bytecode = require('./bytecode');
+var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
+var inherits = utils.inherits;
+var parseArgs = utils.parseArgs;
+
+/**
+ *
+ * @param {Graph} graph
+ * @param {TraversalStrategies} traversalStrategies
+ * @param {Bytecode} [bytecode]
+ * @constructor
+ */
+function GraphTraversalSource(graph, traversalStrategies, bytecode) {
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode || new Bytecode();
+}
+
+/**
+ * @param remoteConnection
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
+ var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
+ traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+ return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
+};
+
+/**
+ * Returns the string representation of the GraphTraversalSource.
+ * @returns {string}
+ */
+GraphTraversalSource.prototype.toString = function () {
+ return 'graphtraversalsource[' + this.graph.toString() + ']';
+};
+
+/**
+ * Graph Traversal Source withBulk method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withBulk = function (args) {
+ var b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withComputer method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withComputer = function (args) {
+ var b = new Bytecode(this.bytecode).addSource('withComputer', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withPath method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withPath = function (args) {
+ var b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withSack method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withSack = function (args) {
+ var b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withSideEffect method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withSideEffect = function (args) {
+ var b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withStrategies method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withStrategies = function (args) {
+ var b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Graph Traversal Source withoutStrategies method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+GraphTraversalSource.prototype.withoutStrategies = function (args) {
+ var b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * E GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.E = function (args) {
+ var b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * V GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.V = function (args) {
+ var b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * addV GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.addV = function (args) {
+ var b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * inject GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversalSource.prototype.inject = function (args) {
+ var b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+};
+
+/**
+ * Represents a graph traversal.
+ * @extends Traversal
+ * @constructor
+ */
+function GraphTraversal(graph, traversalStrategies, bytecode) {
+ t.Traversal.call(this, graph, traversalStrategies, bytecode);
+}
+
+inherits(GraphTraversal, t.Traversal);
+
+/**
+ * Graph traversal V method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.V = function (args) {
+ this.bytecode.addStep('V', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal addE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.addE = function (args) {
+ this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal addInE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.addInE = function (args) {
+ this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal addOutE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.addOutE = function (args) {
+ this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal addV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.addV = function (args) {
+ this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal aggregate method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.aggregate = function (args) {
+ this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal and method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.and = function (args) {
+ this.bytecode.addStep('and', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal as method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.as = function (args) {
+ this.bytecode.addStep('as', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal barrier method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.barrier = function (args) {
+ this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal both method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.both = function (args) {
+ this.bytecode.addStep('both', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal bothE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.bothE = function (args) {
+ this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal bothV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.bothV = function (args) {
+ this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal branch method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.branch = function (args) {
+ this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal by method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.by = function (args) {
+ this.bytecode.addStep('by', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal cap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.cap = function (args) {
+ this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal choose method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.choose = function (args) {
+ this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal coalesce method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.coalesce = function (args) {
+ this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal coin method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.coin = function (args) {
+ this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal constant method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.constant = function (args) {
+ this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal count method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.count = function (args) {
+ this.bytecode.addStep('count', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal cyclicPath method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.cyclicPath = function (args) {
+ this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal dedup method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.dedup = function (args) {
+ this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal drop method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.drop = function (args) {
+ this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal emit method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.emit = function (args) {
+ this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal filter method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.filter = function (args) {
+ this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal flatMap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.flatMap = function (args) {
+ this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal fold method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.fold = function (args) {
+ this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal from method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.from_ = function (args) {
+ this.bytecode.addStep('from', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal group method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.group = function (args) {
+ this.bytecode.addStep('group', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal groupCount method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.groupCount = function (args) {
+ this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal groupV3d0 method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.groupV3d0 = function (args) {
+ this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal has method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.has = function (args) {
+ this.bytecode.addStep('has', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal hasId method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.hasId = function (args) {
+ this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal hasKey method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.hasKey = function (args) {
+ this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal hasLabel method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.hasLabel = function (args) {
+ this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal hasNot method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.hasNot = function (args) {
+ this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal hasValue method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.hasValue = function (args) {
+ this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal id method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.id = function (args) {
+ this.bytecode.addStep('id', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal identity method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.identity = function (args) {
+ this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal in method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.in_ = function (args) {
+ this.bytecode.addStep('in', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal inE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.inE = function (args) {
+ this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal inV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.inV = function (args) {
+ this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal inject method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.inject = function (args) {
+ this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal is method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.is = function (args) {
+ this.bytecode.addStep('is', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal key method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.key = function (args) {
+ this.bytecode.addStep('key', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal label method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.label = function (args) {
+ this.bytecode.addStep('label', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal limit method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.limit = function (args) {
+ this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal local method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.local = function (args) {
+ this.bytecode.addStep('local', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal loops method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.loops = function (args) {
+ this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal map method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.map = function (args) {
+ this.bytecode.addStep('map', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal mapKeys method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.mapKeys = function (args) {
+ this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal mapValues method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.mapValues = function (args) {
+ this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal match method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.match = function (args) {
+ this.bytecode.addStep('match', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal max method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.max = function (args) {
+ this.bytecode.addStep('max', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal mean method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.mean = function (args) {
+ this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal min method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.min = function (args) {
+ this.bytecode.addStep('min', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal not method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.not = function (args) {
+ this.bytecode.addStep('not', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal option method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.option = function (args) {
+ this.bytecode.addStep('option', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal optional method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.optional = function (args) {
+ this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal or method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.or = function (args) {
+ this.bytecode.addStep('or', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal order method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.order = function (args) {
+ this.bytecode.addStep('order', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal otherV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.otherV = function (args) {
+ this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal out method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.out = function (args) {
+ this.bytecode.addStep('out', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal outE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.outE = function (args) {
+ this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal outV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.outV = function (args) {
+ this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal pageRank method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.pageRank = function (args) {
+ this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal path method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.path = function (args) {
+ this.bytecode.addStep('path', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal peerPressure method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.peerPressure = function (args) {
+ this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal profile method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.profile = function (args) {
+ this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal program method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.program = function (args) {
+ this.bytecode.addStep('program', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal project method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.project = function (args) {
+ this.bytecode.addStep('project', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal properties method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.properties = function (args) {
+ this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal property method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.property = function (args) {
+ this.bytecode.addStep('property', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal propertyMap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.propertyMap = function (args) {
+ this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal range method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.range = function (args) {
+ this.bytecode.addStep('range', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal repeat method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.repeat = function (args) {
+ this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal sack method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.sack = function (args) {
+ this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal sample method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.sample = function (args) {
+ this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal select method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.select = function (args) {
+ this.bytecode.addStep('select', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal sideEffect method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.sideEffect = function (args) {
+ this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal simplePath method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.simplePath = function (args) {
+ this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal store method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.store = function (args) {
+ this.bytecode.addStep('store', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal subgraph method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.subgraph = function (args) {
+ this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal sum method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.sum = function (args) {
+ this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal tail method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.tail = function (args) {
+ this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal timeLimit method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.timeLimit = function (args) {
+ this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal times method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.times = function (args) {
+ this.bytecode.addStep('times', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal to method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.to = function (args) {
+ this.bytecode.addStep('to', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal toE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.toE = function (args) {
+ this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal toV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.toV = function (args) {
+ this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal tree method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.tree = function (args) {
+ this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal unfold method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.unfold = function (args) {
+ this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal union method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.union = function (args) {
+ this.bytecode.addStep('union', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal until method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.until = function (args) {
+ this.bytecode.addStep('until', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal value method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.value = function (args) {
+ this.bytecode.addStep('value', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal valueMap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.valueMap = function (args) {
+ this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal values method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.values = function (args) {
+ this.bytecode.addStep('values', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Graph traversal where method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+GraphTraversal.prototype.where = function (args) {
+ this.bytecode.addStep('where', parseArgs.apply(null, arguments));
+ return this;
+};
+
+/**
+ * Contains the static method definitions
+ * @type {Object}
+ */
+var statics = {};
+
+/**
+ * V() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.V = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.V.apply(g, arguments);
+};
+
+/**
+ * addE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.addE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.addE.apply(g, arguments);
+};
+
+/**
+ * addInE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.addInE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.addInE.apply(g, arguments);
+};
+
+/**
+ * addOutE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.addOutE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.addOutE.apply(g, arguments);
+};
+
+/**
+ * addV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.addV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.addV.apply(g, arguments);
+};
+
+/**
+ * aggregate() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.aggregate = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.aggregate.apply(g, arguments);
+};
+
+/**
+ * and() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.and = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.and.apply(g, arguments);
+};
+
+/**
+ * as() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.as = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.as.apply(g, arguments);
+};
+
+/**
+ * barrier() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.barrier = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.barrier.apply(g, arguments);
+};
+
+/**
+ * both() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.both = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.both.apply(g, arguments);
+};
+
+/**
+ * bothE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.bothE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.bothE.apply(g, arguments);
+};
+
+/**
+ * bothV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.bothV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.bothV.apply(g, arguments);
+};
+
+/**
+ * branch() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.branch = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.branch.apply(g, arguments);
+};
+
+/**
+ * cap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.cap = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.cap.apply(g, arguments);
+};
+
+/**
+ * choose() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.choose = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.choose.apply(g, arguments);
+};
+
+/**
+ * coalesce() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.coalesce = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.coalesce.apply(g, arguments);
+};
+
+/**
+ * coin() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.coin = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.coin.apply(g, arguments);
+};
+
+/**
+ * constant() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.constant = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.constant.apply(g, arguments);
+};
+
+/**
+ * count() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.count = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.count.apply(g, arguments);
+};
+
+/**
+ * cyclicPath() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.cyclicPath = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.cyclicPath.apply(g, arguments);
+};
+
+/**
+ * dedup() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.dedup = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.dedup.apply(g, arguments);
+};
+
+/**
+ * drop() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.drop = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.drop.apply(g, arguments);
+};
+
+/**
+ * emit() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.emit = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.emit.apply(g, arguments);
+};
+
+/**
+ * filter() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.filter = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.filter.apply(g, arguments);
+};
+
+/**
+ * flatMap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.flatMap = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.flatMap.apply(g, arguments);
+};
+
+/**
+ * fold() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.fold = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.fold.apply(g, arguments);
+};
+
+/**
+ * group() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.group = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.group.apply(g, arguments);
+};
+
+/**
+ * groupCount() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.groupCount = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.groupCount.apply(g, arguments);
+};
+
+/**
+ * groupV3d0() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.groupV3d0 = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.groupV3d0.apply(g, arguments);
+};
+
+/**
+ * has() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.has = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.has.apply(g, arguments);
+};
+
+/**
+ * hasId() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.hasId = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.hasId.apply(g, arguments);
+};
+
+/**
+ * hasKey() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.hasKey = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.hasKey.apply(g, arguments);
+};
+
+/**
+ * hasLabel() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.hasLabel = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.hasLabel.apply(g, arguments);
+};
+
+/**
+ * hasNot() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.hasNot = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.hasNot.apply(g, arguments);
+};
+
+/**
+ * hasValue() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.hasValue = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.hasValue.apply(g, arguments);
+};
+
+/**
+ * id() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.id = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.id.apply(g, arguments);
+};
+
+/**
+ * identity() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.identity = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.identity.apply(g, arguments);
+};
+
+/**
+ * inE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.inE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.inE.apply(g, arguments);
+};
+
+/**
+ * inV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.inV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.inV.apply(g, arguments);
+};
+
+/**
+ * in_() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.in_ = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.in_.apply(g, arguments);
+};
+
+/**
+ * inject() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.inject = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.inject.apply(g, arguments);
+};
+
+/**
+ * is() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.is = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.is.apply(g, arguments);
+};
+
+/**
+ * key() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.key = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.key.apply(g, arguments);
+};
+
+/**
+ * label() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.label = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.label.apply(g, arguments);
+};
+
+/**
+ * limit() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.limit = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.limit.apply(g, arguments);
+};
+
+/**
+ * local() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.local = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.local.apply(g, arguments);
+};
+
+/**
+ * loops() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.loops = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.loops.apply(g, arguments);
+};
+
+/**
+ * map() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.map = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.map.apply(g, arguments);
+};
+
+/**
+ * mapKeys() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.mapKeys = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.mapKeys.apply(g, arguments);
+};
+
+/**
+ * mapValues() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.mapValues = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.mapValues.apply(g, arguments);
+};
+
+/**
+ * match() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.match = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.match.apply(g, arguments);
+};
+
+/**
+ * max() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.max = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.max.apply(g, arguments);
+};
+
+/**
+ * mean() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.mean = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.mean.apply(g, arguments);
+};
+
+/**
+ * min() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.min = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.min.apply(g, arguments);
+};
+
+/**
+ * not() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.not = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.not.apply(g, arguments);
+};
+
+/**
+ * optional() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.optional = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.optional.apply(g, arguments);
+};
+
+/**
+ * or() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.or = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.or.apply(g, arguments);
+};
+
+/**
+ * order() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.order = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.order.apply(g, arguments);
+};
+
+/**
+ * otherV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.otherV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.otherV.apply(g, arguments);
+};
+
+/**
+ * out() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.out = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.out.apply(g, arguments);
+};
+
+/**
+ * outE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.outE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.outE.apply(g, arguments);
+};
+
+/**
+ * outV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.outV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.outV.apply(g, arguments);
+};
+
+/**
+ * path() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.path = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.path.apply(g, arguments);
+};
+
+/**
+ * project() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.project = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.project.apply(g, arguments);
+};
+
+/**
+ * properties() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.properties = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.properties.apply(g, arguments);
+};
+
+/**
+ * property() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.property = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.property.apply(g, arguments);
+};
+
+/**
+ * propertyMap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.propertyMap = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.propertyMap.apply(g, arguments);
+};
+
+/**
+ * range() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.range = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.range.apply(g, arguments);
+};
+
+/**
+ * repeat() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.repeat = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.repeat.apply(g, arguments);
+};
+
+/**
+ * sack() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.sack = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.sack.apply(g, arguments);
+};
+
+/**
+ * sample() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.sample = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.sample.apply(g, arguments);
+};
+
+/**
+ * select() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.select = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.select.apply(g, arguments);
+};
+
+/**
+ * sideEffect() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.sideEffect = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.sideEffect.apply(g, arguments);
+};
+
+/**
+ * simplePath() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.simplePath = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.simplePath.apply(g, arguments);
+};
+
+/**
+ * start() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.start = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.start.apply(g, arguments);
+};
+
+/**
+ * store() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.store = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.store.apply(g, arguments);
+};
+
+/**
+ * subgraph() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.subgraph = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.subgraph.apply(g, arguments);
+};
+
+/**
+ * sum() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.sum = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.sum.apply(g, arguments);
+};
+
+/**
+ * tail() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.tail = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.tail.apply(g, arguments);
+};
+
+/**
+ * timeLimit() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.timeLimit = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.timeLimit.apply(g, arguments);
+};
+
+/**
+ * times() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.times = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.times.apply(g, arguments);
+};
+
+/**
+ * to() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.to = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.to.apply(g, arguments);
+};
+
+/**
+ * toE() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.toE = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.toE.apply(g, arguments);
+};
+
+/**
+ * toV() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.toV = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.toV.apply(g, arguments);
+};
+
+/**
+ * tree() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.tree = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.tree.apply(g, arguments);
+};
+
+/**
+ * unfold() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.unfold = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.unfold.apply(g, arguments);
+};
+
+/**
+ * union() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.union = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.union.apply(g, arguments);
+};
+
+/**
+ * until() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.until = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.until.apply(g, arguments);
+};
+
+/**
+ * value() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.value = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.value.apply(g, arguments);
+};
+
+/**
+ * valueMap() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.valueMap = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.valueMap.apply(g, arguments);
+};
+
+/**
+ * values() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.values = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.values.apply(g, arguments);
+};
+
+/**
+ * where() static method
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+statics.where = function (args) {
+ var g = new GraphTraversal(null, null, new Bytecode());
+ return g.where.apply(g, arguments);
+};
+
+module.exports = {
+ GraphTraversal: GraphTraversal,
+ GraphTraversalSource: GraphTraversalSource,
+ statics: statics
+};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
new file mode 100644
index 0000000..22d6498
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var utils = require('../utils');
+
+/**
+ * Creates a new instance of TraversalStrategies.
+ * @param {TraversalStrategies} [parent] The parent strategies from where to clone the values from.
+ * @param {Function} [promiseFactory] The factory used to create the A+ Promise instances. Use it when you want to
+ * create Promise instances without using ECMAScript Promise constructor, ie: bluebird or Q promises.
+ * @constructor
+ */
+function TraversalStrategies(parent, promiseFactory) {
+ if (parent) {
+ // Clone the strategies
+ this.strategies = parent.strategies.slice(0);
+ this.promiseFactory = parent.promiseFactory;
+ }
+ else {
+ this.strategies = [];
+ }
+ if (promiseFactory) {
+ this.promiseFactory = promiseFactory;
+ }
+}
+
+/** @param {TraversalStrategy} strategy */
+TraversalStrategies.prototype.addStrategy = function (strategy) {
+ this.strategies.push(strategy);
+};
+
+/**
+ * @param {Traversal} traversal
+ * @returns {Promise}
+ */
+TraversalStrategies.prototype.applyStrategies = function (traversal) {
+ // Apply all strategies serially
+ var self = this;
+ return this.strategies.reduce(function reduceItem(promise, strategy) {
+ return promise.then(function () {
+ return strategy.apply(traversal, self.promiseFactory);
+ });
+ }, utils.resolvedPromise(this.promiseFactory));
+};
+
+/**
+ * @abstract
+ * @constructor
+ */
+function TraversalStrategy() {
+
+}
+
+/**
+ * @abstract
+ * @param {Traversal} traversal
+ * @param {Function|undefined} promiseFactory
+ * @returns {Promise}
+ */
+TraversalStrategy.prototype.apply = function (traversal, promiseFactory) {
+
+};
+
+module.exports = {
+ TraversalStrategies: TraversalStrategies,
+ TraversalStrategy: TraversalStrategy
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
new file mode 100644
index 0000000..1cd6b53
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var utils = require('../utils');
+var parseArgs = utils.parseArgs;
+var itemDone = Object.freeze({ value: null, done: true });
+var emptyArray = Object.freeze([]);
+
+function Traversal(graph, traversalStrategies, bytecode) {
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode;
+ this.traversers = null;
+ this.sideEffects = null;
+ this._traversalStrategiesPromise = null;
+ this._traversersIteratorIndex = 0;
+}
+
+/** @returns {Bytecode} */
+Traversal.prototype.getBytecode = function () {
+ return this.bytecode;
+};
+
+/**
+ * Returns an Array containing the traverser objects.
+ * @returns {Promise.<Array>}
+ */
+Traversal.prototype.toList = function () {
+ var self = this;
+ return this._applyStrategies().then(function () {
+ if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+ return emptyArray;
+ }
+ var arr = new Array(self.traversers.length - self._traversersIteratorIndex);
+ for (var i = self._traversersIteratorIndex; i < self.traversers.length; i++) {
+ arr[i] = self.traversers[i].object;
+ }
+ self._traversersIteratorIndex = self.traversers.length;
+ return arr;
+ });
+};
+
+/**
+ * Async iterator method implementation.
+ * Returns a promise containing an iterator item.
+ * @returns {Promise.<{value, done}>}
+ */
+Traversal.prototype.next = function () {
+ var self = this;
+ return this._applyStrategies().then(function () {
+ if (!self.traversers || self._traversersIteratorIndex === self.traversers.length) {
+ return itemDone;
+ }
+ return { value: self.traversers[self._traversersIteratorIndex++].object, done: false };
+ });
+};
+
+Traversal.prototype._applyStrategies = function () {
+ if (this._traversalStrategiesPromise) {
+ // Apply strategies only once
+ return this._traversalStrategiesPromise;
+ }
+ return this._traversalStrategiesPromise = this.traversalStrategies.applyStrategies(this);
+};
+
+/**
+ * Returns the Bytecode JSON representation of the traversal
+ * @returns {String}
+ */
+Traversal.prototype.toString = function () {
+ return this.bytecode.toString();
+};
+
+/**
+ * Represents an operation.
+ * @constructor
+ */
+function P(operator, value, other) {
+ this.operator = operator;
+ this.value = value;
+ this.other = other;
+}
+
+/**
+ * Returns the string representation of the instance.
+ * @returns {string}
+ */
+P.prototype.toString = function () {
+ if (this.other === undefined) {
+ return this.operator + '(' + this.value + ')';
+ }
+ return this.operator + '(' + this.value + ', ' + this.other + ')';
+};
+
+function createP(operator, args) {
+ args.unshift(null, operator);
+ return new (Function.prototype.bind.apply(P, args));
+}
+
+/** @param {...Object} args */
+P.between = function (args) {
+ return createP('between', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.eq = function (args) {
+ return createP('eq', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.gt = function (args) {
+ return createP('gt', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.gte = function (args) {
+ return createP('gte', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.inside = function (args) {
+ return createP('inside', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.lt = function (args) {
+ return createP('lt', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.lte = function (args) {
+ return createP('lte', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.neq = function (args) {
+ return createP('neq', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.not = function (args) {
+ return createP('not', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.outside = function (args) {
+ return createP('outside', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.test = function (args) {
+ return createP('test', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.within = function (args) {
+ return createP('within', parseArgs.apply(null, arguments));
+};
+
+/** @param {...Object} args */
+P.without = function (args) {
+ return createP('without', parseArgs.apply(null, arguments));
+};
+
+P.prototype.and = function (arg) {
+ return new P('and', this, arg);
+};
+
+P.prototype.or = function (arg) {
+ return new P('or', this, arg);
+};
+
+function Traverser(object, bulk) {
+ this.object = object;
+ this.bulk = bulk == undefined ? 1 : bulk;
+}
+
+function TraversalSideEffects() {
+
+}
+
+function toEnum(typeName, keys) {
+ var result = {};
+ keys.split(' ').forEach(function (k) {
+ var jsKey = k;
+ if (jsKey === jsKey.toUpperCase()) {
+ jsKey = jsKey.toLowerCase();
+ }
+ result[jsKey] = new EnumValue(typeName, k);
+ });
+ return result;
+}
+
+function EnumValue(typeName, elementName) {
+ this.typeName = typeName;
+ this.elementName = elementName;
+}
+
+module.exports = {
+ EnumValue: EnumValue,
+ P: P,
+ Traversal: Traversal,
+ TraversalSideEffects: TraversalSideEffects,
+ Traverser: Traverser,
+ barrier: toEnum('Barrier', 'normSack'),
+ cardinality: toEnum('Cardinality', 'list set single'),
+ column: toEnum('Column', 'keys values'),
+ direction: toEnum('Direction', 'BOTH IN OUT'),
+ operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
+ order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
+ pick: toEnum('Pick', 'any none'),
+ pop: toEnum('Pop', 'all first last'),
+ scope: toEnum('Scope', 'global local'),
+ t: toEnum('T', 'id key label value')
+};
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
new file mode 100644
index 0000000..4ef3fd5
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var gt = require('../process/graph-traversal');
+var t = require('../process/traversal');
+var TraversalStrategies = require('../process/traversal-strategy').TraversalStrategies;
+var utils = require('../utils');
+var inherits = utils.inherits;
+
+function Graph() {
+
+}
+
+/**
+ * Returns the graph traversal source.
+ * @returns {GraphTraversalSource}
+ */
+Graph.prototype.traversal = function () {
+ return new gt.GraphTraversalSource(this, new TraversalStrategies());
+};
+
+Graph.prototype.toString = function () {
+ return 'graph[empty]';
+};
+
+function Element(id, label) {
+ this.id = id;
+ this.label = label;
+}
+
+/**
+ * Compares this instance to another and determines if they can be considered as equal.
+ * @param {Element} other
+ * @returns {boolean}
+ */
+Element.prototype.equals = function (other) {
+ return (other instanceof Element) && this.id === other.id;
+};
+
+function Vertex(id, label, properties) {
+ Element.call(this, id, label);
+ this.properties = properties;
+}
+
+Vertex.prototype.toString = function () {
+ return 'v[' + this.id + ']';
+};
+
+inherits(Vertex, Element);
+
+function Edge(id, outV, label, inV, properties) {
+ Element.call(this, id, label);
+ this.outV = outV;
+ this.inV = inV;
+ this.properties = {};
+ (function adaptProperties(self) {
+ if (properties) {
+ var keys = Object.keys(properties);
+ for (var i = 0; i < keys.length; i++) {
+ var k = keys[i];
+ self.properties[k] = properties[k].value;
+ }
+ }
+ })(this);
+}
+
+inherits(Edge, Element);
+
+Edge.prototype.toString = function () {
+ return 'e[' + this.id + '][' + this.outV.id + '-' + this.label + '->' + this.inV.id + ']';
+};
+
+function VertexProperty(id, label, value, properties) {
+ Element.call(this, id, label);
+ this.value = value;
+ this.key = this.label;
+ this.properties = properties;
+}
+
+inherits(VertexProperty, Element);
+
+VertexProperty.prototype.toString = function () {
+ return 'vp[' + this.label + '->' + this.value.substr(0, 20) + ']';
+};
+
+function Property(key, value) {
+ this.key = key;
+ this.value = value;
+}
+
+Property.prototype.toString = function () {
+ return 'p[' + this.key + '->' + this.value.substr(0, 20) + ']';
+};
+
+Property.prototype.equals = function (other) {
+ return (other instanceof Property) && this.key === other.key && this.value === other.value;
+};
+
+/**
+ * Represents a walk through a graph as defined by a traversal.
+ * @param {Array} labels
+ * @param {Array} objects
+ * @constructor
+ */
+function Path(labels, objects) {
+ this.labels = labels;
+ this.objects = objects;
+}
+
+module.exports = {
+ Edge: Edge,
+ Graph: Graph,
+ Path: Path,
+ Property: Property,
+ Vertex: Vertex,
+ VertexProperty: VertexProperty
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
new file mode 100644
index 0000000..46d251e
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
@@ -0,0 +1,398 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+var t = require('../../process/traversal');
+var Bytecode = require('../../process/bytecode');
+var g = require('../graph.js');
+
+/**
+ * A type serializer
+ * @typedef {Object} Serializer
+ * @property {Function} serialize
+ * @property {Function} deserialize
+ * @property {Function} [canBeUsedFor]
+ */
+
+/**
+ * @const
+ * @private
+ */
+var valueKey = '@value';
+
+/**
+ * @const
+ * @private
+ */
+var typeKey = '@type';
+
+var deserializers = {
+ 'g:Traverser': TraverserSerializer,
+ 'g:Int32': NumberSerializer,
+ 'g:Int64': NumberSerializer,
+ 'g:Float': NumberSerializer,
+ 'g:Double': NumberSerializer,
+ 'g:Vertex': VertexSerializer,
+ 'g:Edge': EdgeSerializer,
+ 'g:VertexProperty': VertexPropertySerializer,
+ 'g:Property': PropertySerializer,
+ 'g:Path': PathSerializer
+};
+
+var serializers = [
+ NumberSerializer,
+ BytecodeSerializer,
+ TraverserSerializer,
+ PSerializer,
+ LambdaSerializer,
+ EnumSerializer
+];
+
+/**
+ * GraphSON Writer
+ * @param {Object} [options]
+ * @param {Object} options.serializers An object used as an associative array with GraphSON 2 type name as keys and
+ * serializer instances as values, ie: { 'g:Int64': longSerializer }.
+ * @constructor
+ */
+function GraphSONWriter(options) {
+ this._options = options || {};
+ // Create instance of the default serializers
+ this._serializers = serializers.map(function (serializerConstructor) {
+ var s = new serializerConstructor();
+ s.writer = this;
+ return s;
+ }, this);
+ var customSerializers = this._options.serializers || {};
+ Object.keys(customSerializers).forEach(function (key) {
+ var s = customSerializers[key];
+ if (!s.serialize) {
+ return;
+ }
+ s.writer = this;
+ // Insert custom serializers first
+ this._serializers.unshift(s);
+ }, this);
+}
+
+GraphSONWriter.prototype.adaptObject = function (value) {
+ var s;
+ if (Array.isArray(value)) {
+ return value.map(function (item) {
+ return this.adaptObject(item);
+ }, this);
+ }
+ for (var i = 0; i < this._serializers.length; i++) {
+ var currentSerializer = this._serializers[i];
+ if (currentSerializer.canBeUsedFor && currentSerializer.canBeUsedFor(value)) {
+ s = currentSerializer;
+ break;
+ }
+ }
+ if (s) {
+ return s.serialize(value);
+ }
+ // Default (strings / objects / ...)
+ return value;
+};
+
+/**
+ * Returns the GraphSON representation of the provided object instance.
+ * @param {Object} obj
+ * @returns {String}
+ */
+GraphSONWriter.prototype.write = function (obj) {
+ return JSON.stringify(this.adaptObject(obj));
+};
+
+/**
+ * GraphSON Reader
+ * @param {Object} [options]
+ * @param {Object} [options.serializers] An object used as an associative array with GraphSON 2 type name as keys and
+ * deserializer instances as values, ie: { 'g:Int64': longSerializer }.
+ * @constructor
+ */
+function GraphSONReader(options) {
+ this._options = options || {};
+ this._deserializers = {};
+ Object.keys(deserializers).forEach(function (typeName) {
+ var serializerConstructor = deserializers[typeName];
+ var s = new serializerConstructor();
+ s.reader = this;
+ this._deserializers[typeName] = s;
+ }, this);
+ if (this._options.serializers) {
+ var customSerializers = this._options.serializers || {};
+ Object.keys(customSerializers).forEach(function (key) {
+ var s = customSerializers[key];
+ if (!s.deserialize) {
+ return;
+ }
+ s.reader = this;
+ this._deserializers[key] = s;
+ }, this);
+ }
+}
+
+GraphSONReader.prototype.read = function (obj) {
+ if (obj === undefined) {
+ return undefined;
+ }
+ if (obj === null) {
+ return null;
+ }
+ if (Array.isArray(obj)) {
+ return obj.map(function mapEach(item) {
+ return this.read(item);
+ }, this);
+ }
+ var type = obj[typeKey];
+ if (type) {
+ var d = this._deserializers[type];
+ if (d) {
+ // Use type serializer
+ return d.deserialize(obj);
+ }
+ return obj[valueKey];
+ }
+ if (obj && typeof obj === 'object' && obj.constructor === Object) {
+ return this._deserializeObject(obj);
+ }
+ // Default (for boolean, number and other scalars)
+ return obj;
+};
+
+GraphSONReader.prototype._deserializeObject = function (obj) {
+ var keys = Object.keys(obj);
+ var result = {};
+ for (var i = 0; i < keys.length; i++) {
+ result[keys[i]] = this.read(obj[keys[i]]);
+ }
+ return result;
+};
+
+function NumberSerializer() {
+
+}
+
+NumberSerializer.prototype.serialize = function (item) {
+ return item;
+};
+
+NumberSerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return parseFloat(value);
+};
+
+NumberSerializer.prototype.canBeUsedFor = function (value) {
+ return (typeof value === 'number');
+};
+
+function BytecodeSerializer() {
+
+}
+
+BytecodeSerializer.prototype.serialize = function (item) {
+ var bytecode = item;
+ if (item instanceof t.Traversal) {
+ bytecode = item.getBytecode();
+ }
+ var result = {};
+ result[typeKey] = 'g:Bytecode';
+ var resultValue = result[valueKey] = {};
+ var sources = this._serializeInstructions(bytecode.sourceInstructions);
+ if (sources) {
+ resultValue['source'] = sources;
+ }
+ var steps = this._serializeInstructions(bytecode.stepInstructions);
+ if (steps) {
+ resultValue['step'] = steps;
+ }
+ return result;
+};
+
+BytecodeSerializer.prototype._serializeInstructions = function (instructions) {
+ if (instructions.length === 0) {
+ return null;
+ }
+ var result = new Array(instructions.length);
+ result[0] = instructions[0];
+ for (var i = 1; i < instructions.length; i++) {
+ result[i] = this.writer.adaptObject(instructions[i]);
+ }
+ return result;
+};
+
+BytecodeSerializer.prototype.canBeUsedFor = function (value) {
+ return (value instanceof Bytecode) || (value instanceof t.Traversal);
+};
+
+function PSerializer() {
+
+}
+
+/** @param {P} item */
+PSerializer.prototype.serialize = function (item) {
+ var result = {};
+ result[typeKey] = 'g:P';
+ var resultValue = result[valueKey] = {
+ 'predicate': item.operator
+ };
+ if (item.other == undefined) {
+ resultValue['value'] = this.writer.adaptObject(item.value);
+ }
+ else {
+ resultValue['value'] = [ this.writer.adaptObject(item.value), this.writer.adaptObject(item.other) ];
+ }
+ return result;
+};
+
+PSerializer.prototype.canBeUsedFor = function (value) {
+ return (value instanceof t.P);
+};
+
+function LambdaSerializer() {
+
+}
+
+/** @param {Function} item */
+LambdaSerializer.prototype.serialize = function (item) {
+ var result = {};
+ result[typeKey] = 'g:Lambda';
+ result[valueKey] = {
+ 'arguments': item.length,
+ 'language': 'gremlin-javascript',
+ 'script': item.toString()
+ };
+ return result;
+};
+
+LambdaSerializer.prototype.canBeUsedFor = function (value) {
+ return (typeof value === 'function');
+};
+
+function EnumSerializer() {
+
+}
+
+/** @param {EnumValue} item */
+EnumSerializer.prototype.serialize = function (item) {
+ var result = {};
+ result[typeKey] = 'g:' + item.typeName;
+ result[valueKey] = item.elementName;
+ return result;
+};
+
+EnumSerializer.prototype.canBeUsedFor = function (value) {
+ return value && value.typeName && value instanceof t.EnumValue;
+};
+
+function TraverserSerializer() {
+
+}
+
+/** @param {Traverser} item */
+TraverserSerializer.prototype.serialize = function (item) {
+ var result = {};
+ result[typeKey] = 'g:Traverser';
+ result[valueKey] = {
+ 'value': this.writer.adaptObject(item.object),
+ 'bulk': this.writer.adaptObject(item.bulk)
+ };
+ return result;
+};
+
+TraverserSerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return new t.Traverser(this.reader.read(value['value']), this.reader.read(value['bulk']));
+};
+
+TraverserSerializer.prototype.canBeUsedFor = function (value) {
+ return (value instanceof t.Traverser);
+};
+
+function VertexSerializer() {
+
+}
+
+VertexSerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return new g.Vertex(this.reader.read(value['id']), value['label'], this.reader.read(value['properties']));
+};
+
+function VertexPropertySerializer() {
+
+}
+
+VertexPropertySerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return new g.VertexProperty(
+ this.reader.read(value['id']),
+ value['label'],
+ this.reader.read(value['value']),
+ this.reader.read(value['properties'])
+ );
+};
+
+function PropertySerializer() {
+
+}
+
+PropertySerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return new g.Property(
+ value['key'],
+ this.reader.read(value['value']));
+};
+
+function EdgeSerializer() {
+
+}
+
+EdgeSerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ return new g.Edge(
+ this.reader.read(value['id']),
+ this.reader.read(value['outV']),
+ value['label'],
+ this.reader.read(value['inV']),
+ this.reader.read(value['properties'])
+ );
+};
+
+function PathSerializer() {
+
+}
+
+PathSerializer.prototype.deserialize = function (obj) {
+ var value = obj[valueKey];
+ var objects = value['objects'].map(function objectMapItem(o) {
+ return this.reader.read(o);
+ }, this);
+ return new g.Path(this.reader.read(value['labels']), objects);
+};
+
+module.exports = {
+ GraphSONWriter: GraphSONWriter,
+ GraphSONReader: GraphSONReader
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
new file mode 100644
index 0000000..7691dda
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * A module containing any utility functions.
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+var util = require('util');
+
+exports.inherits = util.inherits;
+
+exports.parseArgs = function parseArgs() {
+ return (arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments));
+};
+
+/**
+ * @param {Function} handler
+ * @returns {Promise}
+ */
+function defaultPromiseFactory(handler) {
+ return new Promise(function executor(resolve, reject) {
+ handler(function handlerCallback(err, result) {
+ if (err) {
+ return reject(err);
+ }
+ resolve(result);
+ });
+ });
+}
+
+/**
+ * Gets a resolved Promise instance.
+ * @param {Function} promiseFactory
+ * @returns {Promise}
+ */
+exports.resolvedPromise = function (promiseFactory) {
+ return toPromise(promiseFactory, function handler(cb) {
+ cb();
+ });
+};
+
+var toPromise = exports.toPromise = function toPromise(promiseFactory, handler) {
+ promiseFactory = promiseFactory || defaultPromiseFactory;
+ return promiseFactory(handler);
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b4e8e3b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
new file mode 100644
index 0000000..0976f31
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "gremlin-javascript",
+ "version": "3.2.5-alpha1",
+ "description": "JavaScript Gremlin Language Variant",
+ "author": "Apache TinkerPop team",
+ "keywords": [
+ "graph",
+ "gremlin",
+ "tinkerpop",
+ "connection",
+ "glv",
+ "driver",
+ "graphdb"
+ ],
+ "license": "Apache-2.0",
+ "dependencies": {
+ "ws": "^3.0.0"
+ },
+ "devDependencies": {
+ "mocha": ">= 1.14.0"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/apache/tinkerpop.git"
+ },
+ "bugs": {
+ "url": "https://issues.apache.org/jira/browse/TINKERPOP"
+ },
+ "scripts": {
+ "test": "./node_modules/.bin/mocha test --recursive -t 5000",
+ "unit-test": "./node_modules/.bin/mocha test/unit"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+}
[41/47] tinkerpop git commit: install Maven 3.3.9 as part of the
Docker build process
Posted by jo...@apache.org.
install Maven 3.3.9 as part of the Docker build process
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3553ea99
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3553ea99
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3553ea99
Branch: refs/heads/master
Commit: 3553ea9903a2a5cd4dbc41f3aeb82941bc13f817
Parents: 397393d
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu Apr 6 14:40:05 2017 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:18 2018 +0100
----------------------------------------------------------------------
docker/build/Dockerfile.template | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3553ea99/docker/build/Dockerfile.template
----------------------------------------------------------------------
diff --git a/docker/build/Dockerfile.template b/docker/build/Dockerfile.template
index 84f551d..17084c9 100644
--- a/docker/build/Dockerfile.template
+++ b/docker/build/Dockerfile.template
@@ -20,3 +20,7 @@ FROM tinkerpop:hadoop-HADOOP_VERSION
RUN mkdir -p /usr/src/tinkerpop
WORKDIR /usr/src/tinkerpop
COPY . /usr/src/tinkerpop
+RUN chmod 744 ./.travis.install-maven.sh
+ENV M2_HOME /root/mvn-home
+ENV PATH ${M2_HOME}/bin:${PATH}
+RUN ./.travis.install-maven.sh 3.3.9 ${M2_HOME}
[12/47] tinkerpop git commit: Export enums and fix
TraversalStrategies#applyStrategies()
Posted by jo...@apache.org.
Export enums and fix TraversalStrategies#applyStrategies()
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/10c71551
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/10c71551
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/10c71551
Branch: refs/heads/master
Commit: 10c7155166e815304773eef5dc0076f20370aa81
Parents: 2d85056
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Fri Oct 7 12:01:30 2016 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:14 2018 +0100
----------------------------------------------------------------------
.../GraphTraversalSourceGenerator.groovy | 4 +-
.../javascript/TraversalSourceGenerator.groovy | 52 +++++++++-----------
.../driver/remote-connection.js | 2 +-
.../main/javascript/gremlin-javascript/index.js | 11 ++++-
.../process/graph-traversal.js | 4 +-
.../gremlin-javascript/process/traversal.js | 44 ++++++++---------
.../gremlin-javascript/test-exports.js | 15 ++++--
.../gremlin-javascript/test-graphson.js | 2 +-
.../gremlin-javascript/test-traversal.js | 17 ++++++-
9 files changed, 87 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/10c71551/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
index 81c38dc..b569292 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/GraphTraversalSourceGenerator.groovy
@@ -87,12 +87,12 @@ class GraphTraversalSourceGenerator {
/**
* @param remoteConnection
- * @returns {GraphTraversal}
+ * @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
- return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+ return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
};
/**
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/10c71551/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
index efcb826..5b07a32 100644
--- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
+++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy
@@ -177,11 +177,14 @@ class TraversalSourceGenerator {
this.strategies.push(strategy);
};
- /** @param {Traversal} traversal */
- TraversalStrategies.prototype.applyStrategies = function (traversal) {
- this.strategies.forEach(function eachStrategy(s) {
- s.apply(traversal);
- });
+ /**
+ * @param {Traversal} traversal
+ * @param {Function} callback
+ */
+ TraversalStrategies.prototype.applyStrategies = function (traversal, callback) {
+ eachSeries(this.strategies, function eachStrategy(s, next) {
+ s.apply(traversal, next);
+ }, callback);
};
/**
@@ -195,8 +198,9 @@ class TraversalSourceGenerator {
/**
* @abstract
* @param {Traversal} traversal
+ * @param {Function} callback
*/
- TraversalStrategy.prototype.apply = function (traversal) {
+ TraversalStrategy.prototype.apply = function (traversal, callback) {
};
@@ -290,24 +294,6 @@ class TraversalSourceGenerator {
this.elementName = elementName;
}
- /**
- * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
- */
- var enums = {};\n""")
-
- for (final Class<? extends Enum> enumClass : CoreImports.getClassImports()
- .findAll { Enum.class.isAssignableFrom(it) }
- .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }
- .collect()) {
- moduleOutput.append(" enums.${SymbolHelper.decapitalize(enumClass.getSimpleName())} = " +
- "toEnum('${SymbolHelper.toJs(enumClass.getSimpleName())}', '");
- enumClass.getEnumConstants()
- .sort { a, b -> a.name() <=> b.name() }
- .each { value -> moduleOutput.append("${SymbolHelper.toJs(value.name())} "); }
- moduleOutput.deleteCharAt(moduleOutput.length() - 1).append("');\n")
- }
-
- moduleOutput.append("""
// Utility functions
/** @returns {Array} */
function parseArgs() {
@@ -376,11 +362,21 @@ class TraversalSourceGenerator {
TraversalSideEffects: TraversalSideEffects,
TraversalStrategies: TraversalStrategies,
TraversalStrategy: TraversalStrategy,
- Traverser: Traverser
+ Traverser: Traverser""")
+ for (final Class<? extends Enum> enumClass : CoreImports.getClassImports()
+ .findAll { Enum.class.isAssignableFrom(it) }
+ .sort { a, b -> a.getSimpleName() <=> b.getSimpleName() }
+ .collect()) {
+ moduleOutput.append(",\n ${SymbolHelper.decapitalize(enumClass.getSimpleName())}: " +
+ "toEnum('${SymbolHelper.toJs(enumClass.getSimpleName())}', '");
+ enumClass.getEnumConstants()
+ .sort { a, b -> a.name() <=> b.name() }
+ .each { value -> moduleOutput.append("${SymbolHelper.toJs(value.name())} "); }
+ moduleOutput.deleteCharAt(moduleOutput.length() - 1).append("')")
+ }
+
+ moduleOutput.append("""
};
- Object.keys(enums).forEach(function (k) {
- toExport[k] = enums[k];
- });
if (typeof module !== 'undefined') {
// CommonJS
module.exports = toExport;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/10c71551/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
index 99b177f..e19b537 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/driver/remote-connection.js
@@ -68,7 +68,7 @@
/** @override */
RemoteStrategy.prototype.apply = function (traversal, callback) {
if (traversal.traversers) {
- return;
+ return callback();
}
this.connection.submit(traversal.getBytecode(), function (err, remoteTraversal) {
if (err) {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/10c71551/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index cda8200..ddcdac2 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -49,14 +49,21 @@
process: {
Bytecode: t.Bytecode,
EnumValue: t.EnumValue,
- inherits: t.inherits,
P: t.P,
- parseArgs: t.parseArgs,
Traversal: t.Traversal,
TraversalSideEffects: t.TraversalSideEffects,
TraversalStrategies: t.TraversalStrategies,
TraversalStrategy: t.TraversalStrategy,
Traverser: t.Traverser,
+ barrier: t.barrier,
+ cardinality: t.cardinality,
+ column: t.column,
+ direction: t.direction,
+ operator: t.operator,
+ order: t.order,
+ pop: t.pop,
+ scope: t.scope,
+ t: t.t,
GraphTraversal: gt.GraphTraversal,
GraphTraversalSource: gt.GraphTraversalSource,
statics: gt.statics
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/10c71551/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
index d9803ba..1a6356b 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/graph-traversal.js
@@ -44,12 +44,12 @@
/**
* @param remoteConnection
- * @returns {GraphTraversal}
+ * @returns {GraphTraversalSource}
*/
GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
var traversalStrategy = new t.TraversalStrategies(this._traversalStrategies);
traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
- return new GraphTraversal(this._graph, traversalStrategy, new Bytecode(this._bytecode));
+ return new GraphTraversalSource(this._graph, traversalStrategy, new Bytecode(this._bytecode));
};
/**
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/10c71551/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
index 5c9bf6c..ff2927e 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js
@@ -185,11 +185,14 @@
this.strategies.push(strategy);
};
- /** @param {Traversal} traversal */
- TraversalStrategies.prototype.applyStrategies = function (traversal) {
- this.strategies.forEach(function eachStrategy(s) {
- s.apply(traversal);
- });
+ /**
+ * @param {Traversal} traversal
+ * @param {Function} callback
+ */
+ TraversalStrategies.prototype.applyStrategies = function (traversal, callback) {
+ eachSeries(this.strategies, function eachStrategy(s, next) {
+ s.apply(traversal, next);
+ }, callback);
};
/**
@@ -203,8 +206,9 @@
/**
* @abstract
* @param {Traversal} traversal
+ * @param {Function} callback
*/
- TraversalStrategy.prototype.apply = function (traversal) {
+ TraversalStrategy.prototype.apply = function (traversal, callback) {
};
@@ -298,20 +302,6 @@
this.elementName = elementName;
}
- /**
- * @type {{barrier, cardinality, column, direction, operator, order, pop, scope, t}}
- */
- var enums = {};
- enums.barrier = toEnum('Barrier', 'normSack');
- enums.cardinality = toEnum('Cardinality', 'list set single');
- enums.column = toEnum('Column', 'keys values');
- enums.direction = toEnum('Direction', 'BOTH IN OUT');
- enums.operator = toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong');
- enums.order = toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr');
- enums.pop = toEnum('Pop', 'all first last');
- enums.scope = toEnum('Scope', 'global local');
- enums.t = toEnum('T', 'id key label value');
-
// Utility functions
/** @returns {Array} */
function parseArgs() {
@@ -380,11 +370,17 @@
TraversalSideEffects: TraversalSideEffects,
TraversalStrategies: TraversalStrategies,
TraversalStrategy: TraversalStrategy,
- Traverser: Traverser
+ Traverser: Traverser,
+ barrier: toEnum('Barrier', 'normSack'),
+ cardinality: toEnum('Cardinality', 'list set single'),
+ column: toEnum('Column', 'keys values'),
+ direction: toEnum('Direction', 'BOTH IN OUT'),
+ operator: toEnum('Operator', 'addAll and assign div max min minus mult or sum sumLong'),
+ order: toEnum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr'),
+ pop: toEnum('Pop', 'all first last'),
+ scope: toEnum('Scope', 'global local'),
+ t: toEnum('T', 'id key label value')
};
- Object.keys(enums).forEach(function (k) {
- toExport[k] = enums[k];
- });
if (typeof module !== 'undefined') {
// CommonJS
module.exports = toExport;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/10c71551/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
index 6edb323..b9265c7 100644
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-exports.js
@@ -34,9 +34,7 @@
assert.ok(glvModule.process);
assert.strictEqual(typeof glvModule.process.Bytecode, 'function');
assert.strictEqual(typeof glvModule.process.EnumValue, 'function');
- assert.strictEqual(typeof glvModule.process.inherits, 'function');
assert.strictEqual(typeof glvModule.process.P, 'function');
- assert.strictEqual(typeof glvModule.process.parseArgs, 'function');
assert.strictEqual(typeof glvModule.process.Traversal, 'function');
assert.strictEqual(typeof glvModule.process.TraversalSideEffects, 'function');
assert.strictEqual(typeof glvModule.process.TraversalStrategies, 'function');
@@ -44,6 +42,17 @@
assert.strictEqual(typeof glvModule.process.Traverser, 'function');
assert.strictEqual(typeof glvModule.process.GraphTraversal, 'function');
assert.strictEqual(typeof glvModule.process.GraphTraversalSource, 'function');
+ assert.strictEqual(typeof glvModule.process.barrier, 'object');
+ assert.strictEqual(typeof glvModule.process.cardinality, 'object');
+ assert.strictEqual(typeof glvModule.process.column, 'object');
+ assert.strictEqual(typeof glvModule.process.direction, 'object');
+ assert.strictEqual(typeof glvModule.process.operator, 'object');
+ assert.strictEqual(typeof glvModule.process.order, 'object');
+ assert.strictEqual(typeof glvModule.process.pop, 'object');
+ assert.strictEqual(typeof glvModule.process.scope, 'object');
+ assert.strictEqual(typeof glvModule.process.t, 'object');
+
+
assert.ok(glvModule.process.statics);
assert.ok(glvModule.structure);
@@ -75,4 +84,4 @@
}
throw new Error('No module loader was found');
}
-}).call(this)
\ No newline at end of file
+}).call(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/10c71551/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
index e44ef90..418a9dd 100644
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-graphson.js
@@ -87,7 +87,7 @@
assert.strictEqual(writer.write(true), 'true');
assert.strictEqual(writer.write(false), 'false');
},
- function testWriteNumber() {
+ function testWriteP() {
var writer = new GraphSONWriter();
var expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[{"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},{"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},{"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}});
assert.strictEqual(writer.write(P.lt("b").or(P.gt("c")).and(P.neq("d"))), expected);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/10c71551/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
index 477df91..1ec4253 100644
--- a/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
+++ b/gremlin-javascript/src/test/javascript/gremlin-javascript/test-traversal.js
@@ -26,9 +26,10 @@
var helper = loadModule.call(this, './helper.js');
var assert = helper.assert;
var graph = helper.loadLibModule.call(this, 'structure/graph.js');
+ var t = helper.loadLibModule.call(this, 'process/traversal.js');
[
- function testBytecode() {
+ function testBytecode1() {
var g = new graph.Graph().traversal();
var bytecode = g.V().out('created').getBytecode();
assert.ok(bytecode);
@@ -37,6 +38,20 @@
assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
assert.strictEqual(bytecode.stepInstructions[1][0], 'out');
assert.strictEqual(bytecode.stepInstructions[1][1], 'created');
+ },
+ function testBytecode2() {
+ var g = new graph.Graph().traversal();
+ var bytecode = g.V().order().by('age', t.order.decr).getBytecode();
+ assert.ok(bytecode);
+ assert.strictEqual(bytecode.sourceInstructions.length, 0);
+ assert.strictEqual(bytecode.stepInstructions.length, 3);
+ assert.strictEqual(bytecode.stepInstructions[0][0], 'V');
+ assert.strictEqual(bytecode.stepInstructions[1][0], 'order');
+ assert.strictEqual(bytecode.stepInstructions[2][0], 'by');
+ assert.strictEqual(bytecode.stepInstructions[2][1], 'age');
+ assert.strictEqual(typeof bytecode.stepInstructions[2][2], 'object');
+ assert.strictEqual(bytecode.stepInstructions[2][2].typeName, 'Order');
+ assert.strictEqual(bytecode.stepInstructions[2][2].elementName, 'decr');
}
].forEach(function (testCase) {
testCase.call(null);
[26/47] tinkerpop git commit: Parse maps and mark scenarios with
lambdas as skipped
Posted by jo...@apache.org.
Parse maps and mark scenarios with lambdas as skipped
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9339a837
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9339a837
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9339a837
Branch: refs/heads/master
Commit: 9339a837b83aa6d72e22cd292fa8a68880b1b51e
Parents: 219ead0
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Mon Nov 27 14:42:26 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:16 2018 +0100
----------------------------------------------------------------------
.../test/cucumber/feature-steps.js | 84 ++++++++++++++++++--
.../gremlin-javascript/test/cucumber/world.js | 2 +-
2 files changed, 78 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9339a837/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 6625f29..8ec2bdc 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -25,6 +25,7 @@
const defineSupportCode = require('cucumber').defineSupportCode;
const vm = require('vm');
const expect = require('chai').expect;
+const util = require('util');
const graphModule = require('../../lib/structure/graph');
const graphTraversalModule = require('../../lib/process/graph-traversal');
const traversalModule = require('../../lib/process/traversal');
@@ -32,6 +33,10 @@ const Graph = graphModule.Graph;
const Path = graphModule.Path;
const __ = graphTraversalModule.statics;
+// Determines whether the feature maps (m[]), are deserialized as objects (true) or maps (false).
+// Use false for GraphSON3.
+const mapAsObject = true;
+
const parsers = [
[ 'd\\[([\\d.]+)\\]\\.[ilfdm]', toNumeric ],
[ 'v\\[(.+)\\]', toVertex ],
@@ -69,6 +74,8 @@ defineSupportCode(function(methods) {
});
methods.Given(/^using the parameter (.+) defined as "(.+)"$/, function (paramName, stringValue) {
+ // Remove escaped chars
+ stringValue = stringValue.replace(/\\"/g, '"');
let p = Promise.resolve();
if (this.graphName === 'empty') {
p = this.loadEmptyGraphData();
@@ -76,6 +83,11 @@ defineSupportCode(function(methods) {
const self = this;
return p.then(() => {
self.parameters[paramName] = parseValue.call(self, stringValue);
+ }).catch(err => {
+ if (err instanceof IgnoreError) {
+ return 'skipped';
+ }
+ throw err;
});
});
@@ -98,14 +110,14 @@ defineSupportCode(function(methods) {
const expectedResult = resultTable.rows().map(row => parseRow.call(this, row));
switch (characterizedAs) {
case 'ordered':
- console.log('--- ordered', expectedResult);
expect(this.result).to.have.deep.ordered.members(expectedResult);
break;
case 'unordered':
- console.log('--- unordered expected:', expectedResult);
- console.log('--- obtained:', this.result);
expect(this.result).to.have.deep.members(expectedResult);
break;
+ case 'of':
+ expect(this.result).to.include.deep.members(expectedResult);
+ break;
}
});
@@ -117,7 +129,22 @@ defineSupportCode(function(methods) {
});
methods.Then(/^the result should have a count of (\d+)$/, function (stringCount) {
- expect(this.result).to.have.lengthOf(parseInt(stringCount, 10));
+ const expected = parseInt(stringCount, 10);
+ if (!Array.isArray(this.result)) {
+ let count = 0;
+ if (this.result instanceof Map) {
+ count = this.result.size;
+ }
+ else if (typeof this.result === 'object') {
+ count = Object.keys(this.result).length;
+ }
+ else {
+ throw new Error('result not supported: ' + util.inspect(this.result));
+ }
+ expect(count).to.be.equal(expected);
+ return;
+ }
+ expect(this.result).to.have.lengthOf(expected);
});
methods.Then('nothing should happen because', _ => {});
@@ -187,7 +214,11 @@ function toVertexIdString(name) {
}
function toEdge(name) {
- return this.getData().edges[name];
+ const e = this.getData().edges[name];
+ if (!e) {
+ throw new Error(util.format('Edge with key "%s" not found', name));
+ }
+ return e;
}
function toEdgeId(name) {
@@ -210,6 +241,45 @@ function toArray(stringList) {
return stringList.split(',').map(x => parseValue.call(this, x));
}
-function toMap() {}
+function toMap(stringMap) {
+ return parseMapValue.call(this, JSON.parse(stringMap));
+}
+
+function parseMapValue(value) {
+ if (typeof value === 'string') {
+ return parseValue.call(this, value);
+ }
+ if (Array.isArray(value)) {
+ return value.map(x => parseMapValue.call(this, x));
+ }
+ if (typeof value !== 'object') {
+ return value;
+ }
+ if (mapAsObject) {
+ const result = {};
+ Object.keys(value).forEach(key => {
+ result[key] = parseMapValue.call(this, value[key]);
+ });
+ return result;
+ }
+ const map = new Map();
+ Object.keys(value).forEach(key => {
+ map.set(key, parseMapValue.call(this, value[key]));
+ });
+ return map;
+}
+
+function toLambda() {
+ throw new IgnoreError(IgnoreError.reason.lambdaNotSupported);
+}
+
+function IgnoreError(reason) {
+ Error.call(this, reason);
+ Error.captureStackTrace(this, IgnoreError);
+}
+
+util.inherits(IgnoreError, Error);
-function toLambda() {}
\ No newline at end of file
+IgnoreError.reason = {
+ lambdaNotSupported: 'Lambdas are not supported on gremlin-javascript',
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9339a837/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
index 946d124..03febd1 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -104,7 +104,7 @@ function getVertices(connection) {
function getEdges(connection) {
const g = new Graph().traversal().withRemote(connection);
return g.E().group()
- .by(__.project("o", "l", "i").by(__.outV().values("name")).by(__.inV().values("name")))
+ .by(__.project("o", "l", "i").by(__.outV().values("name")).by(__.label()).by(__.inV().values("name")))
.by(__.tail())
.next()
.then(it => {
[35/47] tinkerpop git commit: Use ES6 syntax
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
index f6a0de1..6dcd8f6 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
@@ -22,1141 +22,1144 @@
*/
'use strict';
-var t = require('./traversal.js');
-var remote = require('../driver/remote-connection');
-var utils = require('../utils');
-var Bytecode = require('./bytecode');
-var TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
-var inherits = utils.inherits;
-var parseArgs = utils.parseArgs;
-
-/**
- *
- * @param {Graph} graph
- * @param {TraversalStrategies} traversalStrategies
- * @param {Bytecode} [bytecode]
- * @constructor
- */
-function GraphTraversalSource(graph, traversalStrategies, bytecode) {
- this.graph = graph;
- this.traversalStrategies = traversalStrategies;
- this.bytecode = bytecode || new Bytecode();
+const Traversal = require('./traversal').Traversal;
+const remote = require('../driver/remote-connection');
+const utils = require('../utils');
+const Bytecode = require('./bytecode');
+const TraversalStrategies = require('./traversal-strategy').TraversalStrategies;
+const parseArgs = utils.parseArgs;
+
+
+/**
+ * Represents the primary DSL of the Gremlin traversal machine.
+ */
+class GraphTraversalSource {
+ /**
+ * @param {Graph} graph
+ * @param {TraversalStrategies} traversalStrategies
+ * @param {Bytecode} [bytecode]
+ */
+ constructor(graph, traversalStrategies, bytecode) {
+ this.graph = graph;
+ this.traversalStrategies = traversalStrategies;
+ this.bytecode = bytecode || new Bytecode();
+ }
+
+ /**
+ * @param remoteConnection
+ * @returns {GraphTraversalSource}
+ */
+ withRemote(remoteConnection) {
+ const traversalStrategy = new TraversalStrategies(this.traversalStrategies);
+ traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
+ return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
+ }
+
+ /**
+ * Returns the string representation of the GraphTraversalSource.
+ * @returns {string}
+ */
+ toString() {
+ return 'graphtraversalsource[' + this.graph.toString() + ']';
+ }
+
+ /**
+ * Graph Traversal Source withBulk method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ withBulk(args) {
+ const b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+
+ /**
+ * Graph Traversal Source withPath method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ withPath(args) {
+ const b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+
+ /**
+ * Graph Traversal Source withSack method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ withSack(args) {
+ const b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+
+ /**
+ * Graph Traversal Source withSideEffect method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ withSideEffect(args) {
+ const b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+
+ /**
+ * Graph Traversal Source withStrategies method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ withStrategies(args) {
+ const b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+
+ /**
+ * Graph Traversal Source withoutStrategies method.
+ * @param {...Object} args
+ * @returns {GraphTraversalSource}
+ */
+ withoutStrategies(args) {
+ const b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
+ return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+
+ /**
+ * E GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ E(args) {
+ const b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+
+ /**
+ * V GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ V(args) {
+ const b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+
+ /**
+ * addV GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ addV(args) {
+ const b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+
+ /**
+ * inject GraphTraversalSource step method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ inject(args) {
+ const b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
+ return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+ }
+
}
/**
- * @param remoteConnection
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withRemote = function (remoteConnection) {
- var traversalStrategy = new TraversalStrategies(this.traversalStrategies);
- traversalStrategy.addStrategy(new remote.RemoteStrategy(remoteConnection));
- return new GraphTraversalSource(this.graph, traversalStrategy, new Bytecode(this.bytecode));
-};
-
-/**
- * Returns the string representation of the GraphTraversalSource.
- * @returns {string}
- */
-GraphTraversalSource.prototype.toString = function () {
- return 'graphtraversalsource[' + this.graph.toString() + ']';
-};
-
-/**
- * Graph Traversal Source withBulk method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withBulk = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withBulk', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * Graph Traversal Source withPath method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withPath = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withPath', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * Graph Traversal Source withSack method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withSack = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withSack', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * Graph Traversal Source withSideEffect method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withSideEffect = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withSideEffect', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * Graph Traversal Source withStrategies method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withStrategies = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withStrategies', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * Graph Traversal Source withoutStrategies method.
- * @param {...Object} args
- * @returns {GraphTraversalSource}
- */
-GraphTraversalSource.prototype.withoutStrategies = function (args) {
- var b = new Bytecode(this.bytecode).addSource('withoutStrategies', parseArgs.apply(null, arguments));
- return new GraphTraversalSource(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * E GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.E = function (args) {
- var b = new Bytecode(this.bytecode).addStep('E', parseArgs.apply(null, arguments));
- return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * V GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.V = function (args) {
- var b = new Bytecode(this.bytecode).addStep('V', parseArgs.apply(null, arguments));
- return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * addV GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.addV = function (args) {
- var b = new Bytecode(this.bytecode).addStep('addV', parseArgs.apply(null, arguments));
- return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
- * inject GraphTraversalSource step method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversalSource.prototype.inject = function (args) {
- var b = new Bytecode(this.bytecode).addStep('inject', parseArgs.apply(null, arguments));
- return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
-};
-
-/**
* Represents a graph traversal.
- * @extends Traversal
- * @constructor
*/
-function GraphTraversal(graph, traversalStrategies, bytecode) {
- t.Traversal.call(this, graph, traversalStrategies, bytecode);
+class GraphTraversal extends Traversal {
+ constructor(graph, traversalStrategies, bytecode) {
+ super(graph, traversalStrategies, bytecode);
+ }
+
+ /**
+ * Graph traversal V method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ V(args) {
+ this.bytecode.addStep('V', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal addE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ addE(args) {
+ this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal addInE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ addInE(args) {
+ this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal addOutE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ addOutE(args) {
+ this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal addV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ addV(args) {
+ this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal aggregate method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ aggregate(args) {
+ this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal and method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ and(args) {
+ this.bytecode.addStep('and', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal as method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ as(args) {
+ this.bytecode.addStep('as', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal barrier method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ barrier(args) {
+ this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal both method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ both(args) {
+ this.bytecode.addStep('both', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal bothE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ bothE(args) {
+ this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal bothV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ bothV(args) {
+ this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal branch method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ branch(args) {
+ this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal by method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ by(args) {
+ this.bytecode.addStep('by', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal cap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ cap(args) {
+ this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal choose method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ choose(args) {
+ this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal coalesce method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ coalesce(args) {
+ this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal coin method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ coin(args) {
+ this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal constant method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ constant(args) {
+ this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal count method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ count(args) {
+ this.bytecode.addStep('count', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal cyclicPath method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ cyclicPath(args) {
+ this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal dedup method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ dedup(args) {
+ this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal drop method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ drop(args) {
+ this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal emit method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ emit(args) {
+ this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal filter method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ filter(args) {
+ this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal flatMap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ flatMap(args) {
+ this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal fold method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ fold(args) {
+ this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal from method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ from_(args) {
+ this.bytecode.addStep('from', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal group method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ group(args) {
+ this.bytecode.addStep('group', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal groupCount method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ groupCount(args) {
+ this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal groupV3d0 method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ groupV3d0(args) {
+ this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal has method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ has(args) {
+ this.bytecode.addStep('has', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal hasId method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ hasId(args) {
+ this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal hasKey method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ hasKey(args) {
+ this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal hasLabel method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ hasLabel(args) {
+ this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal hasNot method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ hasNot(args) {
+ this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal hasValue method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ hasValue(args) {
+ this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal id method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ id(args) {
+ this.bytecode.addStep('id', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal identity method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ identity(args) {
+ this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal in method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ in_(args) {
+ this.bytecode.addStep('in', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal inE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ inE(args) {
+ this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal inV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ inV(args) {
+ this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal inject method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ inject(args) {
+ this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal is method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ is(args) {
+ this.bytecode.addStep('is', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal key method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ key(args) {
+ this.bytecode.addStep('key', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal label method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ label(args) {
+ this.bytecode.addStep('label', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal limit method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ limit(args) {
+ this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal local method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ local(args) {
+ this.bytecode.addStep('local', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal loops method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ loops(args) {
+ this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal map method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ map(args) {
+ this.bytecode.addStep('map', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal mapKeys method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ mapKeys(args) {
+ this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal mapValues method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ mapValues(args) {
+ this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal match method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ match(args) {
+ this.bytecode.addStep('match', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal max method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ max(args) {
+ this.bytecode.addStep('max', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal mean method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ mean(args) {
+ this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal min method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ min(args) {
+ this.bytecode.addStep('min', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal not method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ not(args) {
+ this.bytecode.addStep('not', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal option method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ option(args) {
+ this.bytecode.addStep('option', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal optional method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ optional(args) {
+ this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal or method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ or(args) {
+ this.bytecode.addStep('or', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal order method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ order(args) {
+ this.bytecode.addStep('order', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal otherV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ otherV(args) {
+ this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal out method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ out(args) {
+ this.bytecode.addStep('out', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal outE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ outE(args) {
+ this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal outV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ outV(args) {
+ this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal pageRank method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ pageRank(args) {
+ this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal path method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ path(args) {
+ this.bytecode.addStep('path', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal peerPressure method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ peerPressure(args) {
+ this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal profile method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ profile(args) {
+ this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal program method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ program(args) {
+ this.bytecode.addStep('program', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal project method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ project(args) {
+ this.bytecode.addStep('project', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal properties method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ properties(args) {
+ this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal property method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ property(args) {
+ this.bytecode.addStep('property', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal propertyMap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ propertyMap(args) {
+ this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal range method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ range(args) {
+ this.bytecode.addStep('range', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal repeat method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ repeat(args) {
+ this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal sack method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ sack(args) {
+ this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal sample method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ sample(args) {
+ this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal select method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ select(args) {
+ this.bytecode.addStep('select', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal sideEffect method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ sideEffect(args) {
+ this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal simplePath method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ simplePath(args) {
+ this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal store method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ store(args) {
+ this.bytecode.addStep('store', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal subgraph method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ subgraph(args) {
+ this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal sum method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ sum(args) {
+ this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal tail method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ tail(args) {
+ this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal timeLimit method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ timeLimit(args) {
+ this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal times method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ times(args) {
+ this.bytecode.addStep('times', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal to method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ to(args) {
+ this.bytecode.addStep('to', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal toE method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ toE(args) {
+ this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal toV method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ toV(args) {
+ this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal tree method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ tree(args) {
+ this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal unfold method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ unfold(args) {
+ this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal union method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ union(args) {
+ this.bytecode.addStep('union', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal until method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ until(args) {
+ this.bytecode.addStep('until', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal value method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ value(args) {
+ this.bytecode.addStep('value', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal valueMap method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ valueMap(args) {
+ this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal values method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ values(args) {
+ this.bytecode.addStep('values', parseArgs.apply(null, arguments));
+ return this;
+ }
+
+ /**
+ * Graph traversal where method.
+ * @param {...Object} args
+ * @returns {GraphTraversal}
+ */
+ where(args) {
+ this.bytecode.addStep('where', parseArgs.apply(null, arguments));
+ return this;
+ }
+
}
-inherits(GraphTraversal, t.Traversal);
-
-/**
- * Graph traversal V method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.V = function (args) {
- this.bytecode.addStep('V', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal addE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.addE = function (args) {
- this.bytecode.addStep('addE', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal addInE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.addInE = function (args) {
- this.bytecode.addStep('addInE', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal addOutE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.addOutE = function (args) {
- this.bytecode.addStep('addOutE', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal addV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.addV = function (args) {
- this.bytecode.addStep('addV', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal aggregate method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.aggregate = function (args) {
- this.bytecode.addStep('aggregate', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal and method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.and = function (args) {
- this.bytecode.addStep('and', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal as method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.as = function (args) {
- this.bytecode.addStep('as', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal barrier method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.barrier = function (args) {
- this.bytecode.addStep('barrier', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal both method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.both = function (args) {
- this.bytecode.addStep('both', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal bothE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.bothE = function (args) {
- this.bytecode.addStep('bothE', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal bothV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.bothV = function (args) {
- this.bytecode.addStep('bothV', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal branch method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.branch = function (args) {
- this.bytecode.addStep('branch', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal by method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.by = function (args) {
- this.bytecode.addStep('by', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal cap method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.cap = function (args) {
- this.bytecode.addStep('cap', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal choose method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.choose = function (args) {
- this.bytecode.addStep('choose', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal coalesce method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.coalesce = function (args) {
- this.bytecode.addStep('coalesce', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal coin method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.coin = function (args) {
- this.bytecode.addStep('coin', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal constant method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.constant = function (args) {
- this.bytecode.addStep('constant', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal count method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.count = function (args) {
- this.bytecode.addStep('count', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal cyclicPath method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.cyclicPath = function (args) {
- this.bytecode.addStep('cyclicPath', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal dedup method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.dedup = function (args) {
- this.bytecode.addStep('dedup', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal drop method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.drop = function (args) {
- this.bytecode.addStep('drop', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal emit method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.emit = function (args) {
- this.bytecode.addStep('emit', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal filter method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.filter = function (args) {
- this.bytecode.addStep('filter', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal flatMap method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.flatMap = function (args) {
- this.bytecode.addStep('flatMap', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal fold method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.fold = function (args) {
- this.bytecode.addStep('fold', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal from method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.from_ = function (args) {
- this.bytecode.addStep('from', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal group method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.group = function (args) {
- this.bytecode.addStep('group', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal groupCount method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.groupCount = function (args) {
- this.bytecode.addStep('groupCount', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal groupV3d0 method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.groupV3d0 = function (args) {
- this.bytecode.addStep('groupV3d0', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal has method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.has = function (args) {
- this.bytecode.addStep('has', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal hasId method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.hasId = function (args) {
- this.bytecode.addStep('hasId', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal hasKey method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.hasKey = function (args) {
- this.bytecode.addStep('hasKey', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal hasLabel method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.hasLabel = function (args) {
- this.bytecode.addStep('hasLabel', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal hasNot method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.hasNot = function (args) {
- this.bytecode.addStep('hasNot', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal hasValue method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.hasValue = function (args) {
- this.bytecode.addStep('hasValue', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal id method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.id = function (args) {
- this.bytecode.addStep('id', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal identity method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.identity = function (args) {
- this.bytecode.addStep('identity', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal in method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.in_ = function (args) {
- this.bytecode.addStep('in', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal inE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.inE = function (args) {
- this.bytecode.addStep('inE', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal inV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.inV = function (args) {
- this.bytecode.addStep('inV', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal inject method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.inject = function (args) {
- this.bytecode.addStep('inject', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal is method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.is = function (args) {
- this.bytecode.addStep('is', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal key method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.key = function (args) {
- this.bytecode.addStep('key', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal label method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.label = function (args) {
- this.bytecode.addStep('label', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal limit method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.limit = function (args) {
- this.bytecode.addStep('limit', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal local method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.local = function (args) {
- this.bytecode.addStep('local', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal loops method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.loops = function (args) {
- this.bytecode.addStep('loops', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal map method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.map = function (args) {
- this.bytecode.addStep('map', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal mapKeys method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.mapKeys = function (args) {
- this.bytecode.addStep('mapKeys', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal mapValues method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.mapValues = function (args) {
- this.bytecode.addStep('mapValues', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal match method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.match = function (args) {
- this.bytecode.addStep('match', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal max method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.max = function (args) {
- this.bytecode.addStep('max', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal mean method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.mean = function (args) {
- this.bytecode.addStep('mean', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal min method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.min = function (args) {
- this.bytecode.addStep('min', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal not method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.not = function (args) {
- this.bytecode.addStep('not', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal option method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.option = function (args) {
- this.bytecode.addStep('option', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal optional method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.optional = function (args) {
- this.bytecode.addStep('optional', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal or method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.or = function (args) {
- this.bytecode.addStep('or', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal order method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.order = function (args) {
- this.bytecode.addStep('order', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal otherV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.otherV = function (args) {
- this.bytecode.addStep('otherV', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal out method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.out = function (args) {
- this.bytecode.addStep('out', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal outE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.outE = function (args) {
- this.bytecode.addStep('outE', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal outV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.outV = function (args) {
- this.bytecode.addStep('outV', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal pageRank method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.pageRank = function (args) {
- this.bytecode.addStep('pageRank', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal path method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.path = function (args) {
- this.bytecode.addStep('path', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal peerPressure method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.peerPressure = function (args) {
- this.bytecode.addStep('peerPressure', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal profile method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.profile = function (args) {
- this.bytecode.addStep('profile', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal program method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.program = function (args) {
- this.bytecode.addStep('program', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal project method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.project = function (args) {
- this.bytecode.addStep('project', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal properties method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.properties = function (args) {
- this.bytecode.addStep('properties', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal property method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.property = function (args) {
- this.bytecode.addStep('property', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal propertyMap method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.propertyMap = function (args) {
- this.bytecode.addStep('propertyMap', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal range method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.range = function (args) {
- this.bytecode.addStep('range', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal repeat method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.repeat = function (args) {
- this.bytecode.addStep('repeat', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal sack method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.sack = function (args) {
- this.bytecode.addStep('sack', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal sample method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.sample = function (args) {
- this.bytecode.addStep('sample', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal select method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.select = function (args) {
- this.bytecode.addStep('select', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal sideEffect method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.sideEffect = function (args) {
- this.bytecode.addStep('sideEffect', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal simplePath method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.simplePath = function (args) {
- this.bytecode.addStep('simplePath', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal store method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.store = function (args) {
- this.bytecode.addStep('store', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal subgraph method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.subgraph = function (args) {
- this.bytecode.addStep('subgraph', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal sum method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.sum = function (args) {
- this.bytecode.addStep('sum', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal tail method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.tail = function (args) {
- this.bytecode.addStep('tail', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal timeLimit method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.timeLimit = function (args) {
- this.bytecode.addStep('timeLimit', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal times method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.times = function (args) {
- this.bytecode.addStep('times', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal to method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.to = function (args) {
- this.bytecode.addStep('to', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal toE method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.toE = function (args) {
- this.bytecode.addStep('toE', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal toV method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.toV = function (args) {
- this.bytecode.addStep('toV', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal tree method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.tree = function (args) {
- this.bytecode.addStep('tree', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal unfold method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.unfold = function (args) {
- this.bytecode.addStep('unfold', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal union method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.union = function (args) {
- this.bytecode.addStep('union', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal until method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.until = function (args) {
- this.bytecode.addStep('until', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal value method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.value = function (args) {
- this.bytecode.addStep('value', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal valueMap method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.valueMap = function (args) {
- this.bytecode.addStep('valueMap', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal values method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.values = function (args) {
- this.bytecode.addStep('values', parseArgs.apply(null, arguments));
- return this;
-};
-
-/**
- * Graph traversal where method.
- * @param {...Object} args
- * @returns {GraphTraversal}
- */
-GraphTraversal.prototype.where = function (args) {
- this.bytecode.addStep('where', parseArgs.apply(null, arguments));
- return this;
-};
-
/**
* Contains the static method definitions
* @type {Object}
*/
-var statics = {};
+const statics = {};
/**
* V() static method
@@ -1164,7 +1167,7 @@ var statics = {};
* @returns {GraphTraversal}
*/
statics.V = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.V.apply(g, arguments);
};
@@ -1174,7 +1177,7 @@ statics.V = function (args) {
* @returns {GraphTraversal}
*/
statics.addE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.addE.apply(g, arguments);
};
@@ -1184,7 +1187,7 @@ statics.addE = function (args) {
* @returns {GraphTraversal}
*/
statics.addInE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.addInE.apply(g, arguments);
};
@@ -1194,7 +1197,7 @@ statics.addInE = function (args) {
* @returns {GraphTraversal}
*/
statics.addOutE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.addOutE.apply(g, arguments);
};
@@ -1204,7 +1207,7 @@ statics.addOutE = function (args) {
* @returns {GraphTraversal}
*/
statics.addV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.addV.apply(g, arguments);
};
@@ -1214,7 +1217,7 @@ statics.addV = function (args) {
* @returns {GraphTraversal}
*/
statics.aggregate = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.aggregate.apply(g, arguments);
};
@@ -1224,7 +1227,7 @@ statics.aggregate = function (args) {
* @returns {GraphTraversal}
*/
statics.and = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.and.apply(g, arguments);
};
@@ -1234,7 +1237,7 @@ statics.and = function (args) {
* @returns {GraphTraversal}
*/
statics.as = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.as.apply(g, arguments);
};
@@ -1244,7 +1247,7 @@ statics.as = function (args) {
* @returns {GraphTraversal}
*/
statics.barrier = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.barrier.apply(g, arguments);
};
@@ -1254,7 +1257,7 @@ statics.barrier = function (args) {
* @returns {GraphTraversal}
*/
statics.both = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.both.apply(g, arguments);
};
@@ -1264,7 +1267,7 @@ statics.both = function (args) {
* @returns {GraphTraversal}
*/
statics.bothE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.bothE.apply(g, arguments);
};
@@ -1274,7 +1277,7 @@ statics.bothE = function (args) {
* @returns {GraphTraversal}
*/
statics.bothV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.bothV.apply(g, arguments);
};
@@ -1284,7 +1287,7 @@ statics.bothV = function (args) {
* @returns {GraphTraversal}
*/
statics.branch = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.branch.apply(g, arguments);
};
@@ -1294,7 +1297,7 @@ statics.branch = function (args) {
* @returns {GraphTraversal}
*/
statics.cap = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.cap.apply(g, arguments);
};
@@ -1304,7 +1307,7 @@ statics.cap = function (args) {
* @returns {GraphTraversal}
*/
statics.choose = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.choose.apply(g, arguments);
};
@@ -1314,7 +1317,7 @@ statics.choose = function (args) {
* @returns {GraphTraversal}
*/
statics.coalesce = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.coalesce.apply(g, arguments);
};
@@ -1324,7 +1327,7 @@ statics.coalesce = function (args) {
* @returns {GraphTraversal}
*/
statics.coin = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.coin.apply(g, arguments);
};
@@ -1334,7 +1337,7 @@ statics.coin = function (args) {
* @returns {GraphTraversal}
*/
statics.constant = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.constant.apply(g, arguments);
};
@@ -1344,7 +1347,7 @@ statics.constant = function (args) {
* @returns {GraphTraversal}
*/
statics.count = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.count.apply(g, arguments);
};
@@ -1354,7 +1357,7 @@ statics.count = function (args) {
* @returns {GraphTraversal}
*/
statics.cyclicPath = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.cyclicPath.apply(g, arguments);
};
@@ -1364,7 +1367,7 @@ statics.cyclicPath = function (args) {
* @returns {GraphTraversal}
*/
statics.dedup = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.dedup.apply(g, arguments);
};
@@ -1374,7 +1377,7 @@ statics.dedup = function (args) {
* @returns {GraphTraversal}
*/
statics.drop = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.drop.apply(g, arguments);
};
@@ -1384,7 +1387,7 @@ statics.drop = function (args) {
* @returns {GraphTraversal}
*/
statics.emit = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.emit.apply(g, arguments);
};
@@ -1394,7 +1397,7 @@ statics.emit = function (args) {
* @returns {GraphTraversal}
*/
statics.filter = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.filter.apply(g, arguments);
};
@@ -1404,7 +1407,7 @@ statics.filter = function (args) {
* @returns {GraphTraversal}
*/
statics.flatMap = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.flatMap.apply(g, arguments);
};
@@ -1414,7 +1417,7 @@ statics.flatMap = function (args) {
* @returns {GraphTraversal}
*/
statics.fold = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.fold.apply(g, arguments);
};
@@ -1424,7 +1427,7 @@ statics.fold = function (args) {
* @returns {GraphTraversal}
*/
statics.group = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.group.apply(g, arguments);
};
@@ -1434,7 +1437,7 @@ statics.group = function (args) {
* @returns {GraphTraversal}
*/
statics.groupCount = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.groupCount.apply(g, arguments);
};
@@ -1444,7 +1447,7 @@ statics.groupCount = function (args) {
* @returns {GraphTraversal}
*/
statics.groupV3d0 = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.groupV3d0.apply(g, arguments);
};
@@ -1454,7 +1457,7 @@ statics.groupV3d0 = function (args) {
* @returns {GraphTraversal}
*/
statics.has = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.has.apply(g, arguments);
};
@@ -1464,7 +1467,7 @@ statics.has = function (args) {
* @returns {GraphTraversal}
*/
statics.hasId = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.hasId.apply(g, arguments);
};
@@ -1474,7 +1477,7 @@ statics.hasId = function (args) {
* @returns {GraphTraversal}
*/
statics.hasKey = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.hasKey.apply(g, arguments);
};
@@ -1484,7 +1487,7 @@ statics.hasKey = function (args) {
* @returns {GraphTraversal}
*/
statics.hasLabel = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.hasLabel.apply(g, arguments);
};
@@ -1494,7 +1497,7 @@ statics.hasLabel = function (args) {
* @returns {GraphTraversal}
*/
statics.hasNot = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.hasNot.apply(g, arguments);
};
@@ -1504,7 +1507,7 @@ statics.hasNot = function (args) {
* @returns {GraphTraversal}
*/
statics.hasValue = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.hasValue.apply(g, arguments);
};
@@ -1514,7 +1517,7 @@ statics.hasValue = function (args) {
* @returns {GraphTraversal}
*/
statics.id = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.id.apply(g, arguments);
};
@@ -1524,7 +1527,7 @@ statics.id = function (args) {
* @returns {GraphTraversal}
*/
statics.identity = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.identity.apply(g, arguments);
};
@@ -1534,7 +1537,7 @@ statics.identity = function (args) {
* @returns {GraphTraversal}
*/
statics.in_ = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.in_.apply(g, arguments);
};
@@ -1544,7 +1547,7 @@ statics.in_ = function (args) {
* @returns {GraphTraversal}
*/
statics.inE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.inE.apply(g, arguments);
};
@@ -1554,7 +1557,7 @@ statics.inE = function (args) {
* @returns {GraphTraversal}
*/
statics.inV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.inV.apply(g, arguments);
};
@@ -1564,7 +1567,7 @@ statics.inV = function (args) {
* @returns {GraphTraversal}
*/
statics.inject = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.inject.apply(g, arguments);
};
@@ -1574,7 +1577,7 @@ statics.inject = function (args) {
* @returns {GraphTraversal}
*/
statics.is = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.is.apply(g, arguments);
};
@@ -1584,7 +1587,7 @@ statics.is = function (args) {
* @returns {GraphTraversal}
*/
statics.key = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.key.apply(g, arguments);
};
@@ -1594,7 +1597,7 @@ statics.key = function (args) {
* @returns {GraphTraversal}
*/
statics.label = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.label.apply(g, arguments);
};
@@ -1604,7 +1607,7 @@ statics.label = function (args) {
* @returns {GraphTraversal}
*/
statics.limit = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.limit.apply(g, arguments);
};
@@ -1614,7 +1617,7 @@ statics.limit = function (args) {
* @returns {GraphTraversal}
*/
statics.local = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.local.apply(g, arguments);
};
@@ -1624,7 +1627,7 @@ statics.local = function (args) {
* @returns {GraphTraversal}
*/
statics.loops = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.loops.apply(g, arguments);
};
@@ -1634,7 +1637,7 @@ statics.loops = function (args) {
* @returns {GraphTraversal}
*/
statics.map = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.map.apply(g, arguments);
};
@@ -1644,7 +1647,7 @@ statics.map = function (args) {
* @returns {GraphTraversal}
*/
statics.mapKeys = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.mapKeys.apply(g, arguments);
};
@@ -1654,7 +1657,7 @@ statics.mapKeys = function (args) {
* @returns {GraphTraversal}
*/
statics.mapValues = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.mapValues.apply(g, arguments);
};
@@ -1664,7 +1667,7 @@ statics.mapValues = function (args) {
* @returns {GraphTraversal}
*/
statics.match = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.match.apply(g, arguments);
};
@@ -1674,7 +1677,7 @@ statics.match = function (args) {
* @returns {GraphTraversal}
*/
statics.max = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.max.apply(g, arguments);
};
@@ -1684,7 +1687,7 @@ statics.max = function (args) {
* @returns {GraphTraversal}
*/
statics.mean = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.mean.apply(g, arguments);
};
@@ -1694,7 +1697,7 @@ statics.mean = function (args) {
* @returns {GraphTraversal}
*/
statics.min = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.min.apply(g, arguments);
};
@@ -1704,7 +1707,7 @@ statics.min = function (args) {
* @returns {GraphTraversal}
*/
statics.not = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.not.apply(g, arguments);
};
@@ -1714,7 +1717,7 @@ statics.not = function (args) {
* @returns {GraphTraversal}
*/
statics.optional = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.optional.apply(g, arguments);
};
@@ -1724,7 +1727,7 @@ statics.optional = function (args) {
* @returns {GraphTraversal}
*/
statics.or = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.or.apply(g, arguments);
};
@@ -1734,7 +1737,7 @@ statics.or = function (args) {
* @returns {GraphTraversal}
*/
statics.order = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.order.apply(g, arguments);
};
@@ -1744,7 +1747,7 @@ statics.order = function (args) {
* @returns {GraphTraversal}
*/
statics.otherV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.otherV.apply(g, arguments);
};
@@ -1754,7 +1757,7 @@ statics.otherV = function (args) {
* @returns {GraphTraversal}
*/
statics.out = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.out.apply(g, arguments);
};
@@ -1764,7 +1767,7 @@ statics.out = function (args) {
* @returns {GraphTraversal}
*/
statics.outE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.outE.apply(g, arguments);
};
@@ -1774,7 +1777,7 @@ statics.outE = function (args) {
* @returns {GraphTraversal}
*/
statics.outV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.outV.apply(g, arguments);
};
@@ -1784,7 +1787,7 @@ statics.outV = function (args) {
* @returns {GraphTraversal}
*/
statics.path = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.path.apply(g, arguments);
};
@@ -1794,7 +1797,7 @@ statics.path = function (args) {
* @returns {GraphTraversal}
*/
statics.project = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.project.apply(g, arguments);
};
@@ -1804,7 +1807,7 @@ statics.project = function (args) {
* @returns {GraphTraversal}
*/
statics.properties = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.properties.apply(g, arguments);
};
@@ -1814,7 +1817,7 @@ statics.properties = function (args) {
* @returns {GraphTraversal}
*/
statics.property = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.property.apply(g, arguments);
};
@@ -1824,7 +1827,7 @@ statics.property = function (args) {
* @returns {GraphTraversal}
*/
statics.propertyMap = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.propertyMap.apply(g, arguments);
};
@@ -1834,7 +1837,7 @@ statics.propertyMap = function (args) {
* @returns {GraphTraversal}
*/
statics.range = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.range.apply(g, arguments);
};
@@ -1844,7 +1847,7 @@ statics.range = function (args) {
* @returns {GraphTraversal}
*/
statics.repeat = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.repeat.apply(g, arguments);
};
@@ -1854,7 +1857,7 @@ statics.repeat = function (args) {
* @returns {GraphTraversal}
*/
statics.sack = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.sack.apply(g, arguments);
};
@@ -1864,7 +1867,7 @@ statics.sack = function (args) {
* @returns {GraphTraversal}
*/
statics.sample = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.sample.apply(g, arguments);
};
@@ -1874,7 +1877,7 @@ statics.sample = function (args) {
* @returns {GraphTraversal}
*/
statics.select = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.select.apply(g, arguments);
};
@@ -1884,7 +1887,7 @@ statics.select = function (args) {
* @returns {GraphTraversal}
*/
statics.sideEffect = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.sideEffect.apply(g, arguments);
};
@@ -1894,7 +1897,7 @@ statics.sideEffect = function (args) {
* @returns {GraphTraversal}
*/
statics.simplePath = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.simplePath.apply(g, arguments);
};
@@ -1904,7 +1907,7 @@ statics.simplePath = function (args) {
* @returns {GraphTraversal}
*/
statics.store = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.store.apply(g, arguments);
};
@@ -1914,7 +1917,7 @@ statics.store = function (args) {
* @returns {GraphTraversal}
*/
statics.subgraph = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.subgraph.apply(g, arguments);
};
@@ -1924,7 +1927,7 @@ statics.subgraph = function (args) {
* @returns {GraphTraversal}
*/
statics.sum = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.sum.apply(g, arguments);
};
@@ -1934,7 +1937,7 @@ statics.sum = function (args) {
* @returns {GraphTraversal}
*/
statics.tail = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.tail.apply(g, arguments);
};
@@ -1944,7 +1947,7 @@ statics.tail = function (args) {
* @returns {GraphTraversal}
*/
statics.timeLimit = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.timeLimit.apply(g, arguments);
};
@@ -1954,7 +1957,7 @@ statics.timeLimit = function (args) {
* @returns {GraphTraversal}
*/
statics.times = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.times.apply(g, arguments);
};
@@ -1964,7 +1967,7 @@ statics.times = function (args) {
* @returns {GraphTraversal}
*/
statics.to = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.to.apply(g, arguments);
};
@@ -1974,7 +1977,7 @@ statics.to = function (args) {
* @returns {GraphTraversal}
*/
statics.toE = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.toE.apply(g, arguments);
};
@@ -1984,7 +1987,7 @@ statics.toE = function (args) {
* @returns {GraphTraversal}
*/
statics.toV = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.toV.apply(g, arguments);
};
@@ -1994,7 +1997,7 @@ statics.toV = function (args) {
* @returns {GraphTraversal}
*/
statics.tree = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.tree.apply(g, arguments);
};
@@ -2004,7 +2007,7 @@ statics.tree = function (args) {
* @returns {GraphTraversal}
*/
statics.unfold = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.unfold.apply(g, arguments);
};
@@ -2014,7 +2017,7 @@ statics.unfold = function (args) {
* @returns {GraphTraversal}
*/
statics.union = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.union.apply(g, arguments);
};
@@ -2024,7 +2027,7 @@ statics.union = function (args) {
* @returns {GraphTraversal}
*/
statics.until = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.until.apply(g, arguments);
};
@@ -2034,7 +2037,7 @@ statics.until = function (args) {
* @returns {GraphTraversal}
*/
statics.value = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.value.apply(g, arguments);
};
@@ -2044,7 +2047,7 @@ statics.value = function (args) {
* @returns {GraphTraversal}
*/
statics.valueMap = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.valueMap.apply(g, arguments);
};
@@ -2054,7 +2057,7 @@ statics.valueMap = function (args) {
* @returns {GraphTraversal}
*/
statics.values = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.values.apply(g, arguments);
};
@@ -2064,12 +2067,12 @@ statics.values = function (args) {
* @returns {GraphTraversal}
*/
statics.where = function (args) {
- var g = new GraphTraversal(null, null, new Bytecode());
+ const g = new GraphTraversal(null, null, new Bytecode());
return g.where.apply(g, arguments);
};
module.exports = {
- GraphTraversal: GraphTraversal,
- GraphTraversalSource: GraphTraversalSource,
- statics: statics
+ GraphTraversal,
+ GraphTraversalSource,
+ statics
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d458f76d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
index 22d6498..fbc3fba 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal-strategy.js
@@ -22,66 +22,63 @@
*/
'use strict';
-var utils = require('../utils');
+const utils = require('../utils');
-/**
- * Creates a new instance of TraversalStrategies.
- * @param {TraversalStrategies} [parent] The parent strategies from where to clone the values from.
- * @param {Function} [promiseFactory] The factory used to create the A+ Promise instances. Use it when you want to
- * create Promise instances without using ECMAScript Promise constructor, ie: bluebird or Q promises.
- * @constructor
- */
-function TraversalStrategies(parent, promiseFactory) {
- if (parent) {
- // Clone the strategies
- this.strategies = parent.strategies.slice(0);
- this.promiseFactory = parent.promiseFactory;
+class TraversalStrategies {
+ /**
+ * Creates a new instance of TraversalStrategies.
+ * @param {TraversalStrategies} [parent] The parent strategies from where to clone the values from.
+ * @param {Function} [promiseFactory] The factory used to create the A+ Promise instances. Use it when you want to
+ * create Promise instances without using ECMAScript Promise constructor, ie: bluebird or Q promises.
+ * @constructor
+ */
+ constructor(parent, promiseFactory) {
+ if (parent) {
+ // Clone the strategies
+ this.strategies = parent.strategies.slice(0);
+ this.promiseFactory = parent.promiseFactory;
+ }
+ else {
+ this.strategies = [];
+ }
+ if (promiseFactory) {
+ this.promiseFactory = promiseFactory;
+ }
}
- else {
- this.strategies = [];
+
+ /** @param {TraversalStrategy} strategy */
+ addStrategy(strategy) {
+ this.strategies.push(strategy);
}
- if (promiseFactory) {
- this.promiseFactory = promiseFactory;
+
+ /**
+ * @param {Traversal} traversal
+ * @returns {Promise}
+ */
+ applyStrategies(traversal) {
+ // Apply all strategies serially
+ const self = this;
+ return this.strategies.reduce(function reduceItem(promise, strategy) {
+ return promise.then(function () {
+ return strategy.apply(traversal, self.promiseFactory);
+ });
+ }, utils.resolvedPromise(this.promiseFactory));
}
}
-/** @param {TraversalStrategy} strategy */
-TraversalStrategies.prototype.addStrategy = function (strategy) {
- this.strategies.push(strategy);
-};
-
-/**
- * @param {Traversal} traversal
- * @returns {Promise}
- */
-TraversalStrategies.prototype.applyStrategies = function (traversal) {
- // Apply all strategies serially
- var self = this;
- return this.strategies.reduce(function reduceItem(promise, strategy) {
- return promise.then(function () {
- return strategy.apply(traversal, self.promiseFactory);
- });
- }, utils.resolvedPromise(this.promiseFactory));
-};
-
-/**
- * @abstract
- * @constructor
- */
-function TraversalStrategy() {
+/** @abstract */
+class TraversalStrategy {
+ /**
+ * @abstract
+ * @param {Traversal} traversal
+ * @param {Function|undefined} promiseFactory
+ * @returns {Promise}
+ */
+ apply(traversal, promiseFactory) {
+ }
}
-/**
- * @abstract
- * @param {Traversal} traversal
- * @param {Function|undefined} promiseFactory
- * @returns {Promise}
- */
-TraversalStrategy.prototype.apply = function (traversal, promiseFactory) {
-
-};
-
module.exports = {
TraversalStrategies: TraversalStrategies,
TraversalStrategy: TraversalStrategy
[31/47] tinkerpop git commit: Add toLong() method
Posted by jo...@apache.org.
Add toLong() method
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/93cf86d0
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/93cf86d0
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/93cf86d0
Branch: refs/heads/master
Commit: 93cf86d005fb3c11b0687089d7e372f6d4149c5c
Parents: f9f7033
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Nov 29 11:37:24 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:17 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/glv/PackageJson.template | 2 +-
.../main/javascript/gremlin-javascript/index.js | 4 +++-
.../gremlin-javascript/lib/structure/graph.js | 1 -
.../lib/structure/io/graph-serializer.js | 21 ++++++++++++++++++--
.../javascript/gremlin-javascript/lib/utils.js | 11 ++++++++++
.../javascript/gremlin-javascript/package.json | 2 +-
.../test/cucumber/feature-steps.js | 6 ++++--
7 files changed, 39 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/93cf86d0/gremlin-javascript/glv/PackageJson.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template
index 4f1ac05..1b54a87 100644
--- a/gremlin-javascript/glv/PackageJson.template
+++ b/gremlin-javascript/glv/PackageJson.template
@@ -49,7 +49,7 @@
},
"scripts": {
"test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
- "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/AddVertex.feature",
+ "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
"unit-test": "./node_modules/.bin/mocha test/unit"
},
"engines": {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/93cf86d0/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index 600ac53..61ab274 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -29,6 +29,7 @@ var graph = require('./lib/structure/graph');
var gs = require('./lib/structure/io/graph-serializer');
var rc = require('./lib/driver/remote-connection');
var Bytecode = require('./lib/process/bytecode');
+var utils = require('./lib/utils');
module.exports = {
driver: {
@@ -68,6 +69,7 @@ module.exports = {
Path: graph.Path,
Property: graph.Property,
Vertex: graph.Vertex,
- VertexProperty: graph.VertexProperty
+ VertexProperty: graph.VertexProperty,
+ toLong: utils.toLong
}
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/93cf86d0/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
index 95fd30f..cbb7e2c 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
@@ -23,7 +23,6 @@
'use strict';
var gt = require('../process/graph-traversal');
-var t = require('../process/traversal');
var TraversalStrategies = require('../process/traversal-strategy').TraversalStrategies;
var utils = require('../utils');
var inherits = utils.inherits;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/93cf86d0/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
index ff3d72d..8e4ad5e 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
@@ -24,7 +24,8 @@
var t = require('../../process/traversal');
var Bytecode = require('../../process/bytecode');
-var g = require('../graph.js');
+var g = require('../graph');
+var utils = require('../../utils');
/**
* A type serializer
@@ -67,7 +68,8 @@ var serializers = [
LambdaSerializer,
EnumSerializer,
VertexSerializer,
- EdgeSerializer
+ EdgeSerializer,
+ LongSerializer
];
/**
@@ -210,6 +212,21 @@ NumberSerializer.prototype.canBeUsedFor = function (value) {
return (typeof value === 'number');
};
+function LongSerializer() {
+
+}
+
+NumberSerializer.prototype.serialize = function (item) {
+ return {
+ [typeKey]: 'g:Int64',
+ [valueKey]: item.value
+ };
+};
+
+NumberSerializer.prototype.canBeUsedFor = function (value) {
+ return (value instanceof utils.Long);
+};
+
function BytecodeSerializer() {
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/93cf86d0/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
index 7691dda..cbaa53e 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
@@ -59,4 +59,15 @@ exports.resolvedPromise = function (promiseFactory) {
var toPromise = exports.toPromise = function toPromise(promiseFactory, handler) {
promiseFactory = promiseFactory || defaultPromiseFactory;
return promiseFactory(handler);
+};
+
+exports.toLong = function toLong(value) {
+ return new Long(value);
+};
+
+var Long = exports.Long = function Long(value) {
+ if (typeof value !== 'string' && typeof value !== 'number') {
+ throw new TypeError('Ty')
+ }
+ this.value = value.toString();
};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/93cf86d0/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index 7c4a3d6..aae9eb9 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -30,7 +30,7 @@
},
"scripts": {
"test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
- "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/AddVertex.feature",
+ "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
"unit-test": "./node_modules/.bin/mocha test/unit"
},
"engines": {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/93cf86d0/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 06a3283..12bc835 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -29,6 +29,7 @@ const util = require('util');
const graphModule = require('../../lib/structure/graph');
const graphTraversalModule = require('../../lib/process/graph-traversal');
const traversalModule = require('../../lib/process/traversal');
+const utils = require('../../lib/utils');
const Graph = graphModule.Graph;
const Path = graphModule.Path;
const __ = graphTraversalModule.statics;
@@ -185,6 +186,7 @@ function getSandbox(g, parameters) {
Scope: traversalModule.scope,
Operator: traversalModule.operator,
T: traversalModule.t,
+ toLong: utils.toLong
};
// Pass the parameter to the sandbox
Object.keys(parameters).forEach(paramName => sandbox[paramName] = parameters[paramName]);
@@ -194,8 +196,8 @@ function getSandbox(g, parameters) {
function translate(traversalText) {
// Remove escaped chars
traversalText = traversalText.replace(/\\"/g, '"');
- // Remove long suffix
- traversalText = traversalText.replace(/\b(\d+)l\b/gi, '$1');
+ // Replace long suffix with Long instance
+ traversalText = traversalText.replace(/\b(\d+)l\b/gi, 'toLong($1)');
// Change according to naming convention
traversalText = traversalText.replace(/\.in\(/g, '.in_(');
traversalText = traversalText.replace(/\.from\(/g, '.from_(');
[25/47] tinkerpop git commit: Parse traversal parameters and use
empty graph
Posted by jo...@apache.org.
Parse traversal parameters and use empty graph
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/15c86798
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/15c86798
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/15c86798
Branch: refs/heads/master
Commit: 15c86798aacf2732120f303a001421e4111c230c
Parents: e73038c
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Fri Nov 24 15:04:41 2017 +0100
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Fri Jan 19 09:30:16 2018 +0100
----------------------------------------------------------------------
gremlin-javascript/glv/PackageJson.template | 5 +-
.../gremlin-javascript/lib/structure/graph.js | 31 ++++
.../javascript/gremlin-javascript/package.json | 5 +-
.../test/cucumber/feature-steps.js | 156 +++++++++++++++----
.../gremlin-javascript/test/cucumber/world.js | 33 +++-
.../test/integration/remote-connection-tests.js | 2 +-
.../test/integration/traversal-test.js | 2 +-
7 files changed, 195 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/15c86798/gremlin-javascript/glv/PackageJson.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/PackageJson.template b/gremlin-javascript/glv/PackageJson.template
index 52d2c1d..4f1ac05 100644
--- a/gremlin-javascript/glv/PackageJson.template
+++ b/gremlin-javascript/glv/PackageJson.template
@@ -37,7 +37,8 @@
},
"devDependencies": {
"mocha": "~4.0.1",
- "cucumber": "~3.1.0"
+ "cucumber": "~3.1.0",
+ "chai": "~4.1.2"
},
"repository": {
"type": "git",
@@ -48,7 +49,7 @@
},
"scripts": {
"test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
- "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/Count.feature",
+ "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/AddVertex.feature",
"unit-test": "./node_modules/.bin/mocha test/unit"
},
"engines": {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/15c86798/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
index 4ef3fd5..95fd30f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/graph.js
@@ -128,6 +128,37 @@ function Path(labels, objects) {
this.objects = objects;
}
+Path.prototype.equals = function (other) {
+ if (!(other instanceof Path)) {
+ return false;
+ }
+ if (other === this) {
+ return true;
+ }
+ return areEqual(this.objects, other.objects) && areEqual(this.labels, other.labels);
+};
+
+function areEqual(obj1, obj2) {
+ if (obj1 === obj2) {
+ return true;
+ }
+ if (typeof obj1.equals === 'function') {
+ return obj1.equals(obj2);
+ }
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
+ if (obj1.length !== obj2.length) {
+ return false;
+ }
+ for (let i = 0; i < obj1.length; i++) {
+ if (!areEqual(obj1[i], obj2[i])){
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
module.exports = {
Edge: Edge,
Graph: Graph,
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/15c86798/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index 43cf35f..aae9eb9 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -18,7 +18,8 @@
},
"devDependencies": {
"mocha": "~4.0.1",
- "cucumber": "~3.1.0"
+ "cucumber": "~3.1.0",
+ "chai": "~4.1.2"
},
"repository": {
"type": "git",
@@ -29,7 +30,7 @@
},
"scripts": {
"test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
- "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/Count.feature",
+ "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
"unit-test": "./node_modules/.bin/mocha test/unit"
},
"engines": {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/15c86798/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 5270b39..6625f29 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -23,36 +23,60 @@
'use strict';
const defineSupportCode = require('cucumber').defineSupportCode;
-const assert = require('assert');
const vm = require('vm');
+const expect = require('chai').expect;
const graphModule = require('../../lib/structure/graph');
const graphTraversalModule = require('../../lib/process/graph-traversal');
const traversalModule = require('../../lib/process/traversal');
const Graph = graphModule.Graph;
+const Path = graphModule.Path;
const __ = graphTraversalModule.statics;
+const parsers = [
+ [ 'd\\[([\\d.]+)\\]\\.[ilfdm]', toNumeric ],
+ [ 'v\\[(.+)\\]', toVertex ],
+ [ 'v\\[(.+)\\]\\.id', toVertexId ],
+ [ 'v\\[(.+)\\]\\.sid', toVertexIdString ],
+ [ 'e\\[(.+)\\]', toEdge ],
+ [ 'e\\[(.+)\\]\\.id', toEdgeId ],
+ [ 'e\\[(.+)\\]\\.sid', toEdgeIdString ],
+ [ 'p\\[(.+)\\]', toPath ],
+ [ 'l\\[(.*)\\]', toArray ],
+ [ 's\\[(.*)\\]', toArray ],
+ [ 'm\\[(.+)\\]', toMap ],
+ [ 'c\\[(.+)\\]', toLambda ]
+].map(x => [ new RegExp('^' + x[0] + '$'), x[1] ]);
+
defineSupportCode(function(methods) {
methods.Given(/^the (.+) graph$/, function (graphName) {
+ this.graphName = graphName;
+ const data = this.getData();
+ this.g = new Graph().traversal().withRemote(data.connection);
if (graphName === 'empty') {
- //TODO
+ return this.cleanEmptyGraph();
}
- const data = this.getDataByGraphName(graphName);
- this.graphName = graphName;
- this.g = new Graph().traversal().withRemote(data.connection)
});
- methods.Given('the graph initializer of', function () {
- //TODO
+ methods.Given('the graph initializer of', function (traversalText) {
+ const traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
+ return traversal.toList();
});
methods.Given('an unsupported test', () => {});
methods.Given('the traversal of', function (traversalText) {
- this.traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g));
+ this.traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
});
- methods.Given(/^$/, function (paramName, stringValue) {
- //TODO: Add parameter
+ methods.Given(/^using the parameter (.+) defined as "(.+)"$/, function (paramName, stringValue) {
+ let p = Promise.resolve();
+ if (this.graphName === 'empty') {
+ p = this.loadEmptyGraphData();
+ }
+ const self = this;
+ return p.then(() => {
+ self.parameters[paramName] = parseValue.call(self, stringValue);
+ });
});
methods.When('iterated to list', function () {
@@ -63,35 +87,44 @@ defineSupportCode(function(methods) {
return this.traversal.next().then(it => this.result = it.value);
});
- methods.Then(/^the result should be (\w+)$/, function (characterizedAs, resultTable) {
+ methods.Then(/^the result should be (\w+)$/, function assertResult(characterizedAs, resultTable) {
+ if (characterizedAs === 'empty') {
+ expect(this.result).to.be.empty;
+ if (typeof resultTable === 'function'){
+ return resultTable();
+ }
+ return;
+ }
+ const expectedResult = resultTable.rows().map(row => parseRow.call(this, row));
switch (characterizedAs) {
- case 'empty':
- assert.strictEqual(0, result.length);
- break;
case 'ordered':
- const expectedResult = resultTable.rows().map(parseRow);
console.log('--- ordered', expectedResult);
+ expect(this.result).to.have.deep.ordered.members(expectedResult);
+ break;
+ case 'unordered':
+ console.log('--- unordered expected:', expectedResult);
+ console.log('--- obtained:', this.result);
+ expect(this.result).to.have.deep.members(expectedResult);
break;
- }
- //TODO
- if (typeof resultTable === 'function'){
- return resultTable();
}
});
- methods.Then(/^the graph should return (\d+) for count of (.+)$/, function (stringCount, traversalString) {
-
+ methods.Then(/^the graph should return (\d+) for count of "(.+)"$/, function (stringCount, traversalText) {
+ const traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
+ return traversal.toList().then(list => {
+ expect(list).to.have.lengthOf(parseInt(stringCount, 10));
+ });
});
methods.Then(/^the result should have a count of (\d+)$/, function (stringCount) {
-
+ expect(this.result).to.have.lengthOf(parseInt(stringCount, 10));
});
- methods.Then('nothing should happen because', () => {});
+ methods.Then('nothing should happen because', _ => {});
});
-function getSandbox(g) {
- return {
+function getSandbox(g, parameters) {
+ const sandbox = {
g: g,
__: __,
Cardinality: traversalModule.cardinality,
@@ -104,14 +137,79 @@ function getSandbox(g) {
Operator: traversalModule.operator,
T: traversalModule.t,
};
+ // Pass the parameter to the sandbox
+ Object.keys(parameters).forEach(paramName => sandbox[paramName] = parameters[paramName]);
+ return sandbox;
}
function translate(traversalText) {
- traversalText = traversalText.replace('.in(', '.in_(');
- traversalText = traversalText.replace('.from(', '.from_(');
+ // Remove escaped chars
+ traversalText = traversalText.replace(/\\"/g, '"');
+ // Change according to naming convention
+ traversalText = traversalText.replace(/\.in\(/g, '.in_(');
+ traversalText = traversalText.replace(/\.from\(/g, '.from_(');
return traversalText;
}
function parseRow(row) {
- return row[0];
-}
\ No newline at end of file
+ return parseValue.call(this, row[0]);
+}
+
+function parseValue(stringValue) {
+ let extractedValue = null;
+ let parser = null;
+ for (let item of parsers) {
+ let re = item[0];
+ let match = re.exec(stringValue);
+ if (match && match.length > 1) {
+ parser = item[1];
+ extractedValue = match[1];
+ break;
+ }
+ }
+ return parser !== null ? parser.call(this, extractedValue) : stringValue;
+}
+
+function toNumeric(stringValue) {
+ return parseFloat(stringValue);
+}
+
+function toVertex(name) {
+ return this.getData().vertices[name];
+}
+
+function toVertexId(name) {
+ return toVertex.call(this, name).id;
+}
+
+function toVertexIdString(name) {
+ return toVertex.call(this, name).id.toString();
+}
+
+function toEdge(name) {
+ return this.getData().edges[name];
+}
+
+function toEdgeId(name) {
+ return toEdge.call(this, name).id;
+}
+
+function toEdgeIdString(name) {
+ return toEdge.call(this, name).id.toString();
+}
+
+function toPath(value) {
+ const parts = value.split(',');
+ return new Path(parts.map(_ => new Array(0)), parts.map(x => parseValue.call(this, x)));
+}
+
+function toArray(stringList) {
+ if (stringList === '') {
+ return new Array(0);
+ }
+ return stringList.split(',').map(x => parseValue.call(this, x));
+}
+
+function toMap() {}
+
+function toLambda() {}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/15c86798/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
index 8f72c58..946d124 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -37,18 +37,43 @@ defineSupportCode(function (methods) {
this.traversal = null;
this.result = null;
this.cache = null;
+ this.graphName = null;
+ this.parameters = {};
}
- TinkerPopWorld.prototype.getDataByGraphName = function (name) {
- return this.cache[name];
+ TinkerPopWorld.prototype.getData = function () {
+ if (!this.graphName) {
+ throw new Error("Graph name is not set");
+ }
+ return this.cache[this.graphName];
+ };
+
+ TinkerPopWorld.prototype.cleanEmptyGraph = function () {
+ const connection = this.cache['empty'].connection;
+ const g = new Graph().traversal().withRemote(connection);
+ return g.V().drop().toList();
+ };
+
+ TinkerPopWorld.prototype.loadEmptyGraphData = function () {
+ const cacheData = this.cache['empty'];
+ const c = cacheData.connection;
+ return Promise.all([ getVertices(c), getEdges(c) ]).then(values => {
+ cacheData.vertices = values[0];
+ cacheData.edges = values[1];
+ });
};
methods.setWorldConstructor(TinkerPopWorld);
methods.BeforeAll(function () {
// load all traversals
- const promises = ['modern', 'classic', 'crew', 'grateful'].map(graphName => {
- const connection = helper.getConnection('g' + graphName);
+ const promises = ['modern', 'classic', 'crew', 'grateful', 'empty'].map(graphName => {
+ let connection = null;
+ if (graphName === 'empty') {
+ connection = helper.getConnection('ggraph');
+ return connection.open().then(() => cache['empty'] = { connection: connection });
+ }
+ connection = helper.getConnection('g' + graphName);
return connection.open()
.then(() => Promise.all([getVertices(connection), getEdges(connection)]))
.then(values => {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/15c86798/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
index 268773c..e4895fe 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/remote-connection-tests.js
@@ -39,7 +39,7 @@ describe('DriverRemoteConnection', function () {
});
describe('#submit()', function () {
it('should send the request and parse the response', function () {
- return connection.submit(new Bytecode().addStep('addV', [ 'person' ]).addStep('property', [ 'name', 'marko']))
+ return connection.submit(new Bytecode().addStep('V', []).addStep('tail', []))
.then(function (response) {
assert.ok(response);
assert.ok(response.traversers);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/15c86798/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
index adb7d6c..7109427 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js
@@ -44,7 +44,7 @@ describe('Traversal', function () {
var g = new Graph().traversal().withRemote(connection);
return g.V().toList().then(function (list) {
assert.ok(list);
- assert.strictEqual(list.length, 7);
+ assert.strictEqual(list.length, 6);
list.forEach(v => assert.ok(v instanceof Vertex));
});
});