Streaming/Reducer/Input/ValuesIterator.pm

filter: Statementstmt 90.0% 18 / 20 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 2 / 2 totaltotal 87.8% 29 / 33 SCAR 16.2
CC
5
Cov
86%
has_next
4.0
next
2.2
BEGIN
1.0
CRAP 5.1
« Streaming/Role/Emitter.pm ↑ Summary Streaming/Combiner.pm »
1 package Hadoop::Streaming::Reducer::Input::ValuesIterator;
2 {
3 6 $Hadoop::Streaming::Reducer::Input::ValuesIterator::VERSION = '0.122420';
4 }
5 6 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 with 'Hadoop::Streaming::Role::Iterator';
7  
8 #ABSTRACT: Role providing access to values for a given key.
9  
10 6 has input_iter => (
11 is => 'ro',
12 does => 'Hadoop::Streaming::Role::Iterator',
13 required => 1,
14 );
15  
16 6 has first => ( is => 'rw', );
17  
18  
19 sub has_next
20 {
21 376 ▶ my $self = shift;
Subroutine has_next: called CC=4 SCAR=13.9
Pod documented
22 376 ▶ return 1 if $self->first;
Branch: 1 branch
BranchTrueFalseTotal
if $self->first 0 376 376
23 376 ▶ return unless defined $self->input_iter->input->next_key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->input_iter->input->next_key 5 371 376
24 371 ▶ return $self->input_iter->current_key eq
Branch: 1 branch
BranchTrueFalseTotal
$self->input_iter->current_key eq $self->input_iter->input->next_key ? : 299 72 371
25 $self->input_iter->input->next_key ? 1 : 0;
26 }
27  
28  
29 sub next
30 {
31 299 ▶ my $self = shift;
Subroutine next: called CC=2 SCAR=7.9
Pod documented
32 299 ▶ if ( my $first = $self->first )
Branch: 1 branch
BranchTrueFalseTotal
if (my $first = $self->first) 0 299 299
33 {
34 0 $self->first(undef);
35 0 return $first;
36 }
37 299 my ( $key, $value ) = $self->input_iter->input->each;
38 299 $value;
39 }
40  
41 6 __PACKAGE__->meta->make_immutable;
42  
43 6 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  
« Streaming/Role/Emitter.pm ↑ Summary Streaming/Combiner.pm »