public class MyReducer
        extends Reducer<Text, Text, Text, Text> {

  private enum MyCounters {
    INPUT_UNIQUE_USERS
  }

  @Override
  protected void setup(Context context) throws java.io.IOException,
          InterruptedException {
    Configuration conf = context.getConfiguration();
    doSetup(conf);
  }

  @Override
  public void reduce(Text key, Iterable<Text> values, Context context)
          throws IOException, InterruptedException {
    context.getCounter(MyCounters.INPUT_UNIQUE_USERS).increment(1);
    doReduce();
  }

  @Override
  protected void cleanup(Context context) throws java.io.IOException,
          InterruptedException {
      doClean();
  }
}

On Fri, Jun 24, 2011 at 2:15 PM, Mapred Learn <mapred.le...@gmail.com> wrote:
> Hi,
> Could anyone point me to an example of custom counters with new map reduce
> API ?
>
> Thanks,
> -JJ

Reply via email to