Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
courses:mapreduce-tutorial:step-4 [2012/01/24 21:01] straka |
courses:mapreduce-tutorial:step-4 [2012/01/31 09:40] (current) straka Change Perl commandline syntax. |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== MapReduce Tutorial : Counters ====== | ====== MapReduce Tutorial : Counters ====== | ||
- | Sometimes it is useful to | + | Sometimes it is useful to count events differently than outputting them as (key, value) pairs. For that reason Hadoop offers simple counter framework. |
- | {{filename> | + | Hadoop maintains a collection of pre-defined and user-defined counters. Every counter is identified by its group name and counter name. The group name and counter name is an arbitrary string -- for example group " |
- | {{filelist>:snippets:dokuwiki:plugin-*.tar.gz& | + | <code perl> |
+ | sub map { | ||
+ | my ($self, $key, $value, $context) = @_; | ||
+ | |||
+ | $context->counter($group, | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | At the end of computation, | ||
+ | |||
+ | ===== Exercise ===== | ||
+ | |||
+ | Run a Hadoop job on ''/ | ||
+ | wget --no-check-certificate ' | ||
+ | # NOW EDIT THE FILE | ||
+ | # $EDITOR step-4-exercise.pl | ||
+ | rm -rf step-4-out-ex; | ||
+ | less step-4-out-ex/ | ||
+ | |||
+ | ==== Solution ==== | ||
+ | You can also download the solution {{: | ||
+ | wget --no-check-certificate ' | ||
+ | # NOW VIEW THE FILE | ||
+ | # $EDITOR step-3-solution.pl | ||
+ | rm -rf step-4-out-sol; | ||
+ | less step-4-out-sol/ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | < | ||
+ | <table style=" | ||
+ | < | ||
+ | <td style=" | ||
+ | <td style=" | ||
+ | <td style=" | ||
+ | </ | ||
+ | </ | ||
+ | </ |