You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/09/14 21:40:20 UTC

[jira] [Commented] (TINKERPOP-1330) by()-modulation for where()

    [ https://issues.apache.org/jira/browse/TINKERPOP-1330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15491520#comment-15491520 ] 

ASF GitHub Bot commented on TINKERPOP-1330:
-------------------------------------------

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 <ok...@gmail.com>
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.

----


> by()-modulation for where()
> ---------------------------
>
>                 Key: TINKERPOP-1330
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1330
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.2.1
>            Reporter: Daniel Kuppitz
>
> As discussed in https://issues.apache.org/jira/browse/TINKERPOP-1329, it would be nice to have {{by()}}-modulators for {{where()}}. For example:
> {code}
> g.V().as("a").out().where(gt("a")).by("age") // both a and current ages are selected
> g.V().as("a").out().as("b").where("b",gt("a")).by("age") // both a and b ages are selected
> g.V().as("a").out().as("b").where("b",gt("a")).by("age").by("weight") // where b.age > a.weight
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)