Streaming/Reducer/Input/Iterator.pm

filter: Statementstmt 84.8% 28 / 33 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 80.0% 44 / 55 CC 7 SCAR 14.0
CC
7
Cov
76%
next
8.1
__ANON__
2.1
has_next
2.0
CRAP 4.1
↑ Summary Streaming/Reducer/Input/ValuesIterator.pm »
1 package Hadoop::Streaming::Reducer::Input::Iterator;
2 6 $Hadoop::Streaming::Reducer::Input::Iterator::VERSION = '0.143060';
3 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use Safe::Isa;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 with 'Hadoop::Streaming::Role::Iterator';
6  
7 6 ▶use Hadoop::Streaming::Reducer::Input::ValuesIterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #ABSTRACT: Collects values for each key together with an iterator interface
10  
11 has input => (
12 is => 'ro',
13 5 ▶ isa => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
14 5 ▶ die 'not a Hadoop::Streaming::Reducer::Input object'
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->$Hadoop::Streaming::Reducer::Input::Iterator::_isa("Hadoop::Streaming::Reducer::Input") 0 5 5
15 unless $_[0]->$_isa('Hadoop::Streaming::Reducer::Input');
16 },
17 6 required => 1,
18 );
19  
20 6 has current_key => (
21 is => 'rw',
22 does => 'Str'
23 );
24  
25  
26 82 ▶sub has_next {
Subroutine has_next: called CC=2 SCAR=6.9
Pod documented
27 82 my $self = shift;
28 82 ▶ return if not defined $self->input->next_key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->input->next_key 5 77 82
29 77 1;
30 }
31  
32  
33 77 ▶sub next {
Subroutine next: called CC=5 SCAR=20.9
Pod documented
34 77 my $self = shift;
35  
36 77 ▶ if ( not defined $self->current_key ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->current_key) 5 72 77
37 5 $self->current_key($self->input->next_key);
38 5 return $self->retval( $self->current_key );
39 }
40  
41 72 ▶ if ($self->current_key ne $self->input->next_key) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->current_key ne $self->input->next_key) 72 0 72
42 72 $self->current_key($self->input->next_key);
43 72 return $self->retval( $self->current_key );
44 }
45  
46 0 my ($key, $value);
47 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$self->current_key eq $key and do { do { () = $self->input->each or return } } 0 0 0
48 0 ▶ ($key, $value) = $self->input->each or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $self->input->each or return 0 0 0
49 } while ($self->current_key eq $key);
50 0 $self->current_key( $key );
51  
52 0 return $self->retval($key, $value);
53 }
54  
55  
56 77 ▶sub retval {
Subroutine retval: called CC=1 SCAR=0.0
Pod documented
57 77 my ($self, $key, $value) = @_;
58 return (
59 77 $key,
60 Hadoop::Streaming::Reducer::Input::ValuesIterator->new(
61 input_iter => $self,
62 first => $value,
63 ),
64 );
65 }
66  
67 6 __PACKAGE__->meta->make_immutable;
68  
69 6 1;
70  
71 __END__
↑ Summary Streaming/Reducer/Input/ValuesIterator.pm »