You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2019/05/17 11:59:06 UTC

[tinkerpop] branch master updated (cc285d4 -> 1b221be)

This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


    from cc285d4  Merge branch 'tp33'
     add d09d7fb  TINKERPOP-2089 Added DSL support to gremlin-javascript
     add 22e3560  TINKERPOP-2089 Minor fixes
     add bc004a5  TINKERPOP-2089 Added tests for anoynmous DSL steps
     add d8353f4  TINKERPOP-2089 Added docs for javascript DSL
     add 52bfdfe  TINKERPOP-2089 Minor fix to update docs
     new 7095e39  Merge branch 'TINKERPOP-2089' into tp33
     new 1b221be  Merge branch 'tp33'

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGELOG.asciidoc                                 |  1 +
 docs/src/reference/gremlin-variants.asciidoc       | 60 ++++++++++++++++++++++
 docs/src/upgrade/release-3.3.x.asciidoc            |  9 ++++
 .../glv/GraphTraversalSource.template              | 18 ++++---
 .../lib/process/anonymous-traversal.js             | 15 ++++--
 .../lib/process/graph-traversal.js                 | 36 +++++++------
 .../gremlin-javascript/lib/structure/graph.js      |  8 +--
 .../test/integration/traversal-test.js             | 56 ++++++++++++++++++--
 8 files changed, 172 insertions(+), 31 deletions(-)


[tinkerpop] 01/02: Merge branch 'TINKERPOP-2089' into tp33

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 7095e395e58a1074fbc5fb8705ac6703041f4532
Merge: ad12862 52bfdfe
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Fri May 17 07:56:07 2019 -0400

    Merge branch 'TINKERPOP-2089' into tp33

 CHANGELOG.asciidoc                                 |  1 +
 docs/src/reference/the-traversal.asciidoc          | 62 ++++++++++++++++++++++
 docs/src/upgrade/release-3.3.x.asciidoc            |  9 ++++
 .../glv/GraphTraversalSource.template              | 18 ++++---
 .../lib/process/anonymous-traversal.js             | 15 ++++--
 .../lib/process/graph-traversal.js                 | 36 +++++++------
 .../gremlin-javascript/lib/structure/graph.js      |  8 +--
 .../test/integration/traversal-test.js             | 56 +++++++++++++++++--
 8 files changed, 174 insertions(+), 31 deletions(-)



[tinkerpop] 02/02: Merge branch 'tp33'

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 1b221be178c8c7c711b8c3961f63edb657628eec
Merge: cc285d4 7095e39
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Fri May 17 07:58:51 2019 -0400

    Merge branch 'tp33'

 CHANGELOG.asciidoc                                 |  1 +
 docs/src/reference/gremlin-variants.asciidoc       | 60 ++++++++++++++++++++++
 docs/src/upgrade/release-3.3.x.asciidoc            |  9 ++++
 .../glv/GraphTraversalSource.template              | 18 ++++---
 .../lib/process/anonymous-traversal.js             | 15 ++++--
 .../lib/process/graph-traversal.js                 | 36 +++++++------
 .../gremlin-javascript/lib/structure/graph.js      |  8 +--
 .../test/integration/traversal-test.js             | 56 ++++++++++++++++++--
 8 files changed, 172 insertions(+), 31 deletions(-)

diff --cc docs/src/reference/gremlin-variants.asciidoc
index 5993eb1,e4a6cef..24a4e2d
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@@ -1236,4 -621,5 +1236,64 @@@ const result2 = await client.submit('g.
  for (const vertex of result2) {
    console.log(vertex.id);
  }
 +----
++
++[[gremlin-javascript-dsl]]
++=== Domain Specific Languages
++
++Developing Gremlin DSLs in JavaScript largely requires extension of existing core classes with use of standalone
++functions for anonymous traversal spawning. The pattern is demonstrated in the following example:
++
++[source,javascript]
++----
++class SocialTraversal extends GraphTraversal {
++  constructor(graph, traversalStrategies, bytecode) {
++    super(graph, traversalStrategies, bytecode);
++  }
++
++  aged(age) {
++    return this.has('person', 'age', age);
++  }
++}
++
++class SocialTraversalSource extends GraphTraversalSource {
++  constructor(graph, traversalStrategies, bytecode) {
++    super(graph, traversalStrategies, bytecode, SocialTraversalSource, SocialTraversal);
++  }
+ 
++  person(name) {
++    return this.V().has('person', 'name', name);
++  }
++}
++
++function anonymous() {
++  return new SocialTraversal(null, null, new Bytecode());
++}
++
++function aged(age) {
++  return anonymous().aged(age);
++}
++----
++
++`SocialTraversal` extends the core `GraphTraversal` class and has a three argument constructor which is immediately
++proxied to the `GraphTraversal` constructor. New DSL steps are then added to this class using available steps to
++construct the underlying traversal to execute as demonstrated in the `aged()` step.
++
++The `SocialTraversal` is spawned from a `SocialTraversalSource` which is extended from `GraphTraversalSource`. Steps
++added here are meant to be start steps. In the above case, the `person()` start step find a "person" vertex to begin
++the traversal from.
++
++Typically, steps that are made available on a `GraphTraversal` (i.e. SocialTraversal in this example) should also be
++made available as spawns for anonymous traversals. The recommendation is that these steps be exposed in the module
++as standalone functions. In the example above, the standalone `aged()` step creates an anonymous traversal through
++an `anonymous()` utility function. The method for creating these standalone functions can be handled in other ways if
++desired.
++
++To use the DSL, simply initialize the `g` as follows:
++
++[source,javascript]
++----
++const g = traversal(SocialTraversalSource).withRemote(connection);
++g.person('marko').aged(29).values('name').toList().
++  then(names => console.log(names));
+ ----
diff --cc gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js
index ec554e6,34e06db..c068262
--- 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
@@@ -179,19 -175,9 +185,19 @@@ class GraphTraversalSource 
     */
    inject(...args) {
      const b = new Bytecode(this.bytecode).addStep('inject', args);
-     return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
+     return new this.graphTraversalClass(this.graph, new TraversalStrategies(this.traversalStrategies), b);
    }
    
 +  /**
 +   * io GraphTraversalSource step method.
 +   * @param {...Object} args
 +   * @returns {GraphTraversal}
 +   */
 +  io(...args) {
 +    const b = new Bytecode(this.bytecode).addStep('io', args);
 +    return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b);
 +  }
 +  
  }
  
  /**