hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shrijeet Paliwal <shrij...@rocketfuel.com>
Subject Re: sample usage of custom counters with new map Reduce API
Date Fri, 24 Jun 2011 21:27:51 GMT
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.learn@gmail.com> wrote:
> Hi,
> Could anyone point me to an example of custom counters with new map reduce
> API ?
>
> Thanks,
> -JJ

Mime
View raw message