| 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
| |||||||||||||
| 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'
MC/DC0%0/1
$opts{'group'} || 'group'
$opts{'group'}
Truth table50%1/2
A
A= $opts{'group'}
| |||||||||||||
| 34 | 4 | ▶ | my $counter = $opts{counter} || 'counter'; | ||||||||||
|
Condition50%1/2
$opts{'counter'} || 'counter'
MC/DC0%0/1
$opts{'counter'} || 'counter'
$opts{'counter'}
Truth table50%1/2
A
A= $opts{'counter'}
| |||||||||||||
| 35 | 4 | ▶ | my $amount = $opts{amount} || 'amount'; | ||||||||||
|
Condition50%1/2
$opts{'amount'} || 'amount'
MC/DC0%0/1
$opts{'amount'} || 'amount'
$opts{'amount'}
Truth table50%1/2
A
A= $opts{'amount'}
| |||||||||||||
| 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__ | ||||||||||||