blib/lib/App/RecordStream/DomainLanguage/Library.pm

filter: Statementstmt 98.2% 109 / 111 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 4 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 96.6% 29 / 30 Podpod 0.0% 0 / 2 totaltotal 92.3% 145 / 157 CC 5 SCAR 2.4
CC
5
Cov
96%
_raw_valuation
2.1
inject_into_aggregator
2.0
map_reduce_aggregator
2.0
CRAP 1.3
« blib/lib/App/RecordStream/Executor.pm ↑ Summary blib/lib/App/RecordStream/Clumper/Key/WrappedCallback.pm »
1 package App::RecordStream::DomainLanguage::Library;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶use App::RecordStream::Aggregator::InjectInto::Subrefs;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use App::RecordStream::DomainLanguage::Registry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use App::RecordStream::DomainLanguage::Snippet;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use App::RecordStream::DomainLanguage::Valuation::KeySpec;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 ▶use App::RecordStream::DomainLanguage::Valuation::Sub;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use App::RecordStream::DomainLanguage::Value;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub _identity
14 {
15 0 ▶ return $_[0];
Subroutine _identity: not called CC=1 SCAR=6.9
16 }
17  
18 8 App::RecordStream::DomainLanguage::Registry::register_fn(\&_identity, 'type_agg', 'AGGREGATOR');
19 8 App::RecordStream::DomainLanguage::Registry::register_fn(\&_identity, 'type_valuation', 'VALUATION');
20 8 App::RecordStream::DomainLanguage::Registry::register_fn(\&_identity, 'type_scalar', 'SCALAR');
21  
22 sub _snippet_upgrade
23 {
24 147 ▶ my $snippet = shift;
Subroutine _snippet_upgrade: called CC=1 SCAR=0.0
25  
26 147 my $ret = App::RecordStream::DomainLanguage::Value->new();
27 147 ▶ $ret->add_possibility('VALUATION', App::RecordStream::DomainLanguage::Valuation::Sub->new(sub { return $snippet->evaluate_as('SCALAR', {'$r' => $_[0]}); }));
Subroutine __ANON__: called CC=1 SCAR=0.0
28 147 $ret->add_possibility('SNIPPET', $snippet);
29 147 return $ret;
30 }
31  
32 8 App::RecordStream::DomainLanguage::Registry::register_fn(\&_snippet_upgrade, 'snip', 'SNIPPET');
33  
34 sub _rec_valuation
35 {
36 2 ▶ return App::RecordStream::DomainLanguage::Valuation::Sub->new(sub { return $_[0]; });
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine _rec_valuation: called CC=1 SCAR=0.0
37 }
38  
39 8 App::RecordStream::DomainLanguage::Registry::register_fn(\&_rec_valuation, 'record');
40 8 App::RecordStream::DomainLanguage::Registry::register_fn(\&_rec_valuation, 'rec');
41  
42 sub _raw_valuation
43 {
44 1 ▶ my $v = shift;
Subroutine _raw_valuation: called CC=2 SCAR=7.6
45  
46 1 ▶ if(ref($v) eq "CODE")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq "CODE") 1 0 1
47 {
48 1 return App::RecordStream::DomainLanguage::Valuation::Sub->new($v);
49 }
50  
51 0 return App::RecordStream::DomainLanguage::Valuation::KeySpec->new($v);
52 }
53  
54 8 App::RecordStream::DomainLanguage::Registry::register_fn(\&_raw_valuation, 'valuation', 'SCALAR');
55 8 App::RecordStream::DomainLanguage::Registry::register_fn(\&_raw_valuation, 'val', 'SCALAR');
56  
57 sub inject_into_aggregator
58 {
59 36 ▶ my $initial_snippet = shift;
Subroutine inject_into_aggregator: called CC=2 SCAR=6.9
Pod undocumented
60 36 my $combine_snippet = shift;
61 36 ▶ my $squish_snippet = shift || App::RecordStream::DomainLanguage::Snippet->new('$a');
Condition66%2/3
shift() || 'App::RecordStream::DomainLanguage::Snippet'->new('$a')
l!l&&r!l&&!r
24120
MC/DC0%0/2
shift() || 'App::RecordStream::DomainLanguage::Snippet'->new('$a')
shift() 'App::RecordStream::DomainLanguage::Snippet'->new('$a')
Truth table66%2/3
A || B
A= shift()B= 'App::RecordStream::DomainLanguage::Snippet'->new('$a')
ABresult
1X1
011
000
62  
63 my $initial_sub = sub
64 {
65 12 ▶ return $initial_snippet->evaluate_as('SCALAR');
Subroutine __ANON__: called CC=1 SCAR=0.0
66 36 };
67  
68 my $combine_sub = sub
69 {
70 40 ▶ my $cookie = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
71 40 my $record = shift;
72  
73 40 return $combine_snippet->evaluate_as('SCALAR', {'$a' => $cookie, '$r' => $record});
74 36 };
75  
76 my $squish_sub = sub
77 {
78 12 ▶ my $cookie = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
79  
80 12 return $squish_snippet->evaluate_as('SCALAR', {'$a' => $cookie});
81 36 };
82  
83 36 return App::RecordStream::Aggregator::InjectInto::Subrefs->new($initial_sub, $combine_sub, $squish_sub);
84 }
85  
86 8 for my $ii_name ('ii', 'inject_into')
87 {
88 16 for my $agg_name ('agg', 'aggregator')
89 {
90 32 App::RecordStream::DomainLanguage::Registry::register_fn(\&inject_into_aggregator, $ii_name . '_' . $agg_name, 'SNIPPET', 'SNIPPET');
91 32 App::RecordStream::DomainLanguage::Registry::register_fn(\&inject_into_aggregator, $ii_name . '_' . $agg_name, 'SNIPPET', 'SNIPPET', 'SNIPPET');
92 }
93 }
94  
95 sub map_reduce_aggregator
96 {
97 42 ▶ my $map_snippet = shift;
Subroutine map_reduce_aggregator: called CC=2 SCAR=6.9
Pod undocumented
98 42 my $reduce_snippet = shift;
99 42 ▶ my $squish_snippet = shift || App::RecordStream::DomainLanguage::Snippet->new('$a');
Condition66%2/3
shift() || 'App::RecordStream::DomainLanguage::Snippet'->new('$a')
l!l&&r!l&&!r
30120
MC/DC0%0/2
shift() || 'App::RecordStream::DomainLanguage::Snippet'->new('$a')
shift() 'App::RecordStream::DomainLanguage::Snippet'->new('$a')
Truth table66%2/3
A || B
A= shift()B= 'App::RecordStream::DomainLanguage::Snippet'->new('$a')
ABresult
1X1
011
000
100  
101 my $map_sub = sub
102 {
103 46 ▶ my $record = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
104  
105 46 return $map_snippet->evaluate_as('SCALAR', {'$r' => $record});
106 42 };
107  
108 my $reduce_sub = sub
109 {
110 29 ▶ my $cookie1 = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
111 29 my $cookie2 = shift;
112  
113 29 return $reduce_snippet->evaluate_as('SCALAR', {'$a' => $cookie1, '$b' => $cookie2});
114 42 };
115  
116 my $squish_sub = sub
117 {
118 14 ▶ my $cookie = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
119  
120 14 return $squish_snippet->evaluate_as('SCALAR', {'$a' => $cookie});
121 42 };
122  
123 42 return App::RecordStream::Aggregator::MapReduce::Subrefs->new($map_sub, $reduce_sub, $squish_sub);
124 }
125  
126 8 for my $mr_name ('mr', 'map_reduce')
127 {
128 16 for my $agg_name ('agg', 'aggregator')
129 {
130 32 App::RecordStream::DomainLanguage::Registry::register_fn(\&map_reduce_aggregator, $mr_name . '_' . $agg_name, 'SNIPPET', 'SNIPPET');
131 32 App::RecordStream::DomainLanguage::Registry::register_fn(\&map_reduce_aggregator, $mr_name . '_' . $agg_name, 'SNIPPET', 'SNIPPET', 'SNIPPET');
132 }
133 }
134  
135 sub _subset_agg
136 {
137 6 ▶ my $match_snippet = shift;
Subroutine _subset_agg: called CC=1 SCAR=0.0
138 6 my $aggregator = shift;
139  
140 my $initial_sub = sub
141 {
142 2 ▶ return $aggregator->initial();
Subroutine __ANON__: called CC=1 SCAR=0.0
143 6 };
144  
145 my $combine_sub = sub
146 {
147 12 ▶ my $cookie = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
148 12 my $record = shift;
149  
150 12 ▶ if($match_snippet->evaluate_as('SCALAR', {'$r' => $record}))
Branch: 1 branch
BranchTrueFalseTotal
if ($match_snippet->evaluate_as("SCALAR", {"\$r", $record})) 6 6 12
151 {
152 6 $cookie = $aggregator->combine($cookie, $record);
153 }
154  
155 12 return $cookie;
156 6 };
157  
158 my $squish_sub = sub
159 {
160 2 ▶ my $cookie = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
161  
162 2 return $aggregator->squish($cookie);
163 6 };
164  
165 6 return App::RecordStream::Aggregator::InjectInto::Subrefs->new($initial_sub, $combine_sub, $squish_sub);
166 }
167  
168 8 App::RecordStream::DomainLanguage::Registry::register_fn(\&_subset_agg, 'subset_aggregator', 'SNIPPET', 'AGGREGATOR');
169 8 App::RecordStream::DomainLanguage::Registry::register_fn(\&_subset_agg, 'subset_agg', 'SNIPPET', 'AGGREGATOR');
170  
171 sub _xform_agg
172 {
173 3 ▶ my $aggregator = shift;
Subroutine _xform_agg: called CC=1 SCAR=0.0
174 3 my $snippet = shift;
175  
176 my $initial_sub = sub
177 {
178 1 ▶ return $aggregator->initial();
Subroutine __ANON__: called CC=1 SCAR=0.0
179 3 };
180  
181 my $combine_sub = sub
182 {
183 3 ▶ my $cookie = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
184 3 my $record = shift;
185  
186 3 return $aggregator->combine($cookie, $record);
187 3 };
188  
189 my $squish_sub = sub
190 {
191 1 ▶ my $cookie = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
192  
193 1 my $result = $aggregator->squish($cookie);
194  
195 1 return $snippet->evaluate_as('SCALAR', {'$r' => $result});
196 3 };
197  
198 3 return App::RecordStream::Aggregator::InjectInto::Subrefs->new($initial_sub, $combine_sub, $squish_sub);
199 }
200  
201 8 App::RecordStream::DomainLanguage::Registry::register_fn(\&_xform_agg, 'xform', 'AGGREGATOR', 'SNIPPET');
202  
203 8 1;
« blib/lib/App/RecordStream/Executor.pm ↑ Summary blib/lib/App/RecordStream/Clumper/Key/WrappedCallback.pm »