You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by dkuppitz <gi...@git.apache.org> on 2016/05/25 23:24:52 UTC

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

GitHub user dkuppitz opened a pull request:

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

    TINKERPOP-1312 .count().is(0) is not properly optimized

    Tweaked `RangeByIsCountStrategy`. The patterns ...
    
    * `....count().is(0)`
    * `....count().is(lt(1))`
    * `....count().is(lte(0))`
    
    ... are now replaced by `not(...)`.
    
    `docker/build.sh -t -i -n` succeeded.
    
    VOTE: +1

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

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

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

    https://github.com/apache/incubator-tinkerpop/pull/320.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 #320
    
----
commit 5f3305315052258d3e659b1d984e87e73ad2b0af
Author: Daniel Kuppitz <da...@hotmail.com>
Date:   2016-05-25T19:13:48Z

    Tweaked `RangeByIsCountStrategy`. The pattern `outE().count().is(0)` is now replaced by `not(outE())`

commit 5f5a0f37221c0ca7ec777418b96429b4a20d9934
Author: Daniel Kuppitz <da...@hotmail.com>
Date:   2016-05-25T19:24:58Z

    Updated CHANGELOG

commit 5751456fcc91ea4ab9b7628e91209b96ea5d958e
Author: Daniel Kuppitz <da...@hotmail.com>
Date:   2016-05-25T19:33:44Z

    Increase step offset by 2 if `foo.count().is(0)` was replaced by `not(foo)`.

commit 3f9a256db449f0a8bbca3ca9fce8355a6dbb9a39
Author: Daniel Kuppitz <da...@hotmail.com>
Date:   2016-05-25T19:55:27Z

    Fixed the previous commit. We don't want to increase the step offset, but decrease the traversal size, after removing steps from a traversal.

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by okram <gi...@git.apache.org>.
Github user okram commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/320#issuecomment-221886983
  
    When all is in place, can you provide a benchmark on Grateful Dead graph of some query in master/ vs. this branch and their runtimes? So to be certain its all as expected. Even provide a `explain()` of the traversal you are benchmarking so we see how it compiled?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by dkuppitz <gi...@git.apache.org>.
Github user dkuppitz commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/320#issuecomment-221823513
  
    Updated. Regarding the order of `RangeByIsCountStrategy` and `AdjacentToIncidentStrategy`, it doesn't really matter. We either go:
    
    `out().count().is(0) -> outE().count().is(0) -> not(outE())`
    
    or:
    
    `out().count().is(0) -> not(out()) -> not(outE())`
    
    In fact it's the former, but either way we would always end up with the same step sequence.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by dkuppitz <gi...@git.apache.org>.
Github user dkuppitz commented on a diff in the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/320#discussion_r64829983
  
    --- Diff: gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java ---
    @@ -142,6 +142,7 @@ public void doTest(final Traversal traversal, final Traversal optimized) {
                         {__.out().count().is(without(2, 6, 4)), __.out().limit(6).count().is(without(2, 6, 4))},
                         {__.map(__.count().is(0)), __.map(__.limit(1).count().is(0))},
                         {__.flatMap(__.count().is(0)), __.flatMap(__.limit(1).count().is(0))},
    +                    {__.filter(__.count().is(0)), __.filter(__.not(__.identity()))},
    --- End diff --
    
    It is the same, but IMO it's not RangeByIsCountStrategy's job to optimize that.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by okram <gi...@git.apache.org>.
Github user okram commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/320#issuecomment-222008526
  
    Sweet benchmark. VOTE +1. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by okram <gi...@git.apache.org>.
Github user okram commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/320#issuecomment-221842344
  
    Sorry to be a pest, but could you add more complex tests still! :)
    
    ```
    outE().count().is(0).inV()
    both().both().count().is(0).as("a")
    ```
    
    For the latter, should it be `not(both().both())` ? What are the semantics in longer chains -- also, what about local children and global children. All your test cases are basically "the same" in terms of just `out().*`.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by dkuppitz <gi...@git.apache.org>.
Github user dkuppitz closed the pull request at:

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


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by spmallette <gi...@git.apache.org>.
Github user spmallette commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/320#issuecomment-222121544
  
    Nice tests and benchmark stuff  - VOTE +1


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by okram <gi...@git.apache.org>.
Github user okram commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/320#issuecomment-221764771
  
    Can you add some more complex tests? For instance:
    
    ```
    out().count().is(0).as("a")
    ```
    
    Also, `RangeByIsCountStrategy` doesn't have `applyPrior()` of `AdjacentToIncidentStrategy`. Does that matter? That is:
    
    ```
    out().count().is(0) ->
    outE().count().is(0) ->
    not(outE())
    ```
    
    We want `not(outE())` NOT `not(out())`. Can you verify that such compilations happen?
    
    Also, why do you make a distinction between computer and standard engines for this strategy?
    
    I think you should copy that pattern in the other strategy tests that ensure proper `__()` compilations. We can go crazy on adding patterns to make sure compilations are as expected. E.g.:
    
    ```
      @Parameterized.Parameters(name = "{0}")
        public static Iterable<Object[]> generateTestParameters() {
    
            return Arrays.asList(new Traversal[][]{
                    {__.outE().count(), __.outE().count()},
                    {__.bothE("knows").count(), __.bothE("knows").count()},
                    {__.properties().count(), __.properties().count()},
                    {__.properties("name").count(), __.properties("name").count()},
                    {__.out().count(), __.outE().count()},
                    {__.in().count(), __.inE().count()},
                    {__.both().count(), __.bothE().count()},
                    {__.out("knows").count(), __.outE("knows").count()},
                    {__.out("knows", "likes").count(), __.outE("knows", "likes").count()},
                    {__.filter(__.out()), __.filter(__.outE())},
                    {__.where(__.not(__.out())), __.where(__.not(__.outE()))},
                    {__.where(__.out("knows")), __.where(__.outE("knows"))},
                    {__.values().count(), __.properties().count()},
                    {__.values("name").count(), __.properties("name").count()},
                    {__.where(__.values()), __.where(__.properties())},
                    {__.and(__.out(), __.in()), __.and(__.outE(), __.inE())},
                    {__.or(__.out(), __.in()), __.or(__.outE(), __.inE())},
                    {__.out().as("a").count(), __.outE().count()},   // TODO: is this good?
                    {__.where(__.as("a").out("knows").as("b")), __.where(__.as("a").out("knows").as("b"))}});
        }
    ```
    



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by dkuppitz <gi...@git.apache.org>.
Github user dkuppitz commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/320#issuecomment-222225527
  
    Not sure why the merge was not recognized automatically, but it's merged into `tp31` and `master`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by okram <gi...@git.apache.org>.
Github user okram commented on a diff in the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/320#discussion_r64829335
  
    --- Diff: gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java ---
    @@ -142,6 +142,7 @@ public void doTest(final Traversal traversal, final Traversal optimized) {
                         {__.out().count().is(without(2, 6, 4)), __.out().limit(6).count().is(without(2, 6, 4))},
                         {__.map(__.count().is(0)), __.map(__.limit(1).count().is(0))},
                         {__.flatMap(__.count().is(0)), __.flatMap(__.limit(1).count().is(0))},
    +                    {__.filter(__.count().is(0)), __.filter(__.not(__.identity()))},
    --- End diff --
    
    `filter(not(_.identity))` the same as `not()` ?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by dkuppitz <gi...@git.apache.org>.
Github user dkuppitz commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/320#issuecomment-221869056
  
    > For the latter, should it be `not(both().both())`?
    
    Since we only look at it in conjunction with `count().is(something)`, we don't need to differentiate between single steps and longer chains.
    
    `both().not(both())` is the same thing as `not(both().both())`.
    
    It makes a difference if something comes after `is(0)`, but in that case we don't use `not()`:
    
    `both().both().count().is(0).both() -> both().both().limit(1).count().is(0).both()`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-tinkerpop pull request: TINKERPOP-1312 .count().is(0) is...

Posted by dkuppitz <gi...@git.apache.org>.
Github user dkuppitz commented on the pull request:

    https://github.com/apache/incubator-tinkerpop/pull/320#issuecomment-221813315
  
    > why do you make a distinction between computer and standard engines for this strategy's test case?
    
    I was wondering why we initially chose another pattern for this test class; I couldn't figure it out, but then still just followed the pattern that we started with. I'll change that.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---