[ 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

Next revision Both sides next revision
courses:mapreduce-tutorial:perl-api [2012/01/23 21:07]
straka vytvořeno
courses:mapreduce-tutorial:perl-api [2012/01/23 21:16]
straka
Line 1: Line 1:
 ====== MapReduce Tutorial - Perl API ====== ====== MapReduce Tutorial - Perl API ======
  
-The main class is ''Hadoop::Runner'': +===== Hadoop::Runner ===== 
-<code>+ 
 +<code perl>
 package Hadoop::Runner; package Hadoop::Runner;
 +use Moose;
  
 has 'mapper' => (does => 'Hadoop::Mapper', required => 1); has 'mapper' => (does => 'Hadoop::Mapper', required => 1);
Line 28: Line 30:
   * ''hadoop_prefix'' -- the prefix of Hadoop instalation. Default value is fine in UFAL cluster.   * ''hadoop_prefix'' -- the prefix of Hadoop instalation. Default value is fine in UFAL cluster.
   * ''keep_env'' -- which environment variables are preserved when running perl mappers, reducers, combiners and partitioners   * ''keep_env'' -- which environment variables are preserved when running perl mappers, reducers, combiners and partitioners
 +
 +===== Hadoop::Mapper =====
 +
 +<code perl>
 +package Hadoop::Mapper;
 +use Moose::Role;
 +
 +requires 'map';
 +
 +sub setup() { 1; }
 +sub cleanup { 1;}
 +</code>
 +  * ''sub map($self, $key, $value, $context)'' -- executed for every (key, value) input pair. 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''
  

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