Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.0.2-incubating
    • Fix Version/s: 3.2.5
    • Component/s: documentation
    • Labels:
      None

      Description

      Develop and document the patterns for custom DSLs. The method previously described and under consideration at 3.0.0 seems a bit cumbersome to deal with.

        Issue Links

          Activity

          Hide
          spmallette stephen mallette added a comment -

          Some discussion on this topic on the mailing list: https://groups.google.com/d/msg/gremlin-users/HW_p51tA74g/FhxduVHvrxUJ

          Show
          spmallette stephen mallette added a comment - Some discussion on this topic on the mailing list: https://groups.google.com/d/msg/gremlin-users/HW_p51tA74g/FhxduVHvrxUJ
          Hide
          okram Marko A. Rodriguez added a comment -

          Daniel Kuppitz We should work on section of the docs describing this stuff.

          Show
          okram Marko A. Rodriguez added a comment - Daniel Kuppitz We should work on section of the docs describing this stuff.
          Hide
          okram Marko A. Rodriguez added a comment - - edited

          Jeremy Hanna was interested in how this will look. Its easy.

          public SocailTraversal<S,E> extends DefaultTraversal<S,E> {
          
            private final GraphTraversal<S,E> rawTraversal = new DefaultGraphTraversal<S,E>();
          
            public SocialTraversal<S,Vertex> know(final String personName) {
              this.rawTraversal.out("knows").hasLabel("person").has("name",personName);
              return this;
            }
          
            public SocialTraversal<S,Vertex> olderThan(final String personName) {
              this.rawTraversal.filter(as("xx").V().has("name",personName").values("age").where(lt("xx")));
             return this;
            }
          
           public SocialTraversal<S,Vertex> people() {
              this.rawTraversal.V().hasLabel("person");
              return this;
           }
          
           public SocialTraversal<S,String> name() {
             this.rawTraversal.values("name");
             return this;
           }
           
           public SocialTraversal<S,E> who() {
             return this;
            }
          
            public SocialTraversal<S,E> thatAre() {
             return this;
            }
            ......
          }
          

          They will then need a TraversalSource implementation which we will have a DefaultTraversalSource to make things easy. And finally, in action:

          social = graph.traversal(SocialTraversal.class)
          social.people().who().know("stephen").thatAre().olderThan("daniel").name()
          

          TADA!

          Show
          okram Marko A. Rodriguez added a comment - - edited Jeremy Hanna was interested in how this will look. Its easy. public SocailTraversal<S,E> extends DefaultTraversal<S,E> { private final GraphTraversal<S,E> rawTraversal = new DefaultGraphTraversal<S,E>(); public SocialTraversal<S,Vertex> know( final String personName) { this .rawTraversal.out( "knows" ).hasLabel( "person" ).has( "name" ,personName); return this ; } public SocialTraversal<S,Vertex> olderThan( final String personName) { this .rawTraversal.filter(as( "xx" ).V().has( "name" ,personName ").values(" age ").where(lt(" xx"))); return this ; } public SocialTraversal<S,Vertex> people() { this .rawTraversal.V().hasLabel( "person" ); return this ; } public SocialTraversal<S, String > name() { this .rawTraversal.values( "name" ); return this ; } public SocialTraversal<S,E> who() { return this ; } public SocialTraversal<S,E> thatAre() { return this ; } ...... } They will then need a TraversalSource implementation which we will have a DefaultTraversalSource to make things easy. And finally, in action: social = graph.traversal(SocialTraversal.class) social.people().who().know( "stephen" ).thatAre().olderThan( "daniel" ).name() TADA!
          Hide
          okram Marko A. Rodriguez added a comment -

          This is now possible with the merging of TINKERPOP-971.

          Show
          okram Marko A. Rodriguez added a comment - This is now possible with the merging of TINKERPOP-971 .
          Hide
          spmallette stephen mallette added a comment -

          Perhaps we need a tutorial written on this topic at this point as it sounds like the pattern is decided. I'm going to switch the type on this issue to "documentation" and here's some recent discussion on the mailing list for ways DSLs can be implemented:

          https://groups.google.com/d/msg/gremlin-users/FO3bcXHWTrg/6H64dHrUFgAJ

          Show
          spmallette stephen mallette added a comment - Perhaps we need a tutorial written on this topic at this point as it sounds like the pattern is decided. I'm going to switch the type on this issue to "documentation" and here's some recent discussion on the mailing list for ways DSLs can be implemented: https://groups.google.com/d/msg/gremlin-users/FO3bcXHWTrg/6H64dHrUFgAJ
          Hide
          gereedy Geoff Reedy added a comment -

          Unless I'm missing something, this approach doesn't enable extension of an existing traversal DSL. For my use case, and I imagine many others' as well, this ability is critical.

          Show
          gereedy Geoff Reedy added a comment - Unless I'm missing something, this approach doesn't enable extension of an existing traversal DSL. For my use case, and I imagine many others' as well, this ability is critical.
          Hide
          spmallette stephen mallette added a comment -

          It occurs to me that I'm not sure how DSLs will work with the remoting API/GLVs. not sure if anyone has any thoughts on that.

          Show
          spmallette stephen mallette added a comment - It occurs to me that I'm not sure how DSLs will work with the remoting API/GLVs. not sure if anyone has any thoughts on that.
          Hide
          Florian Hockmann Florian Hockmann added a comment -

          Since all GLVs will probably use some form of code generator which will most likely be based on gremlin-java, I think the best option here would be to make those generators flexible enough so that they can be used with a DSL defined by users.
          When we define a common interface for the GLV generators, then users can simply call the generators on their own DSL and get the DSL in all GLVs.
          Maybe the interfaces could look something like this:

          1. GraphTraversalGenerator: Takes a GraphTraversal class or a class derived from that as its input
          2. GraphTraversalSourceGenerator: Takes a GraphTraversalSource class or a class derived from that as its input
          3. EnumGenerator: Takes an enum class as its input (like T)
          4. PredicateGenerator: Takes a predicate class as its input (like P)

          This would probably require some modifications to the existing GLV generators so that they implement those interfaces and also to make them flexible enough to work with a DSL (e.g. the generator should not only expect a GraphTraversal as the return type for steps but also a type that derives from that).

          Show
          Florian Hockmann Florian Hockmann added a comment - Since all GLVs will probably use some form of code generator which will most likely be based on gremlin-java, I think the best option here would be to make those generators flexible enough so that they can be used with a DSL defined by users. When we define a common interface for the GLV generators, then users can simply call the generators on their own DSL and get the DSL in all GLVs. Maybe the interfaces could look something like this: GraphTraversalGenerator : Takes a GraphTraversal class or a class derived from that as its input GraphTraversalSourceGenerator : Takes a GraphTraversalSource class or a class derived from that as its input EnumGenerator : Takes an enum class as its input (like T ) PredicateGenerator : Takes a predicate class as its input (like P ) This would probably require some modifications to the existing GLV generators so that they implement those interfaces and also to make them flexible enough to work with a DSL (e.g. the generator should not only expect a GraphTraversal as the return type for steps but also a type that derives from that).
          Hide
          okram Marko A. Rodriguez added a comment -

          That is a good idea Florian Hockmann. That would definitely make it easier to "pump out" GLVs and keep them all unified and easier to maintain.

          Show
          okram Marko A. Rodriguez added a comment - That is a good idea Florian Hockmann . That would definitely make it easier to "pump out" GLVs and keep them all unified and easier to maintain.
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user spmallette opened a pull request:

          https://github.com/apache/tinkerpop/pull/610

          TINKERPOP-786 Gremlin DSL Support

          https://issues.apache.org/jira/browse/TINKERPOP-786

          This pull request provides tools, documentation, tests and examples for how to develop DSLs for both Java/Groovy as well Python. Note the addition of the new `gremlin-archetype-dsl` module which demonstrates how the DSL system works with Java/Groovy and see `test_dsl.py` for the recommended method for python.

          Builds with `docker/build.sh -t -i -n`

          VOTE +1

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/apache/tinkerpop TINKERPOP-786

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/tinkerpop/pull/610.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #610



          Show
          githubbot ASF GitHub Bot added a comment - GitHub user spmallette opened a pull request: https://github.com/apache/tinkerpop/pull/610 TINKERPOP-786 Gremlin DSL Support https://issues.apache.org/jira/browse/TINKERPOP-786 This pull request provides tools, documentation, tests and examples for how to develop DSLs for both Java/Groovy as well Python. Note the addition of the new `gremlin-archetype-dsl` module which demonstrates how the DSL system works with Java/Groovy and see `test_dsl.py` for the recommended method for python. Builds with `docker/build.sh -t -i -n` VOTE +1 You can merge this pull request into a Git repository by running: $ git pull https://github.com/apache/tinkerpop TINKERPOP-786 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/tinkerpop/pull/610.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #610
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user dkuppitz commented on the issue:

          https://github.com/apache/tinkerpop/pull/610

          Slick! It's indeed much easier than I thought.

          VOTE: +1

          Show
          githubbot ASF GitHub Bot added a comment - Github user dkuppitz commented on the issue: https://github.com/apache/tinkerpop/pull/610 Slick! It's indeed much easier than I thought. VOTE: +1
          Hide
          gereedy Geoff Reedy added a comment -

          This looks quite similar to the approach we have been using internally, almost a drop in replacement; very excited to see it, thanks Stephen. I'll take a look and see if it works for our use case; now that there's some existing code here we may be able to contribute some improvements if necessary.

          Show
          gereedy Geoff Reedy added a comment - This looks quite similar to the approach we have been using internally, almost a drop in replacement; very excited to see it, thanks Stephen. I'll take a look and see if it works for our use case; now that there's some existing code here we may be able to contribute some improvements if necessary.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user okram commented on the issue:

          https://github.com/apache/tinkerpop/pull/610

          VOTE +1.

          Show
          githubbot ASF GitHub Bot added a comment - Github user okram commented on the issue: https://github.com/apache/tinkerpop/pull/610 VOTE +1.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user n-tran commented on the issue:

          https://github.com/apache/tinkerpop/pull/610

          +1

          Show
          githubbot ASF GitHub Bot added a comment - Github user n-tran commented on the issue: https://github.com/apache/tinkerpop/pull/610 +1
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/tinkerpop/pull/610

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/tinkerpop/pull/610

            People

            • Assignee:
              spmallette stephen mallette
              Reporter:
              spmallette stephen mallette
            • Votes:
              4 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development