hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mapred Learn <mapred.le...@gmail.com>
Subject Re: how to access a mapper counter in reducer
Date Thu, 01 Dec 2011 19:05:04 GMT
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_cheng@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?
>
>
>
>

Mime
View raw message