Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
courses:mapreduce-tutorial:step-10 [2012/01/25 19:01] straka |
courses:mapreduce-tutorial:step-10 [2012/01/25 19:03] straka |
||
---|---|---|---|
Line 11: | Line 11: | ||
<code perl> | <code perl> | ||
package Mapper; | package Mapper; | ||
- | use Moose; | + | ... |
- | with ' | + | |
- | + | ||
- | sub map { | + | |
- | my ($self, $key, $value, $context) = @_; | + | |
- | + | ||
- | foreach my $word (split /\W/, $value) { | + | |
- | next if not length $word; | + | |
- | $context-> | + | |
- | } | + | |
- | } | + | |
package Reducer; | package Reducer; | ||
- | use Moose; | + | ... |
- | with ' | + | |
- | + | ||
- | sub reduce { | + | |
- | my ($self, $key, $values, $context) = @_; | + | |
- | + | ||
- | my $sum = 0; | + | |
- | while ($values-> | + | |
- | $sum += $values-> | + | |
- | } | + | |
- | + | ||
- | $context-> | + | |
- | } | + | |
package Main; | package Main; | ||
Line 43: | Line 21: | ||
my $runner = Hadoop:: | my $runner = Hadoop:: | ||
mapper => Mapper-> | mapper => Mapper-> | ||
- | combiner => Reducer-> | + | combiner => Reducer-> |
reducer => Reducer-> | reducer => Reducer-> | ||
input_format => ' | input_format => ' | ||
- | + | ... | |
- | $runner-> | + | |
</ | </ | ||