how to access Mapper Counter value in a Reducer?

后端 未结 3 1842
臣服心动
臣服心动 2021-02-15 12:16

I want to acces the myCounter.my value in reducer :

public static class Map extends Mapper

        
相关标签:
3条回答
  • 2021-02-15 12:41

    You to make it work for new API by accessing the counters via job object.

    Configuration conf = context.getConfiguration();
    Cluster cluster = new Cluster(conf);
    Job currentJob = cluster.getJob(context.getJobID());
    long val=currentJob.getCounters().findCounter(myCounter.my).getValue();
    
    0 讨论(0)
  • 2021-02-15 12:44

    You can access as follows:

    Map.myCounter.my // static fields you can access by it's class name.
    
    0 讨论(0)
  • 2021-02-15 12:46

    You can access your counter value in reducer using the same code

    Counter counter = context.getCounter( myCounter.my );
            counter.getValue();
    

    also see

    0 讨论(0)
提交回复
热议问题