[ 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:perl-api [2012/01/23 21:18]
straka
courses:mapreduce-tutorial:perl-api [2012/01/23 21:20]
straka
Line 47: Line 47:
   * ''sub setup($self, $context)'' -- executed once before any input (key, value) pairs are processed. The ''$context'' can be used to both produce (key, value) pairs and increment counters.   * ''sub setup($self, $context)'' -- executed once before any input (key, value) pairs are processed. The ''$context'' can be used to both produce (key, value) pairs and increment counters.
   * ''sub cleanup($self, $context)'' -- executed once after all input (key, value) pairs are processed. The ''$context'' can be used to both produce (key, value) pairs and increment counters.   * ''sub cleanup($self, $context)'' -- executed once after all input (key, value) pairs are processed. The ''$context'' can be used to both produce (key, value) pairs and increment counters.
 +
 +===== Hadoop::Reducer =====
 +
 +<code perl>
 +package Hadoop::Reduce;
 +use Moose::Role;
 +
 +requires 'reduce';
 +
 +sub setup() { 1; }
 +sub cleanup { 1;}
 +</code>
 +  * ''sub reduce($self, $key, $values, $context)'' -- executed for every (key, values) input data.
 +    * fsa
 +    The variable '$content' has following methods:
 +    * ''$content%%->%%write($key, $value)'' -- output the (''$key'', ''$value'') pair
 +    * ''$content%%->%%counter($group, $name, $increment)'' -- increases the counter ''$name'' in the group ''$group'' by ''$increment''
 +  * ''sub setup($self, $context)'' -- executed once before any input (key, values) pairs are processed. The ''$context'' can be used to both produce (key, value) pairs and increment counters.
 +  * ''sub cleanup($self, $context)'' -- executed once after all input (key, values) pairs are processed. The ''$context'' can be used to both produce (key, value) pairs and increment counters.

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