Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
courses:mapreduce-tutorial:step-24 [2012/01/31 09:52] straka Change Java commandline syntax. |
courses:mapreduce-tutorial:step-24 [2012/01/31 11:27] straka |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== MapReduce Tutorial : Mappers, running Java Hadoop jobs ====== | + | ====== MapReduce Tutorial : Mappers, running Java Hadoop jobs, counters |
We start by going through a simple Hadoop job with Mapper only. | We start by going through a simple Hadoop job with Mapper only. | ||
Line 103: | Line 103: | ||
* When not specifying '' | * When not specifying '' | ||
+ | ===== Counters ===== | ||
+ | |||
+ | As in the Perl API, a mapper or a reducer can increment various counters by using '' | ||
+ | <code java> | ||
+ | public void map(Text key, Text value, Context context) throws IOException, | ||
+ | ... | ||
+ | context.getCounter(" | ||
+ | ... | ||
+ | } | ||
+ | </ | ||
+ | The '' | ||
+ | <code java> | ||
+ | public void reduce(Text key, Iterable< | ||
+ | ... | ||
+ | Counter values = context.getCounter(" | ||
+ | for (IntWritable value : values) { | ||
+ | ... | ||
+ | values.increment(1); | ||
+ | } | ||
+ | } | ||
+ | </ | ||