« 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
| |||||||||||
| 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
| |||||||||||
| 40 | 137 | $cookie->[2] = App::RecordStream::Aggregator::map_combine($this->{'AGGREGATORS'}, $cookie->[2], $record); | |||||||||
| 41 | |||||||||||
| 42 | 137 | ▶ | if($this->{'INCREMENTAL'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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; | |||||||||