Streaming/Combiner.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 91.1% 31 / 34 CC 4 SCAR 10.2
CC
4
Cov
90%
run
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.8
« Streaming/Reducer/Input/ValuesIterator.pm ↑ Summary Streaming/Reducer.pm »
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
BranchTrueFalseTotal
if ($iter->has_next) 17 1 18
23 17 ▶ my ($key, $values_iter) = $iter->next or last;
Branch: 1 branch
BranchTrueFalseTotal
() = $iter->next or last 17 0 17
24 17 eval {
25 17 $self->combine( $key => $values_iter );
26 };
27 17 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 17 17
28 0 warn $@;
29 }
30 }
31 }
32  
33 1 1;
34  
35 __END__
« Streaming/Reducer/Input/ValuesIterator.pm ↑ Summary Streaming/Reducer.pm »