blib/lib/App/RecordStream/Aggregator/ValuesToKeys.pm

filter: Statementstmt 67.8% 19 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 55.5% 5 / 9 Podpod 0.0% 0 / 5 totaltotal 57.1% 24 / 42 CC 2 SCAR 8.3
CC
2
Cov
68%
reduce
6.0
map_fields
2.0
long_usage
2.0
CRAP 2.3
« blib/lib/App/RecordStream/Operation/fromxferlog.pm ↑ Summary blib/lib/App/RecordStream/Operation/fromkv.pm »
1 package App::RecordStream::Aggregator::ValuesToKeys;
2  
3 6 our $VERSION = "4.0.23";
4  
5 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use App::RecordStream::Aggregator;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use base qw(App::RecordStream::Aggregator::MapReduce::FieldSet);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #sub new -- passed through
12  
13 #sub new_from_valuation -- passed through
14  
15 sub map_fields {
16 0 ▶ my ($this, $key, $value) = @_;
Subroutine map_fields: not called CC=1 SCAR=6.9
Pod undocumented
17 0 return { $key => $value };
18 }
19  
20 sub reduce {
21 0 ▶ my ($this, $cookie1, $cookie2) = @_;
Subroutine reduce: not called CC=2 SCAR=17.9
Pod undocumented
22  
23 0 foreach my $key (keys %$cookie2 ) {
24 0 my $value = $cookie2->{$key};
25 0 $cookie1->{$key} = $value;
26 }
27  
28 0 return $cookie1;
29 }
30  
31 sub long_usage {
32 0 ▶ return <<EOF;
Subroutine long_usage: not called CC=1 SCAR=6.9
Pod undocumented
33 Usage: valuestokeys,<keyfield>,<valuefield>
34 Take the specified keyfield, use its value as the key for the value of value
35 field.. For instance:
36 { k: 'FOO', t: 2 }
37 { k: 'BAR', t: 5 }
38  
39 becomes:
40 { 'FOO': 2, 'BAR': 5 }
41  
42 with the aggregator 'vk,k,t'. Repeated keyfield values will clobber earlier
43 instances
44 EOF
45 }
46  
47 sub short_usage {
48 1 ▶ return "use one key-value as a key for a different value in the record";
Subroutine short_usage: called CC=1 SCAR=0.0
Pod undocumented
49 }
50  
51 sub argct {
52 0 ▶ return 2;
Subroutine argct: not called CC=1 SCAR=6.9
Pod undocumented
53 }
54  
55 6 App::RecordStream::Aggregator->register_implementation('valuestokeys', __PACKAGE__);
56 6 App::RecordStream::Aggregator->register_implementation('vk', __PACKAGE__);
57  
58 6 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'valuestokeys', 'VALUATION', 'VALUATION');
59 6 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'vk', 'VALUATION', 'VALUATION');
60  
61 6 1;
« blib/lib/App/RecordStream/Operation/fromxferlog.pm ↑ Summary blib/lib/App/RecordStream/Operation/fromkv.pm »