| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 48 | 0 | ▶ | ($key, $value) = $self->input->each or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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__ | ||||||||||