| 1 | package Hadoop::Streaming::Combiner; | ||||||||||
| 2 | 1 | $Hadoop::Streaming::Combiner::VERSION = '0.143060'; | |||||||||
| 3 | 1 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use IO::Handle; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Hadoop::Streaming::Reducer::Input; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | with 'Hadoop::Streaming::Role::Emitter'; | |||||||||
| 9 | 1 | requires qw/combine/; | |||||||||
| 10 | |||||||||||
| 11 | # ABSTRACT: Simplify writing Hadoop Streaming jobs. Combiner follows the same interface as Reducer. Requires a combine() function which will be called for each line of combiner data. Combiners are run on the same machine as the mapper as a pre-reduce reduction step. | ||||||||||
| 12 | |||||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | sub run { | ||||||||
|
Subroutine
run: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||
| 16 | 1 | my $class = shift; | |||||||||
| 17 | 1 | my $self = $class->new; | |||||||||
| 18 | |||||||||||
| 19 | 1 | my $input = Hadoop::Streaming::Reducer::Input->new(handle => \*STDIN); | |||||||||
| 20 | 1 | my $iter = $input->iterator; | |||||||||
| 21 | |||||||||||
| 22 | 1 | ▶ | while ($iter->has_next) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 17 | ▶ | my ($key, $values_iter) = $iter->next or last; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 17 | eval { | |||||||||
| 25 | 17 | $self->combine( $key => $values_iter ); | |||||||||
| 26 | }; | ||||||||||
| 27 | 17 | ▶ | if ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | warn $@; | |||||||||
| 29 | } | ||||||||||
| 30 | } | ||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 1 | 1; | |||||||||
| 34 | |||||||||||
| 35 | __END__ | ||||||||||