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

filter: Statementstmt 85.7% 48 / 56 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 12 / 14 Podpod 0.0% 0 / 8 totaltotal 77.5% 62 / 80 CC 4 SCAR 4.6
CC
4
Cov
86%
key_clumper_push_record
3.0
new_from_valuation
2.0
long_usage
2.0
CRAP 1.6
« blib/lib/App/RecordStream/Operation/sort.pm ↑ Summary blib/lib/App/RecordStream/Aggregator/Mode.pm »
1 package App::RecordStream::Clumper::KeyLRU;
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::Key;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use App::RecordStream::DomainLanguage::Registry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use App::RecordStream::LRUSheriff;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 ▶use base 'App::RecordStream::Clumper::Key';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub new
13 {
14 5 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
15 5 my $field = shift;
16 5 my $size = shift;
17  
18 5 my $this = $class->SUPER::new($field);
19  
20 5 $this->{'size'} = $size;
21  
22 5 return $this;
23 }
24  
25 sub new_from_valuation
26 {
27 0 ▶ my $class = shift;
Subroutine new_from_valuation: not called CC=1 SCAR=6.9
Pod undocumented
28 0 my $name = shift;
29 0 my $valuation = shift;
30 0 my $size = shift;
31  
32 0 my $this = $class->SUPER::new_from_valuation($name, $valuation);
33  
34 0 $this->{'size'} = $size;
35  
36 0 return $this;
37 }
38  
39 sub long_usage
40 {
41 0 ▶ return <<EOF;
Subroutine long_usage: not called CC=1 SCAR=6.9
Pod undocumented
42 Usage: keylru,<keyspec>,<size>
43 Clump records by the value for a key, limiting number of active clumps to <size>
44 EOF
45 }
46  
47 sub short_usage
48 {
49 2 ▶ return "clump records by the value for a key, limiting number of active clumps";
Subroutine short_usage: called CC=1 SCAR=0.0
Pod undocumented
50 }
51  
52 sub argct
53 {
54 5 ▶ return 2;
Subroutine argct: called CC=1 SCAR=0.0
Pod undocumented
55 }
56  
57 sub key_clumper_begin
58 {
59 11 ▶ return App::RecordStream::LRUSheriff->new();
Subroutine key_clumper_begin: called CC=1 SCAR=0.0
Pod undocumented
60 }
61  
62 sub key_clumper_push_record
63 {
64 62 ▶ my $this = shift;
Subroutine key_clumper_push_record: called CC=3 SCAR=11.0
Pod undocumented
65 62 my $cookie = shift;
66 62 my $value = shift;
67 62 my $record = shift;
68 62 my $next = shift;
69  
70 {
71 62 my $next_cookie = $cookie->find($value);
72 62 ▶ if(!defined($next_cookie))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $next_cookie) 34 28 62
73 {
74 34 $cookie->put($value, $next_cookie = $next->key_clumper_callback_begin());
75 }
76  
77 62 $next->key_clumper_callback_push_record($next_cookie, $record);
78 }
79  
80 62 for my $next_cookie ($cookie->purgenate($this->{'size'}))
81 {
82 13 $next->key_clumper_callback_end($next_cookie);
83 }
84 }
85  
86 sub key_clumper_end
87 {
88 11 ▶ my $this = shift;
Subroutine key_clumper_end: called CC=2 SCAR=6.9
Pod undocumented
89 11 my $cookie = shift;
90 11 my $next = shift;
91  
92 11 for my $next_cookie ($cookie->purgenate(0))
93 {
94 21 $next->key_clumper_callback_end($next_cookie);
95 }
96 }
97  
98 5 App::RecordStream::Clumper->register_implementation('keylru', __PACKAGE__);
99  
100 5 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'keylru', 'SCALAR', 'VALUATION', 'SCALAR');
101 5 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'key', 'SCALAR', 'VALUATION', 'SCALAR');
102  
103 5 1;
« blib/lib/App/RecordStream/Operation/sort.pm ↑ Summary blib/lib/App/RecordStream/Aggregator/Mode.pm »