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