You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@edgent.apache.org by queeniema <gi...@git.apache.org> on 2016/03/17 19:54:25 UTC

[GitHub] incubator-quarks pull request: [QUARKS-16] Update split to use lam...

GitHub user queeniema opened a pull request:

    https://github.com/apache/incubator-quarks/pull/25

    [QUARKS-16] Update split to use lambda function

    Change made to avoid using `serialVersionUID`.

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

    $ git pull https://github.com/queeniema/incubator-quarks sample-CombiningStreamsProcessingResults-quarks-16

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

    https://github.com/apache/incubator-quarks/pull/25.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 #25
    
----
commit e56833c91818911742174baca3a86ec97cefdfc2
Author: qfma <qu...@us.ibm.com>
Date:   2016-03-17T18:51:07Z

    Update split to use lambda function

----


---
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-quarks pull request: [QUARKS-16] Update split to use lam...

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

    https://github.com/apache/incubator-quarks/pull/25#discussion_r56561498
  
    --- Diff: samples/topology/src/main/java/quarks/samples/topology/CombiningStreamsProcessingResults.java ---
    @@ -62,32 +61,28 @@ public static void main(String[] args) throws Exception {
                     .filter(tuple -> tuple.get("Systolic") < 200 && tuple.get("Diastolic") < 130);
     
             // Split the stream by blood pressure category
    -        List<TStream<Map<String, Integer>>> categories = readings.split(6, new ToIntFunction<Map<String, Integer>>() {
    -            private static final long serialVersionUID = 1L;
    -            @Override
    -            public int applyAsInt(Map<String, Integer> tuple) {
    -                if (tuple.get("Systolic") < 120 && tuple.get("Diastolic") < 80) {
    -                    // Normal
    -                    return 0;
    -                } else if ((tuple.get("Systolic") >= 120 && tuple.get("Systolic") <= 139) ||
    -                           (tuple.get("Diastolic") >= 80 && tuple.get("Diastolic") <= 89)) {
    -                    // Prehypertension
    -                    return 1;
    -                } else if ((tuple.get("Systolic") >= 140 && tuple.get("Systolic") <= 159) ||
    -                           (tuple.get("Diastolic") >= 90 && tuple.get("Diastolic") <= 99)) {
    -                    // High Blood Pressure (Hypertension) Stage 1
    -                    return 2;
    -                } else if ((tuple.get("Systolic") >= 160 && tuple.get("Systolic") <= 179) ||
    -                           (tuple.get("Diastolic") >= 100 && tuple.get("Diastolic") <= 109)) {
    -                    // High Blood Pressure (Hypertension) Stage 2
    -                    return 3;
    -                } else if (tuple.get("Systolic") >= 180 && tuple.get("Diastolic") >= 110)  {
    -                    // Hypertensive Crisis
    -                    return 4;
    -                } else {
    -                    // Invalid
    -                    return -1;
    -                }
    +        List<TStream<Map<String, Integer>>> categories = readings.split(6, tuple -> {
    +            if (tuple.get("Systolic") < 120 && tuple.get("Diastolic") < 80) {
    --- End diff --
    
    Unrelated to this change but it jumps out at me that the code might be clearer and more compact if you fetched the two values into local variables first and then used those variables rather than getting each value multiple times.


---
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-quarks pull request: [QUARKS-16] Update split to use lam...

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

    https://github.com/apache/incubator-quarks/pull/25


---
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.
---