[ https://issues.apache.org/jira/browse/TINKERPOP-1237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15216468#comment-15216468 ]
ASF GitHub Bot commented on TINKERPOP-1237: ------------------------------------------- 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 <okramma...@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. ---- > ProjectMap: For the Love of Die Faterland > ----------------------------------------- > > Key: TINKERPOP-1237 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1237 > Project: TinkerPop > Issue Type: Improvement > Components: process > Affects Versions: 3.1.1-incubating > Reporter: Marko A. Rodriguez > Assignee: Daniel Kuppitz > > {code} > gremlin> g.V(1).out("knows"). > project("a","b").by("name").by(outE().count()) > ==>{a:josh, b:2} > ==>{a:vadas, b:0} > {code} > Its like {{select()}} by inverted -- thus, {{project()}}! Moreover, its a > generalization of {{valueMap()}} and {{propertyMap}}. > {code} > 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; > } > } > {code} > cc/ Mein Obergruppenführer [~mbroecheler]. -- This message was sent by Atlassian JIRA (v6.3.4#6332)