Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
courses:mapreduce-tutorial:step-4 [2012/01/24 21:28] straka |
courses:mapreduce-tutorial:step-4 [2012/01/28 11:49] majlis Odstranen odkaz |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== MapReduce Tutorial : Counters ====== | ====== MapReduce Tutorial : Counters ====== | ||
- | Sometimes it is useful to count events differently than outputting them (key, value) pairs. For that reason Hadoop offers simple counter framework. | + | Sometimes it is useful to count events differently than outputting them as (key, value) pairs. For that reason Hadoop offers simple counter framework. |
+ | |||
+ | Hadoop maintains a collection of pre-defined and user-defined counters. Every counter is identified by its group name and counter name. To increment a counter, the following code can be used: | ||
<code perl> | <code perl> | ||
- | ... | + | sub map { |
- | sub map() { | + | my ($self, $key, $value, $context) = @_; |
+ | $context-> | ||
} | } | ||
- | ... | ||
</ | </ | ||
- | ===== Exercise ===== | + | At the end of computation, |
- | Run a MR job on / | + | ===== Exercise ===== |
- | {{.:step-4-solution.txt|Solution.pl}} | + | Run a Hadoop job on ''/ |