Github user StephanEwen commented on the pull request:

    https://github.com/apache/flink/pull/896#issuecomment-120065197
  
    This pattern seems to repeat in many places:
    ```java
    AccumulatorRegistry accumulatorRegistry = 
getEnvironment().getAccumulatorRegistry();
    AccumulatorRegistry.Internal internalRegistry = 
accumulatorRegistry.getInternal();
    this.recordsOutCounter = 
internalRegistry.createLongCounter(AccumulatorRegistry.Internal.NUM_RECORDS_OUT);
    this.bytesOutCounter = 
internalRegistry.createLongCounter(AccumulatorRegistry.Internal.NUM_BYTES_OUT);
    
    AccumulatorRegistry.External externalRegistry = 
accumulatorRegistry.getExternal();
    this.accumulatorMap = new HashMap<String, Accumulator<?, ?>>();
    externalRegistry.setMap(this.accumulatorMap);
    ```
    
    I think the code would be simpler is the registry simply always had a 
created map for internal and external accumulators. Also, a "reporter" object 
would help. The code would then look like:
    ```java
    AccumulatorRegistry accumulatos = getEnvironment().getAccumulatorRegistry();
    ReadWriteReporter reporter = accumulatos.getReadWriteReporter();
    writer.setStatsReporter(reporter);
    this.accumulatorMap = accumulatos.getUserMap();
    ```


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