FAQ
Hi,
Could anyone point me to an example of custom counters with new map reduce
API ?

Thanks,
-JJ

Search Discussions

  • Shrijeet Paliwal at Jun 24, 2011 at 9:28 pm
    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 wrote:
    Hi,
    Could anyone point me to an example of custom counters with new map reduce
    API ?

    Thanks,
    -JJ
  • Mapred Learn at Jun 24, 2011 at 9:31 pm
    Thanks Shrijeet !
    I will try it out

    On Fri, Jun 24, 2011 at 2:27 PM, Shrijeet Paliwal
    wrote:
    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 wrote:
    Hi,
    Could anyone point me to an example of custom counters with new map reduce
    API ?

    Thanks,
    -JJ
  • Mapred Learn at Jul 29, 2011 at 8:09 pm
    Hi Shrijeet,
    Is there a way to do it in main class instead of mappers and reducers ?


    On Fri, Jun 24, 2011 at 2:27 PM, Shrijeet Paliwal
    wrote:
    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 wrote:
    Hi,
    Could anyone point me to an example of custom counters with new map reduce
    API ?

    Thanks,
    -JJ

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmapreduce-user @
categorieshadoop
postedJun 24, '11 at 9:16p
activeJul 29, '11 at 8:09p
posts4
users2
websitehadoop.apache.org...
irc#hadoop

2 users in discussion

Mapred Learn: 3 posts Shrijeet Paliwal: 1 post

People

Translate

site design / logo © 2022 Grokbase