line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hadoop::Streaming::Reducer::Input; |
2
|
|
|
|
|
|
|
$Hadoop::Streaming::Reducer::Input::VERSION = '0.143060'; |
3
|
1
|
|
|
1
|
|
483
|
use Moo; |
|
1
|
|
|
|
|
1858
|
|
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
1605
|
use Hadoop::Streaming::Reducer::Input::Iterator; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
273
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#ABSTRACT: Parse input stream for reducer |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has handle => ( |
9
|
|
|
|
|
|
|
is => 'ro', |
10
|
|
|
|
|
|
|
does => 'FileHandle', |
11
|
|
|
|
|
|
|
required => 1, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has buffer => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub next_key |
20
|
|
|
|
|
|
|
{ |
21
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
22
|
0
|
0
|
|
|
|
|
my $line = $self->buffer ? $self->buffer : $self->next_line; |
23
|
0
|
0
|
|
|
|
|
return if not defined $line; |
24
|
0
|
|
|
|
|
|
my ( $key, $value ) = split /\t/, $line, 2; |
25
|
0
|
|
|
|
|
|
return $key; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub next_line { |
30
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
31
|
0
|
0
|
|
|
|
|
return if $self->handle->eof; |
32
|
0
|
|
|
|
|
|
$self->buffer( $self->handle->getline ); |
33
|
0
|
|
|
|
|
|
$self->buffer; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub getline { |
38
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
39
|
0
|
0
|
|
|
|
|
if (defined $self->buffer) { |
40
|
0
|
|
|
|
|
|
my $buf = $self->buffer; |
41
|
0
|
|
|
|
|
|
$self->buffer(undef); |
42
|
0
|
|
|
|
|
|
return $buf; |
43
|
|
|
|
|
|
|
} else { |
44
|
0
|
|
|
|
|
|
return $self->next_line; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub iterator { |
50
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
51
|
0
|
|
|
|
|
|
Hadoop::Streaming::Reducer::Input::Iterator->new( input => $self ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub each |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
58
|
0
|
0
|
|
|
|
|
my $line = $self->getline or return; |
59
|
0
|
|
|
|
|
|
chomp $line; |
60
|
0
|
|
|
|
|
|
split /\t/, $line, 2; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |