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

ASF GitHub Bot commented on QUARKS-16:
--------------------------------------

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.


> Recipe creation for split and union
> -----------------------------------
>
>                 Key: QUARKS-16
>                 URL: https://issues.apache.org/jira/browse/QUARKS-16
>             Project: Quarks
>          Issue Type: Improvement
>          Components: Documentation
>            Reporter: Queenie Ma
>            Assignee: Queenie Ma
>            Priority: Minor
>              Labels: documentation, enhancement, recipes
>         Attachments: CombiningStreamsProcessingResults.java, 
> CombiningStreamsProcessingResults.java, HeartMonitorSensor.java, 
> HeartMonitorSensor.java, split_union.md, split_union.md, 
> split_union_topology_graph.jpg, split_union_topology_graph.png, 
> split_union_topology_graph.png
>
>
> I wrote up a recipe on how to split and union streams. I'd like to get some 
> feedback on the sample code and the recipe walkthrough.



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

Reply via email to