GitHub user okram opened a pull request:

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

    TINKERPOP-1330: by()-modulation for where()

    https://issues.apache.org/jira/browse/TINKERPOP-1330
    
     Added `by()`-modulation support to `where()` predicate-based steps. Added 
3 solid `WhereTest` cases to verify proper functioning. Ensured proper 
`hashCode()` construction in `WhereStepTest`. Also, optimized `TraversalRing` 
to return `null` if there are no traversals in the ring and thus, 
`TraversalUtil.applyNullable()` can be leveraged instead which
     is more efficient than using `IdentityTraversal`. Finally, there was a 
severe bug in Gremlin-Python that made a complex `WhereTest` fail because 
`P.and` and `P.or` nesting was 
     reversed! I have fixed Gremlin-Python `P` in this PR.
    
    ---
    
     Here is an example of the new `where().by()`-model.
    
    ```
    // give me "a" and "b" is "a" knows "b" and "a" is older than "b".
    gremlin> g.V().as("a").out("knows").as("b").
    ......1>   where("a",gt("b")).by("age").
    ......2>   select("a","b").by("name")
    ==>[a:marko,b:vadas]
    
    
    gremlin>  g.V().as("a").outE("created").as("b").
    ......1>   inV().as("c").
    ......2>   in("created").as("d").
    ......3>     where("a", lt("b").or(gt("c")).and(neq("d"))).
    ......4>       by("age").
    ......5>       by("weight").
    ......6>       by(__.in("created").values("age").min()).
    ......7>   select("a", "c", "d").by("name")
    ==>[a:josh,c:lop,d:marko]
    ==>[a:josh,c:lop,d:peter]
    ==>[a:peter,c:lop,d:marko]
    ==>[a:peter,c:lop,d:josh]
    ```
    
    In the second query:
        a -> "age"
        b -> "weight"
        c -> in("created")...
        d -> "age" // TraversalRings are round-robin structures
    
    Pretty insane-o.
    
    If people start using `where()-by()` heavily, I believe there is an easy 
translation to `match()` and as such a `TraversalStrategy` would enable us to 
get the benefits of `match()`-steps runtime query optimizer.
    
    VOTE +1

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

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

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

    https://github.com/apache/tinkerpop/pull/417.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 #417
    
----
commit 5f264db45f2f58f79ab833e900f52d66501e741a
Author: Marko A. Rodriguez <[email protected]>
Date:   2016-09-14T21:30:34Z

    added where().by() semantics to Gremlin and fixed a severe bug in 
Gremlin-Python's P object. Optimized TraversalRing for non-existent modulators.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to