blib/lib/App/RecordStream/Clumper/Window.pm

filter: Statementstmt 97.6% 42 / 43 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 0.0% 0 / 7 totaltotal 86.3% 57 / 66 CC 4 SCAR 6.2
CC
4
Cov
98%
clumper_push_record
4.0
long_usage
2.0
BEGIN
1.0
CRAP 1.9
« blib/lib/App/RecordStream/Manual/Story.pm ↑ Summary generate_pods.pl »
1 package App::RecordStream::Clumper::Window;
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::Clumper::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use App::RecordStream::DomainLanguage::Registry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 ▶use base 'App::RecordStream::Clumper::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub new
12 2 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
13 2 my $class = shift;
14 2 my $size = shift;
15  
16 2 my $this =
17 {
18 'size' => $size,
19 };
20 2 bless $this, $class;
21  
22 2 return $this;
23 }
24  
25 sub long_usage
26 0 ▶{
Subroutine long_usage: not called CC=1 SCAR=6.9
Pod undocumented
27 0 return <<EOF;
28 Usage: window,<size>
29 Clump records by a rolling window of size <size>. The windows are strict
30 (that is partial windows are not given at the beginning or end). For
31 example, if there are five input records (1, 2, 3, 4, 5) and the window is
32 3, then the first clump will be (1, 2, 3), the second (2, 3, 4) and the
33 third and final (3, 4, 5).
34 EOF
35 }
36  
37 sub short_usage
38 2 ▶{
Subroutine short_usage: called CC=1 SCAR=0.0
Pod undocumented
39 2 return "clump records by a rolling window";
40 }
41  
42 sub argct
43 2 ▶{
Subroutine argct: called CC=1 SCAR=0.0
Pod undocumented
44 2 return 1;
45 }
46  
47 sub clumper_begin
48 5 ▶{
Subroutine clumper_begin: called CC=1 SCAR=0.0
Pod undocumented
49 5 my $this = shift;
50 5 my $bucket = shift;
51  
52 5 return [$bucket, []];
53 }
54  
55 sub clumper_push_record
56 19 ▶{
Subroutine clumper_push_record: called CC=4 SCAR=13.9
Pod undocumented
57 19 my $this = shift;
58 19 my $cookie = shift;
59 19 my $record = shift;
60 19 my $next = shift;
61  
62 19 my $bucket = $cookie->[0];
63 19 my $window = $cookie->[1];
64  
65 19 push @$window, $record;
66 19 ▶ if(@$window > $this->{'size'})
Branch: 1 branch
BranchTrueFalseTotal
if (@$window > $this->{"size"}) 7 12 19
67 {
68 7 shift @$window;
69 }
70 19 ▶ if(@$window >= $this->{'size'})
Branch: 1 branch
BranchTrueFalseTotal
if (@$window >= $this->{"size"}) 10 9 19
71 {
72 10 my $next_cookie = $next->clumper_callback_begin($bucket);
73 10 for my $record (@$window)
74 {
75 30 $next->clumper_callback_push_record($next_cookie, $record);
76 }
77 10 $next->clumper_callback_end($next_cookie);
78 }
79 }
80  
81 sub clumper_end
82 5 ▶{
Subroutine clumper_end: called CC=1 SCAR=0.0
Pod undocumented
83 # ignore
84 }
85  
86 5 App::RecordStream::Clumper->register_implementation('window', __PACKAGE__);
87  
88 5 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new', 'window', 'SCALAR');
89  
90 5 1;
« blib/lib/App/RecordStream/Manual/Story.pm ↑ Summary generate_pods.pl »