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/bbe33776
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/bbe33776
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/bbe33776

Branch: refs/heads/master
Commit: bbe337765d899bd3815d3f92585e5ba54ebb49cd
Parents: 78851d7 2fedaac
Author: Marko A. Rodriguez <[email protected]>
Authored: Fri Mar 24 08:41:34 2017 -0600
Committer: Marko A. Rodriguez <[email protected]>
Committed: Fri Mar 24 08:41:34 2017 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   5 +
 docs/src/reference/the-traversal.asciidoc       |  58 +++
 .../upgrade/release-3.2.x-incubating.asciidoc   |  16 +
 .../gremlin/process/traversal/Path.java         |  57 +++
 .../traversal/dsl/graph/GraphTraversal.java     | 423 +++++++++----------
 .../traversal/step/FromToModulating.java        |  48 +++
 .../traversal/step/filter/CyclicPathStep.java   |  46 --
 .../traversal/step/filter/PathFilterStep.java   | 139 ++++++
 .../traversal/step/filter/SimplePathStep.java   |  47 ---
 .../process/traversal/step/map/AddEdgeStep.java |  19 +-
 .../process/traversal/step/map/PathStep.java    |  29 +-
 .../optimization/FilterRankingStrategy.java     |  38 +-
 .../IncidentToAdjacentStrategy.java             |   7 +-
 .../gremlin/process/traversal/PathTest.java     | 128 +++++-
 .../step/filter/CyclicPathStepTest.java         |  37 --
 .../step/filter/PathFilterStepTest.java         |  53 +++
 .../step/filter/SimplePathStepTest.java         |  37 --
 .../process/traversal/step/ComplexTest.java     |  49 ++-
 .../traversal/step/filter/CyclicPathTest.java   |  16 +-
 .../traversal/step/filter/SimplePathTest.java   |  29 +-
 .../process/traversal/step/map/PathTest.java    |  20 +
 21 files changed, 858 insertions(+), 443 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bbe33776/CHANGELOG.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bbe33776/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------
diff --cc docs/src/reference/the-traversal.asciidoc
index eea606e,b0db605..d381d4e
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@@ -2033,37 -2051,41 +2049,70 @@@ objects in it, the traverser is filtere
  g.V(1).both().both()
  g.V(1).both().both().simplePath()
  g.V(1).both().both().simplePath().path()
- ----
+ g.V().out().as('a').out().as('b').out().as('c').
+   simplePath().by(label).
+   path()
+ g.V().out().as('a').out().as('b').out().as('c').
+   simplePath().
+     by(label).
+     from('b').
+     to('c').
+   path().
+     by('name')
+ ----
+ 
+ By using the `from()` and `to()` modulators traversers can ensure that only 
certain sections of the path are are acyclic.
+ 
+ [gremlin-grovvy]
+ ----
 -g.addV().property(id, "A").as("a").
 -  addV().property(id, "B").as("b").
 -  addV().property(id, "C").as("c").
 -  addV().property(id, "D").as("d").
 -  addE("link").from("a").to("b").
 -  addE("link").from("b").to("c").
 -  addE("link").from("c").to("d").iterate()
 -g.V("A").repeat(both().simplePath()).times(3).path()  <1>
 -g.V("D").repeat(both().simplePath()).times(3).path()  <2>
 -g.V("A").as("a").
 -  repeat(both().simplePath().from("a")).times(3).as("b").
 -  repeat(both().simplePath().from("b")).times(3).path()  <3>
++g.addV().property(id, 'A').as('a').
++  addV().property(id, 'B').as('b').
++  addV().property(id, 'C').as('c').
++  addV().property(id, 'D').as('d').
++  addE('link').from('a').to('b').
++  addE('link').from('b').to('c').
++  addE('link').from('c').to('d').iterate()
++g.V('A').repeat(both().simplePath()).times(3).path()  <1>
++g.V('D').repeat(both().simplePath()).times(3).path()  <2>
++g.V('A').as('a').
++  repeat(both().simplePath().from('a')).times(3).as('b').
++  repeat(both().simplePath().from('b')).times(3).path()  <3>
+ ----
+ 
+ <1> Traverse all acyclic 3-hop paths starting from vertex `A`
+ <2> Traverse all acyclic 3-hop paths starting from vertex `D`
+ <3> Traverse all acyclic 3-hop paths starting from vertex `A` and from there 
again all 3-hop paths. The second path may
+ cross the vertices from the first path.
  
 +[[skip-step]]
 +Skip Step
 +~~~~~~~~~
 +
 +The `skip()`-step is analogous to <<range-step,`range()`-step>> save that the 
higher end range is set to -1.
 +
 +[gremlin-groovy,modern]
 +----
 +g.V().values('age').order()
 +g.V().values('age').order().skip(2)
 +g.V().values('age').order().range(2, -1)
 +----
 +
 +The `skip()`-step can also be applied with `Scope.local`, in which case it 
operates on the incoming collection.
 +
 +[gremlin-groovy,modern]
 +----
 +g.V().hasLabel('person').filter(outE('created')).as('p'). <1>
 +  map(out('created').values('name').fold()).
 +  project('person','primary','other').
 +    by(select('p').by('name')).
 +    by(limit(local, 1)). <2>
 +    by(skip(local, 1)) <3>
 +----
 +
 +<1> For each person who created something...
 +<2> ...select the first project (random order) as `primary` and...
 +<3> ...select all other projects as `other`.
 +
  [[store-step]]
  Store Step
  ~~~~~~~~~~

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bbe33776/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bbe33776/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Path.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bbe33776/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
----------------------------------------------------------------------
diff --cc 
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
index 66362eb,bde1dea..6ca6a3e
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java
@@@ -564,10 -563,10 +564,10 @@@ public interface GraphTraversal<S, E> e
       * @param propertyKeys  the properties to retrieve
       * @param <E2>          the value type of the returned properties
       * @return the traversal with an appended {@link PropertyMapStep}.
-      * @since 3.0.0-incubating
       * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#valuemap-step";
 target="_blank">Reference Documentation - ValueMap Step</a>
+      * @since 3.0.0-incubating
       */
 -    public default <E2> GraphTraversal<S, Map<String, E2>> valueMap(final 
boolean includeTokens, final String... propertyKeys) {
 +    public default <E2> GraphTraversal<S, Map<Object, E2>> valueMap(final 
boolean includeTokens, final String... propertyKeys) {
          this.asAdmin().getBytecode().addStep(Symbols.valueMap, includeTokens, 
propertyKeys);
          return this.asAdmin().addStep(new PropertyMapStep<>(this.asAdmin(), 
includeTokens, PropertyType.VALUE, propertyKeys));
      }
@@@ -2429,12 -2373,11 +2426,12 @@@
       * Calculates a PageRank over the graph using a 0.85 for the {@code 
alpha} value.
       *
       * @return the traversal with the appended {@link 
PageRankVertexProgramStep}
-      * @since 3.2.0-incubating
       * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#pagerank-step";
 target="_blank">Reference Documentation - PageRank Step</a>
+      * @since 3.2.0-incubating
       */
      public default GraphTraversal<S, E> pageRank() {
 -        return this.pageRank(0.85d);
 +        this.asAdmin().getBytecode().addStep(Symbols.pageRank);
 +        return this.asAdmin().addStep((Step<E, E>) new 
PageRankVertexProgramStep(this.asAdmin(), 0.85d));
      }
  
      /**
@@@ -2500,12 -2443,11 +2497,12 @@@
       * {@code Integer.MAX_VALUE}.
       *
       * @return the traversal with an appended {@link NoOpBarrierStep}
-      * @since 3.0.0-incubating
       * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#barrier-step";
 target="_blank">Reference Documentation - Barrier Step</a>
+      * @since 3.0.0-incubating
       */
      public default GraphTraversal<S, E> barrier() {
 -        return this.barrier(Integer.MAX_VALUE);
 +        this.asAdmin().getBytecode().addStep(Symbols.barrier);
 +        return this.asAdmin().addStep(new NoOpBarrierStep<>(this.asAdmin(), 
Integer.MAX_VALUE));
      }
  
      /**
@@@ -2699,15 -2641,15 +2696,15 @@@
      /**
       * This step modifies {@link #choose(Function)} to specifies the 
available choices that might be executed.
       *
-      * @param pickToken the token that would trigger this option
+      * @param pickToken       the token that would trigger this option
       * @param traversalOption the option as a traversal
       * @return the traversal with the modulated step
-      * @since 3.0.0-incubating
       * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#choose-step";
 target="_blank">Reference Documentation - Choose Step</a>
+      * @since 3.0.0-incubating
       */
 -    public default <M, E2> GraphTraversal<S, E> option(final M pickToken, 
final Traversal<E, E2> traversalOption) {
 +    public default <M, E2> GraphTraversal<S, E> option(final M pickToken, 
final Traversal<?, E2> traversalOption) {
          this.asAdmin().getBytecode().addStep(Symbols.option, pickToken, 
traversalOption);
 -        ((TraversalOptionParent<M, E, E2>) 
this.asAdmin().getEndStep()).addGlobalChildOption(pickToken, 
traversalOption.asAdmin());
 +        ((TraversalOptionParent<M, E, E2>) 
this.asAdmin().getEndStep()).addGlobalChildOption(pickToken, 
(Traversal.Admin<E, E2>) traversalOption.asAdmin());
          return this;
      }
  
@@@ -2716,13 -2658,12 +2713,13 @@@
       *
       * @param traversalOption the option as a traversal
       * @return the traversal with the modulated step
-      * @since 3.0.0-incubating
       * @see <a 
href="http://tinkerpop.apache.org/docs/${project.version}/reference/#choose-step";
 target="_blank">Reference Documentation - Choose Step</a>
+      * @since 3.0.0-incubating
       */
 -    public default <E2> GraphTraversal<S, E> option(final Traversal<E, E2> 
traversalOption) {
 +    public default <E2> GraphTraversal<S, E> option(final Traversal<?, E2> 
traversalOption) {
          this.asAdmin().getBytecode().addStep(Symbols.option, traversalOption);
 -        return this.option(TraversalOptionParent.Pick.any, 
traversalOption.asAdmin());
 +        ((TraversalOptionParent<Object, E, E2>) 
this.asAdmin().getEndStep()).addGlobalChildOption(TraversalOptionParent.Pick.any,
 (Traversal.Admin<E, E2>) traversalOption.asAdmin());
 +        return this;
      }
  
      ////

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bbe33776/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ComplexTest.java
----------------------------------------------------------------------
diff --cc 
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ComplexTest.java
index 7085d4f,d53f9d5..5c6a1e5
--- 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ComplexTest.java
+++ 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/ComplexTest.java
@@@ -285,9 -306,22 +307,22 @@@ public abstract class ComplexTest exten
                              barrier().
                              group("x").
                              by(select("src", "tgt")).
 -                            by(select("p").fold()).select("tgt").barrier()).
 +                            by(select(all, 
"p").fold()).select("tgt").barrier()).
                      
cap("x").select(values).unfold().unfold().map(unfold().id().fold());
          }
+ 
+         @Override
+         public Traversal<Vertex, Map<String, List<String>>> 
getPlaylistPaths() {
+             return g.V().has("name", "Bob_Dylan").in("sungBy").as("a").
+                     
repeat(out().order().by(Order.shuffle).simplePath().from("a")).
+                     until(out("writtenBy").has("name", 
"Johnny_Cash")).limit(1).as("b").
+                     
repeat(out().order().by(Order.shuffle).as("c").simplePath().from("b").to("c")).
+                     until(out("sungBy").has("name", 
"Grateful_Dead")).limit(1).
+                     path().from("a").unfold().
+                     <List<String>>project("song", "artists").
+                     by("name").
+                     by(__.coalesce(out("sungBy", 
"writtenBy").dedup().values("name"), constant("Unknown")).fold());
+         }
      }
  }
  

Reply via email to