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