blib/lib/App/RecordStream/Operation/collate/BaseClumperCallback.pm

filter: Statementstmt 97.7% 43 / 44 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 4 totaltotal 90.6% 58 / 64 CC 7 SCAR 8.9
CC
7
Cov
96%
clumper_callback_end
4.0
clumper_callback_push_record
3.0
clumper_callback_begin
2.0
CRAP 2.4
« blib/lib/App/RecordStream/Operation/collate.pm ↑ Summary blib/lib/App/RecordStream/Operation/generate.pm »
1 package App::RecordStream::Operation::collate::BaseClumperCallback;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use App::RecordStream::Aggregator;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use App::RecordStream::Record;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub new {
10 15 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
11 15 my $aggregators = shift;
12 15 my $incremental = shift;
13 15 my $bucket = shift;
14 15 my $record_cb = shift;
15  
16 15 my $this = {
17 'AGGREGATORS' => $aggregators,
18 'INCREMENTAL' => $incremental,
19 'BUCKET' => $bucket,
20 'RECORD_CB' => $record_cb,
21 };
22 15 bless $this, $class;
23  
24 15 return $this;
25 }
26  
27 sub clumper_callback_begin {
28 66 ▶ my $this = shift;
Subroutine clumper_callback_begin: called CC=2 SCAR=6.9
Pod undocumented
29 66 my $bucket = shift;
30  
31 66 ▶ return [$bucket, $this->{'BUCKET'} ? undef : [], App::RecordStream::Aggregator::map_initial($this->{'AGGREGATORS'})];
Branch: 1 branch
BranchTrueFalseTotal
$this->{'BUCKET'} ? : 64 2 66
32 }
33  
34 sub clumper_callback_push_record {
35 137 ▶ my $this = shift;
Subroutine clumper_callback_push_record: called CC=3 SCAR=11.1
Pod undocumented
36 137 my $cookie = shift;
37 137 my $record = shift;
38  
39 137 ▶ push @{$cookie->[1]}, $record if(!$this->{'BUCKET'});
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"BUCKET"} 5 132 137
40 137 $cookie->[2] = App::RecordStream::Aggregator::map_combine($this->{'AGGREGATORS'}, $cookie->[2], $record);
41  
42 137 ▶ if($this->{'INCREMENTAL'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"INCREMENTAL"}) 0 137 137
43 0 $this->clumper_callback_end($cookie);
44 }
45 }
46  
47 sub clumper_callback_end {
48 65 ▶ my $this = shift;
Subroutine clumper_callback_end: called CC=4 SCAR=13.9
Pod undocumented
49 65 my $cookie = shift;
50  
51 65 ▶ for my $proto_result ($this->{'BUCKET'} ? ($cookie->[0]) : @{$cookie->[1]}) {
Branch: 1 branch
BranchTrueFalseTotal
$this->{'BUCKET'} ? : 63 2 65
52 my $result = {
53 # first, the bucket or original record
54 %$proto_result,
55  
56 # then, the aggregators
57 68 %{App::RecordStream::Aggregator::map_squish($this->{'AGGREGATORS'}, $cookie->[2])},
58 };
59  
60 68 my $record = App::RecordStream::Record->new();
61  
62 68 for my $key (keys(%$result))
63 {
64 197 my $value = $result->{$key};
65  
66 197 ${$record->guess_key_from_spec($key)} = $value;
67 }
68  
69 68 $this->{'RECORD_CB'}->($record);
70 }
71 }
72  
73 4 1;
« blib/lib/App/RecordStream/Operation/collate.pm ↑ Summary blib/lib/App/RecordStream/Operation/generate.pm »