[ 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:29]
straka
courses:mapreduce-tutorial:perl-api [2012/01/23 21:33]
straka
Line 68: Line 68:
   * ''sub setup($self, $context)'' -- executed once before any input keys 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 keys 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 keys 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 keys are processed. The ''$context'' can be used to both produce (key, value) pairs and increment counters.
 +
 +===== Hadoop::Partitioner =====
 +
 +<code perl>
 +package Hadoop::Partitioner;
 +use Moose::Role;
 +
 +requires 'getPartition';
 +
 +sub setup { 1; }
 +sub cleanup { 1; }
 +
 +</code>
 +  * ''sub getPartition($self, $key, $value, $partitions)'' -- executed for every (key, value) input pair. It must return a number in the range 0..$partitions-1, 
 +  * ''sub setup($self)'' -- executed once before any input (key, value) pairs are processed.
 +  * ''sub cleanup($self)'' -- executed once after all input (key, value) pairs are processed. 

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