Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-1237

ProjectMap: For the Love of Die Faterland

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Implemented
    • 3.1.1-incubating
    • 3.2.0-incubating
    • process
    • None

    Description

      gremlin> g.V(1).out("knows").
                 project("a","b").by("name").by(outE().count())
      ==>{a:josh, b:2}
      ==>{a:vadas, b:0}
      

      Its like select() by inverted – thus, project()! Moreover, its a generalization of valueMap() and propertyMap.

      public class ProjectStep<S,E> extends MapStep<S,Map<String,E>> {
        TraversalRing<S,E> ...
        String... keys;  
      
         public Map<String,E> map(final Traverser.Admin<S> traverser) {
            final Map<String,E> result = new HashMap<>(keys.length);
            for(final String key : keys) {
              result.put(key, TraversalUtil.apply(traverser, traversalRing.next());
            }
            traversalRing.reset();
            return result;
          }
      }
      

      cc/ Mein ObergruppenfĂĽhrer mbroecheler.

      Attachments

        Activity

          okram Marko A. Rodriguez added a comment - - edited

          This ticket should also add by()-modulation TraversalRings to PropertyMapStep. Also, if still efficient, PropertyMapStep should extend ProjectStep and thus, the concept of "forward projection" is born.

          • select(): backwards selection (indefinitely into the past)
          • step(): forward projection (one step in the future)
          • project(): forward projection (indefinitely into the future)

          A whole new dimension of thinking here. This categorization of steps is orthogonal to the map, flatMap, filter, sideEffect categorization.

          okram Marko A. Rodriguez added a comment - - edited This ticket should also add by() -modulation TraversalRings to PropertyMapStep . Also, if still efficient, PropertyMapStep should extend ProjectStep and thus, the concept of "forward projection" is born. select() : backwards selection (indefinitely into the past) step() : forward projection (one step in the future) project() : forward projection (indefinitely into the future) A whole new dimension of thinking here. This categorization of steps is orthogonal to the map , flatMap , filter , sideEffect categorization.
          githubbot ASF GitHub Bot added a comment -

          GitHub user okram opened a pull request:

          https://github.com/apache/incubator-tinkerpop/pull/284

          TINKERPOP-1237: ProjectMap: For the Love of Die Faterland

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

          Added `GraphTraversal.project()` which allows is like the inverse of `select()`. Instead of pulling from this path history, you are pushing into the future. While this can be done with `match()`, `ProjectStep` does not require `LABELED_PATHS` and thus, is more efficient (though, its constrained to local children `by()`-modulation).

          EXAMPLE:

          ```
          gremlin> g.V().out("created").
          project("a","b").
          by("name").
          by(in("created").count()).
          order().by(select("b"),decr).
          select("a")
          ==>lop
          ==>lop
          ==>lop
          ==>ripple
          ```

          CHANGELOG

          ```

          • Added `GraphTraversal.project()` to allow projecting out a `Map<String,E>` given the current traverser and an arbitrary number of `by()`-modulators.
            ```

          Docs build, `mvn clean install` and Giraph (at `ProjectTest`) tested.

          VOTE +1.

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

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

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

          https://github.com/apache/incubator-tinkerpop/pull/284.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 #284


          commit d90be26f1625e376e93ce91adcff725de836a8e5
          Author: Marko A. Rodriguez <okrammarko@gmail.com>
          Date: 2016-03-29T17:44:52Z

          Added ProjectStep and GraphTraversal.project() which is like select(), but on the current traverser, not history data. As such, it does not require path-computations, though its by()-modulators are local children. Added test cases and updated docs.


          githubbot ASF GitHub Bot added a comment - GitHub user okram opened a pull request: https://github.com/apache/incubator-tinkerpop/pull/284 TINKERPOP-1237 : ProjectMap: For the Love of Die Faterland https://issues.apache.org/jira/browse/TINKERPOP-1237 Added `GraphTraversal.project()` which allows is like the inverse of `select()`. Instead of pulling from this path history, you are pushing into the future. While this can be done with `match()`, `ProjectStep` does not require `LABELED_PATHS` and thus, is more efficient (though, its constrained to local children `by()`-modulation). EXAMPLE: ``` gremlin> g.V().out("created"). project("a","b"). by("name"). by(in("created").count()). order().by(select("b"),decr). select("a") ==>lop ==>lop ==>lop ==>ripple ``` CHANGELOG ``` Added `GraphTraversal.project()` to allow projecting out a `Map<String,E>` given the current traverser and an arbitrary number of `by()`-modulators. ``` Docs build, `mvn clean install` and Giraph (at `ProjectTest`) tested. VOTE +1. You can merge this pull request into a Git repository by running: $ git pull https://github.com/apache/incubator-tinkerpop TINKERPOP-1237 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-tinkerpop/pull/284.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 #284 commit d90be26f1625e376e93ce91adcff725de836a8e5 Author: Marko A. Rodriguez <okrammarko@gmail.com> Date: 2016-03-29T17:44:52Z Added ProjectStep and GraphTraversal.project() which is like select(), but on the current traverser, not history data. As such, it does not require path-computations, though its by()-modulators are local children. Added test cases and updated docs.
          githubbot ASF GitHub Bot added a comment -

          Github user dkuppitz commented on the pull request:

          https://github.com/apache/incubator-tinkerpop/pull/284#issuecomment-203038066

          VOTE: +1

          githubbot ASF GitHub Bot added a comment - Github user dkuppitz commented on the pull request: https://github.com/apache/incubator-tinkerpop/pull/284#issuecomment-203038066 VOTE: +1
          githubbot ASF GitHub Bot added a comment -

          Github user twilmes commented on a diff in the pull request:

          https://github.com/apache/incubator-tinkerpop/pull/284#discussion_r57778316

          — Diff: docs/src/reference/the-traversal.asciidoc —
          @@ -1376,6 +1376,24 @@ metrics = t.getSideEffects().get('metrics')

          For traversal compilation information, please see <<explain-step,`explain()`>>-step.

          +[[project-step]]
          +Project Step
          +~~~~~~~~~~~~
          +
          +The `project()`-step (map) projects labeled attributes of the current object into a `Map<String,Object>`. It is similar
          +to <<select-step,`select()`>>-step, save that instead of retrieving and modulating historic traverser state, it modulates
          +the current state of the traverser.
          +
          +[gremlin-groovy,modern]
          +----
          +g.V().out('created').
          + project('a",'b').
          — End diff –

          Small typo, `'a"` -> `'a'`

          githubbot ASF GitHub Bot added a comment - Github user twilmes commented on a diff in the pull request: https://github.com/apache/incubator-tinkerpop/pull/284#discussion_r57778316 — Diff: docs/src/reference/the-traversal.asciidoc — @@ -1376,6 +1376,24 @@ metrics = t.getSideEffects().get('metrics') For traversal compilation information, please see <<explain-step,`explain()`>>-step. +[ [project-step] ] +Project Step +~~~~~~~~~~~~ + +The `project()`-step ( map ) projects labeled attributes of the current object into a `Map<String,Object>`. It is similar +to <<select-step,`select()`>>-step, save that instead of retrieving and modulating historic traverser state, it modulates +the current state of the traverser. + + [gremlin-groovy,modern] +---- +g.V().out('created'). + project('a",'b'). — End diff – Small typo, `'a"` -> `'a'`
          githubbot ASF GitHub Bot added a comment -

          Github user twilmes commented on the pull request:

          https://github.com/apache/incubator-tinkerpop/pull/284#issuecomment-203045239

          VOTE: +1

          githubbot ASF GitHub Bot added a comment - Github user twilmes commented on the pull request: https://github.com/apache/incubator-tinkerpop/pull/284#issuecomment-203045239 VOTE: +1
          githubbot ASF GitHub Bot added a comment -

          Github user okram commented on a diff in the pull request:

          https://github.com/apache/incubator-tinkerpop/pull/284#discussion_r57778538

          — Diff: docs/src/reference/the-traversal.asciidoc —
          @@ -1376,6 +1376,24 @@ metrics = t.getSideEffects().get('metrics')

          For traversal compilation information, please see <<explain-step,`explain()`>>-step.

          +[[project-step]]
          +Project Step
          +~~~~~~~~~~~~
          +
          +The `project()`-step (map) projects labeled attributes of the current object into a `Map<String,Object>`. It is similar
          +to <<select-step,`select()`>>-step, save that instead of retrieving and modulating historic traverser state, it modulates
          +the current state of the traverser.
          +
          +[gremlin-groovy,modern]
          +----
          +g.V().out('created').
          + project('a",'b').
          — End diff –

          I just fixed. I built the docs, then reformatted the text and I caused that. The docs are rebuilding right now... then I will push the typo fix.

          githubbot ASF GitHub Bot added a comment - Github user okram commented on a diff in the pull request: https://github.com/apache/incubator-tinkerpop/pull/284#discussion_r57778538 — Diff: docs/src/reference/the-traversal.asciidoc — @@ -1376,6 +1376,24 @@ metrics = t.getSideEffects().get('metrics') For traversal compilation information, please see <<explain-step,`explain()`>>-step. +[ [project-step] ] +Project Step +~~~~~~~~~~~~ + +The `project()`-step ( map ) projects labeled attributes of the current object into a `Map<String,Object>`. It is similar +to <<select-step,`select()`>>-step, save that instead of retrieving and modulating historic traverser state, it modulates +the current state of the traverser. + + [gremlin-groovy,modern] +---- +g.V().out('created'). + project('a",'b'). — End diff – I just fixed. I built the docs, then reformatted the text and I caused that. The docs are rebuilding right now... then I will push the typo fix.
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/incubator-tinkerpop/pull/284

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

          People

            okram Marko A. Rodriguez
            okram Marko A. Rodriguez
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: