[ Skip to the content ]

Institute of Formal and Applied Linguistics Wiki


[ Back to the navigation ]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
courses:mapreduce-tutorial:step-4 [2012/01/24 21:33]
straka
courses:mapreduce-tutorial:step-4 [2012/01/25 21:52]
straka
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: 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:
Line 8: Line 8:
 sub map { sub map {
   my ($self, $key, $value, $context) = @_;   my ($self, $key, $value, $context) = @_;
- +
   $context->counter($group, $counter, $increment);   $context->counter($group, $counter, $increment);
 } }
 </code> </code>
  
-At the end of computation, Hadoop prints an aggregated value of all counters.+At the end of computation, Hadoop prints an aggregated value of all the counters.
  
 ===== Exercise ===== ===== Exercise =====
  
-Run a MR job on /home/straka/wiki/cs-text, which uses counters to count the number of articles according to their first letter (ignoring the case and possible diacritics).+Run a Hadoop job on ''/home/straka/wiki/cs-text'', which uses counters to count the number of articles according to their first letter (ignoring the case and possible diacritics).
  
 {{.:step-4-solution.txt|Solution.pl}} {{.:step-4-solution.txt|Solution.pl}}
  

[ Back to the navigation ] [ Back to the content ]