Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
courses:mapreduce-tutorial:step-5 [2012/01/24 19:04] straka vytvořeno |
courses:mapreduce-tutorial:step-5 [2012/01/24 22:30] straka |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== MapReduce Tutorial : ====== | + | ====== MapReduce Tutorial : Basic reducer |
+ | |||
+ | The interesting part of a MR job is the reducer -- after all mappers produce the (key, value) pairs, for every unique key and all its values a '' | ||
+ | |||
+ | The '' | ||
+ | |||
+ | <file perl reducer.pl> | ||
+ | package Mapper; | ||
+ | use Moose; | ||
+ | with ' | ||
+ | |||
+ | sub map { | ||
+ | my ($self, $key, $value, $context) = @_; | ||
+ | |||
+ | $context-> | ||
+ | } | ||
+ | |||
+ | package Reducer; | ||
+ | use Moose; | ||
+ | with ' | ||
+ | |||
+ | sub reduce { | ||
+ | my ($self, $key, $values, $context) = @_; | ||
+ | |||
+ | while ($values-> | ||
+ | $context-> | ||
+ | } | ||
+ | } | ||
+ | |||
+ | package Main; | ||
+ | use Hadoop:: | ||
+ | |||
+ | my $runner = Hadoop:: | ||
+ | mapper => Mapper-> | ||
+ | reducer => Reducer-> | ||
+ | |||
+ | $runner-> | ||
+ | </ | ||
+ | |||
+ | ===== Exercise 1 ===== | ||
+ | |||
+ | Run a MR job on / | ||
+ | |||
+ | ===== Exercise 2 ===== | ||
+ | |||
+ | Run a MR job on / |