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/28 12:50] majlis Commands for execution were added. |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== MapReduce Tutorial : ====== | + | ====== MapReduce Tutorial : Basic reducer |
+ | |||
+ | The interesting part of a Hadoop job is the //reducer// -- after all mappers produce the (key, value) pairs, for every unique key and all its values a '' | ||
+ | |||
+ | The '' | ||
+ | |||
+ | <file perl> | ||
+ | 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-> | ||
+ | </ | ||
+ | |||
+ | As before, Hadoop silently handles failures. It can happen that even a successfully finished mapper needs to be executed again -- if the machine, where its output data were stored, gets disconnected from the network. | ||
+ | |||
+ | ===== Exercise 1 ===== | ||
+ | |||
+ | Run a Hadoop job on ''/ | ||
+ | wget --no-check-certificate ' | ||
+ | rm -rf step-5-out-ex1; | ||
+ | less step-5-out-ex1/ | ||
+ | |||
+ | ==== Solution ==== | ||
+ | You can also download the solution {{: | ||
+ | wget --no-check-certificate ' | ||
+ | rm -rf step-5-out-sol1; | ||
+ | less step-5-out-sol1/ | ||
+ | |||
+ | |||
+ | ===== Exercise 2 ===== | ||
+ | |||
+ | Run a Hadoop job on ''/ | ||
+ | wget --no-check-certificate ' | ||
+ | rm -rf step-5-out-ex2; | ||
+ | less step-5-out-ex2/ | ||
+ | |||
+ | ==== Solution ==== | ||
+ | You can also download the solution {{: | ||
+ | wget --no-check-certificate ' | ||
+ | rm -rf step-5-out-sol2; | ||
+ | less step-5-out-sol2/ | ||
+ | |||
+ |