| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Hadoop::Streaming::Role::Emitter; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$Hadoop::Streaming::Role::Emitter::VERSION = '0.122420'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
1
|
|
|
1
|
|
596
|
use Any::Moose qw(Role); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
7
|
|
|
6
|
1
|
|
|
1
|
|
1270
|
use Params::Validate qw/validate_pos/; |
|
|
1
|
|
|
|
|
13840
|
|
|
|
1
|
|
|
|
|
321
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#provides qw(run emit counter status); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Role to provide emit, counter, and status interaction with Hadoop::Streaming. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub emit { |
|
14
|
0
|
|
|
0
|
1
|
|
my ($self, $key, $value) = @_; |
|
15
|
0
|
|
|
|
|
|
eval { |
|
16
|
0
|
|
|
|
|
|
$self->put($key, $value); |
|
17
|
|
|
|
|
|
|
}; |
|
18
|
0
|
0
|
|
|
|
|
if ($@) { |
|
19
|
0
|
|
|
|
|
|
warn $@; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub put |
|
25
|
|
|
|
|
|
|
{ |
|
26
|
0
|
|
|
0
|
1
|
|
my ($self, $key, $value) = validate_pos(@_, 1, 1, 1); |
|
27
|
0
|
|
|
|
|
|
printf "%s\t%s\n", $key, $value; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub counter |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
0
|
|
|
0
|
1
|
|
my ( $self, %opts ) = @_; |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
0
|
|
|
|
my $group = $opts{group} || 'group'; |
|
36
|
0
|
|
0
|
|
|
|
my $counter = $opts{counter} || 'counter'; |
|
37
|
0
|
|
0
|
|
|
|
my $amount = $opts{amount} || 'amount'; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $msg |
|
40
|
|
|
|
|
|
|
= sprintf( "reporter:counter:%s,%s,%s\n", $group, $counter, $amount ); |
|
41
|
0
|
|
|
|
|
|
print STDERR $msg; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub status |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
0
|
|
|
0
|
1
|
|
my ($self, $message ) = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $msg = sprintf( "reporter:status:%s\n", $message); |
|
50
|
0
|
|
|
|
|
|
print STDERR $msg; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |
|
56
|
|
|
|
|
|
|
=pod |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Hadoop::Streaming::Role::Emitter - Role to provide emit, counter, and status interaction with Hadoop::Streaming. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 VERSION |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
version 0.122420 |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 METHODS |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 emit |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$object->emit( $key, $value ) |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This method emits a key,value pair in the format expected by Hadoop::Streaming. |
|
73
|
|
|
|
|
|
|
It does this by calling $self->put(). This catches errors from put and turns |
|
74
|
|
|
|
|
|
|
them into warnings. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 put |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$object->put( $key, $value ) |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This method emits a key,value pair to STDOUT in the format expected by |
|
81
|
|
|
|
|
|
|
Hadoop::Streaming: ( key \t value \n ) |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 counter |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$object->counter( |
|
86
|
|
|
|
|
|
|
group => $group, |
|
87
|
|
|
|
|
|
|
counter => $countername, |
|
88
|
|
|
|
|
|
|
amount => $count, |
|
89
|
|
|
|
|
|
|
); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This method emits a counter key to STDERR in the format expected by hadoop: |
|
92
|
|
|
|
|
|
|
reporter:counter:<group>,<counter>,<amount> |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 status |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$object->status( $message ) |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This method emits a status message to STDERR in the format expected by Hadoop::Streaming: |
|
99
|
|
|
|
|
|
|
reporter:status:$message\n |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHORS |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item * |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
andrew grangaard <spazm@cpan.org> |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Naoya Ito <naoya@hatena.ne.jp> |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Naoya Ito <naoya@hatena.ne.jp>. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
120
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
|
123
|
|
|
|
|
|
|
|