Streaming/Role/Emitter.pm

filter: Statementstmt 83.3% 20 / 24 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 83.3% 5 / 6 Podpod 100% 4 / 4 totaltotal 73.3% 33 / 45 CC 5 SCAR 9.6
CC
5
Cov
75%
counter
4.2
emit
2.1
status
2.0
CRAP 2.6
« Streaming/Reducer.pm ↑ Summary Streaming/Reducer/Input.pm »
1 package Hadoop::Streaming::Role::Emitter;
2 10 $Hadoop::Streaming::Role::Emitter::VERSION = '0.143060';
3 10 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use Params::Validate qw/validate_pos/;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 331 ▶sub emit {
Subroutine emit: called CC=2 SCAR=7.4
Pod documented
12 331 my ($self, $key, $value) = @_;
13 331 eval {
14 331 $self->put($key, $value);
15 };
16 331 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 331 331
17 0 warn $@;
18 }
19 }
20  
21  
22 sub put
23 331 ▶{
Subroutine put: called CC=1 SCAR=0.0
Pod documented
24 331 my ($self, $key, $value) = validate_pos(@_, 1, 1, 1);
25 331 printf "%s\t%s\n", $key, $value;
26 }
27  
28  
29 sub counter
30 4 ▶{
Subroutine counter: called CC=4 SCAR=14.5
Pod documented
31 4 my ( $self, %opts ) = @_;
32  
33 4 ▶ my $group = $opts{group} || 'group';
Condition50%1/2
$opts{'group'} || 'group'
l!l
40
MC/DC0%0/1
$opts{'group'} || 'group'
$opts{'group'}
Truth table50%1/2
A
A= $opts{'group'}
Aresult
11
00
34 4 ▶ my $counter = $opts{counter} || 'counter';
Condition50%1/2
$opts{'counter'} || 'counter'
l!l
40
MC/DC0%0/1
$opts{'counter'} || 'counter'
$opts{'counter'}
Truth table50%1/2
A
A= $opts{'counter'}
Aresult
11
00
35 4 ▶ my $amount = $opts{amount} || 'amount';
Condition50%1/2
$opts{'amount'} || 'amount'
l!l
40
MC/DC0%0/1
$opts{'amount'} || 'amount'
$opts{'amount'}
Truth table50%1/2
A
A= $opts{'amount'}
Aresult
11
00
36  
37 4 my $msg
38 = sprintf( "reporter:counter:%s,%s,%s\n", $group, $counter, $amount );
39 4 print STDERR $msg;
40 }
41  
42  
43 sub status
44 0 ▶{
Subroutine status: not called CC=1 SCAR=6.9
Pod documented
45 0 my ($self, $message ) = @_;
46  
47 0 my $msg = sprintf( "reporter:status:%s\n", $message);
48 0 print STDERR $msg;
49 }
50  
51 10 1;
52  
53 __END__
« Streaming/Reducer.pm ↑ Summary Streaming/Reducer/Input.pm »