line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hadoop::Streaming::Reducer::Input::Iterator; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Hadoop::Streaming::Reducer::Input::Iterator::VERSION = '0.122420'; |
4
|
|
|
|
|
|
|
} |
5
|
1
|
|
|
1
|
|
5
|
use Any::Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
6
|
|
|
|
|
|
|
with 'Hadoop::Streaming::Role::Iterator'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
962
|
use Hadoop::Streaming::Reducer::Input::ValuesIterator; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
289
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#ABSTRACT: Collects values for each key together with an iterator interface |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has input => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
isa => 'Hadoop::Streaming::Reducer::Input', |
15
|
|
|
|
|
|
|
required => 1, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has current_key => ( |
19
|
|
|
|
|
|
|
is => 'rw', |
20
|
|
|
|
|
|
|
does => 'Str' |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub has_next { |
25
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
26
|
0
|
0
|
|
|
|
|
return if not defined $self->input->next_key; |
27
|
0
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub next { |
32
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
if ( not defined $self->current_key ) { |
35
|
0
|
|
|
|
|
|
$self->current_key($self->input->next_key); |
36
|
0
|
|
|
|
|
|
return $self->retval( $self->current_key ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
if ($self->current_key ne $self->input->next_key) { |
40
|
0
|
|
|
|
|
|
$self->current_key($self->input->next_key); |
41
|
0
|
|
|
|
|
|
return $self->retval( $self->current_key ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my ($key, $value); |
45
|
0
|
|
|
|
|
|
do { |
46
|
0
|
0
|
|
|
|
|
($key, $value) = $self->input->each or return; |
47
|
|
|
|
|
|
|
} while ($self->current_key eq $key); |
48
|
0
|
|
|
|
|
|
$self->current_key( $key ); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $self->retval($key, $value); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub retval { |
55
|
0
|
|
|
0
|
1
|
|
my ($self, $key, $value) = @_; |
56
|
|
|
|
|
|
|
return ( |
57
|
0
|
|
|
|
|
|
$key, |
58
|
|
|
|
|
|
|
Hadoop::Streaming::Reducer::Input::ValuesIterator->new( |
59
|
|
|
|
|
|
|
input_iter => $self, |
60
|
|
|
|
|
|
|
first => $value, |
61
|
|
|
|
|
|
|
), |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |
70
|
|
|
|
|
|
|
=pod |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Hadoop::Streaming::Reducer::Input::Iterator - Collects values for each key together with an iterator interface |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 VERSION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
version 0.122420 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 METHODS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 has_next |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$Iterator->has_next(); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Checks if the iterator has a next_key. Returns 1 if there is another key in the input iterator. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 next |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$Iterator->next(); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns the key and value iterator for the next key. Discards any remaining values from the current key. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Moves the iterator to the next key value, and returns the output of retval( $key, $value); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 retval |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$Iterator->retval($key ); |
99
|
|
|
|
|
|
|
$Iterator->retval($key, $value); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Returns an two element array containing the key and a Hadoop::Streaming::Reducer::Input::ValuesIterator initialized with the given value as the first element. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
( $key, $ValueIterator) |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHORS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=over 4 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
andrew grangaard <spazm@cpan.org> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Naoya Ito <naoya@hatena.ne.jp> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Naoya Ito <naoya@hatena.ne.jp>. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
124
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|