Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/210#discussion_r23081083
  
    --- Diff: flink-java/src/main/java/org/apache/flink/api/java/Utils.java ---
    @@ -32,4 +38,44 @@ public static String getCallLocationName(int depth) {
                }
                return st[depth].toString();
        }
    +
    +   protected static class CountHelper<T> extends RichFlatMapFunction<T, 
Long> {
    +
    +           private static final long serialVersionUID = 1L;
    +
    +           private final String id;
    +
    +           public CountHelper(String id) {
    +                   this.id = id;
    +           }
    +
    +           @Override
    +           public void flatMap(T value, Collector<Long> out) throws 
Exception {
    +                   getRuntimeContext().getLongCounter(id).add(1L);
    --- End diff --
    
    I think it is more efficient to have a `long`inside this function that is 
incremented for each record, and then aggregate this `long` to the accumulator 
in the `close()` method.


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

Reply via email to