line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hadoop::Streaming::Role::Emitter; |
2
|
|
|
|
|
|
|
$Hadoop::Streaming::Role::Emitter::VERSION = '0.143060'; |
3
|
1
|
|
|
1
|
|
410
|
use Moo::Role; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
699
|
use Params::Validate qw/validate_pos/; |
|
1
|
|
|
|
|
5100
|
|
|
1
|
|
|
|
|
251
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#provides qw(run emit counter status); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Role to provide emit, counter, and status interaction with Hadoop::Streaming. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub emit { |
12
|
0
|
|
|
0
|
1
|
|
my ($self, $key, $value) = @_; |
13
|
0
|
|
|
|
|
|
eval { |
14
|
0
|
|
|
|
|
|
$self->put($key, $value); |
15
|
|
|
|
|
|
|
}; |
16
|
0
|
0
|
|
|
|
|
if ($@) { |
17
|
0
|
|
|
|
|
|
warn $@; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub put |
23
|
|
|
|
|
|
|
{ |
24
|
0
|
|
|
0
|
1
|
|
my ($self, $key, $value) = validate_pos(@_, 1, 1, 1); |
25
|
0
|
|
|
|
|
|
printf "%s\t%s\n", $key, $value; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub counter |
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
0
|
1
|
|
my ( $self, %opts ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
0
|
|
|
|
my $group = $opts{group} || 'group'; |
34
|
0
|
|
0
|
|
|
|
my $counter = $opts{counter} || 'counter'; |
35
|
0
|
|
0
|
|
|
|
my $amount = $opts{amount} || 'amount'; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $msg |
38
|
|
|
|
|
|
|
= sprintf( "reporter:counter:%s,%s,%s\n", $group, $counter, $amount ); |
39
|
0
|
|
|
|
|
|
print STDERR $msg; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub status |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
|
|
0
|
1
|
|
my ($self, $message ) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $msg = sprintf( "reporter:status:%s\n", $message); |
48
|
0
|
|
|
|
|
|
print STDERR $msg; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |