File Coverage

blib/lib/Hadoop/Streaming/Reducer/Input/ValuesIterator.pm
Criterion Covered Total %
statement 3 13 23.0
branch 0 8 0.0
condition n/a
subroutine 1 3 33.3
pod 2 2 100.0
total 6 26 23.0


line stmt bran cond sub pod time code
1             package Hadoop::Streaming::Reducer::Input::ValuesIterator;
2             {
3             $Hadoop::Streaming::Reducer::Input::ValuesIterator::VERSION = '0.122420';
4             }
5 1     1   6 use Any::Moose;
  1         2  
  1         7  
6             with 'Hadoop::Streaming::Role::Iterator';
7              
8             #ABSTRACT: Role providing access to values for a given key.
9              
10             has input_iter => (
11             is => 'ro',
12             does => 'Hadoop::Streaming::Role::Iterator',
13             required => 1,
14             );
15              
16             has first => ( is => 'rw', );
17              
18              
19             sub has_next
20             {
21 0     0 1   my $self = shift;
22 0 0         return 1 if $self->first;
23 0 0         return unless defined $self->input_iter->input->next_key;
24 0 0         return $self->input_iter->current_key eq
25             $self->input_iter->input->next_key ? 1 : 0;
26             }
27              
28              
29             sub next
30             {
31 0     0 1   my $self = shift;
32 0 0         if ( my $first = $self->first )
33             {
34 0           $self->first(undef);
35 0           return $first;
36             }
37 0           my ( $key, $value ) = $self->input_iter->input->each;
38 0           $value;
39             }
40              
41             __PACKAGE__->meta->make_immutable;
42              
43             1;
44              
45             __END__
46             =pod
47              
48             =head1 NAME
49              
50             Hadoop::Streaming::Reducer::Input::ValuesIterator - Role providing access to values for a given key.
51              
52             =head1 VERSION
53              
54             version 0.122420
55              
56             =head1 METHODS
57              
58             =head2 has_next
59              
60             $ValuesIterator->has_next();
61              
62             Checks if the ValueIterator has another value available for this key.
63              
64             Returns 1 on success, 0 if the next value is from another key, and undef if there is no next key.
65              
66             =head2 next
67              
68             $ValuesIterator->next();
69              
70             Returns the next value available. Reads from $ValuesIterator->input_iter->input
71              
72             =head1 AUTHORS
73              
74             =over 4
75              
76             =item *
77              
78             andrew grangaard <spazm@cpan.org>
79              
80             =item *
81              
82             Naoya Ito <naoya@hatena.ne.jp>
83              
84             =back
85              
86             =head1 COPYRIGHT AND LICENSE
87              
88             This software is copyright (c) 2012 by Naoya Ito <naoya@hatena.ne.jp>.
89              
90             This is free software; you can redistribute it and/or modify it under
91             the same terms as the Perl 5 programming language system itself.
92              
93             =cut
94