File Coverage

blib/lib/Hadoop/Streaming/Reducer.pm
Criterion Covered Total %
statement 9 19 47.3
branch 0 4 0.0
condition n/a
subroutine 3 4 75.0
pod 1 1 100.0
total 13 28 46.4


line stmt bran cond sub pod time code
1             package Hadoop::Streaming::Reducer;
2             $Hadoop::Streaming::Reducer::VERSION = '0.143060';
3 1     1   2638 use Moo::Role;
  1         2  
  1         5  
4              
5 1     1   260 use IO::Handle;
  1         2  
  1         34  
6 1     1   343 use Hadoop::Streaming::Reducer::Input;
  1         3  
  1         139  
7              
8             with 'Hadoop::Streaming::Role::Emitter';
9             requires qw/reduce/;
10              
11             # ABSTRACT: Simplify writing Hadoop Streaming jobs. Write a reduce() function and let this role handle the Stream interface. This Reducer roll provides an iterator over the multiple values for a given key.
12              
13              
14              
15             sub run {
16 0     0 1   my $class = shift;
17 0           my $self = $class->new;
18              
19 0           my $input = Hadoop::Streaming::Reducer::Input->new(handle => \*STDIN);
20 0           my $iter = $input->iterator;
21              
22 0           while ($iter->has_next) {
23 0 0         my ($key, $values_iter) = $iter->next or last;
24 0           eval {
25 0           $self->reduce( $key => $values_iter );
26             };
27 0 0         if ($@) {
28 0           warn $@;
29             }
30             }
31             }
32              
33             1;
34              
35             __END__