Can access it via the Job API?

http://hadoop.apache.org/mapreduce/docs/current/api/org/apache/hadoop/mapreduce/Job.html#getCounters%28%29

> Hi,
> I have a similar query.
> 
> Infact, I sent it yesterday and waiting for anybody's response who might
> have done it.
> 
> 
> Thanks,
> Anurag Tangri
> 
> 2011/11/30 rabbit_cheng <rabbit_ch...@126.com>
> 
> >  I have created a counter in mapper to count something, I wanna get the
> > 
> > counter's value in reducer phase, the code segment is as follow:
> > 
> > public class MM extends Mapper<LongWritable, Text, Text, Text> {
> > 
> >     static enum TEST{ pt }
> >     @Override
> >     public void map(LongWritable key, Text values, Context context)
> >     throws
> > 
> > IOException, InterruptedException {
> > 
> >         context.getCounter(TEST.pt).increment(1);
> >     
> >     }
> > 
> > }
> > public class KMeansReducer extends Reducer<Text, Text, Text, Text> {
> > 
> >     @Override
> >     protected void setup(Context context) throws IOException,
> > 
> > InterruptedException {
> > 
> >         long ptValue=context.getCounter(MM.TEST.pt <http://mm.test.pt/>
> > 
> > ).getValue();
> > 
> >     }
> > 
> > }
> > but what I get is always 0, i.e., the value of variable ptValue is always
> > 0.
> > Does anybody know how to access a mapper counter in reducer?

Reply via email to