line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RecordStream::DomainLanguage::Library; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
1179
|
use strict; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
184
|
|
4
|
6
|
|
|
6
|
|
37
|
use warnings; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
179
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
1680
|
use App::RecordStream::Aggregator::InjectInto::Subrefs; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
165
|
|
7
|
6
|
|
|
6
|
|
661
|
use App::RecordStream::DomainLanguage::Registry; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
161
|
|
8
|
6
|
|
|
6
|
|
38
|
use App::RecordStream::DomainLanguage::Snippet; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
128
|
|
9
|
6
|
|
|
6
|
|
35
|
use App::RecordStream::DomainLanguage::Valuation::KeySpec; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
132
|
|
10
|
6
|
|
|
6
|
|
33
|
use App::RecordStream::DomainLanguage::Valuation::Sub; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
145
|
|
11
|
6
|
|
|
6
|
|
39
|
use App::RecordStream::DomainLanguage::Value; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
5983
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _identity |
14
|
|
|
|
|
|
|
{ |
15
|
0
|
|
|
0
|
|
0
|
return $_[0]; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&_identity, 'type_agg', 'AGGREGATOR'); |
19
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&_identity, 'type_valuation', 'VALUATION'); |
20
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&_identity, 'type_scalar', 'SCALAR'); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _snippet_upgrade |
23
|
|
|
|
|
|
|
{ |
24
|
147
|
|
|
147
|
|
300
|
my $snippet = shift; |
25
|
|
|
|
|
|
|
|
26
|
147
|
|
|
|
|
422
|
my $ret = App::RecordStream::DomainLanguage::Value->new(); |
27
|
147
|
|
|
28
|
|
1080
|
$ret->add_possibility('VALUATION', App::RecordStream::DomainLanguage::Valuation::Sub->new(sub { return $snippet->evaluate_as('SCALAR', {'$r' => $_[0]}); })); |
|
28
|
|
|
|
|
112
|
|
28
|
147
|
|
|
|
|
461
|
$ret->add_possibility('SNIPPET', $snippet); |
29
|
147
|
|
|
|
|
386
|
return $ret; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&_snippet_upgrade, 'snip', 'SNIPPET'); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _rec_valuation |
35
|
|
|
|
|
|
|
{ |
36
|
2
|
|
|
2
|
|
8
|
return App::RecordStream::DomainLanguage::Valuation::Sub->new(sub { return $_[0]; }); |
|
3
|
|
|
3
|
|
22
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&_rec_valuation, 'record'); |
40
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&_rec_valuation, 'rec'); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _raw_valuation |
43
|
|
|
|
|
|
|
{ |
44
|
1
|
|
|
1
|
|
2
|
my $v = shift; |
45
|
|
|
|
|
|
|
|
46
|
1
|
50
|
|
|
|
4
|
if(ref($v) eq "CODE") |
47
|
|
|
|
|
|
|
{ |
48
|
1
|
|
|
|
|
4
|
return App::RecordStream::DomainLanguage::Valuation::Sub->new($v); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
0
|
return App::RecordStream::DomainLanguage::Valuation::KeySpec->new($v); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&_raw_valuation, 'valuation', 'SCALAR'); |
55
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&_raw_valuation, 'val', 'SCALAR'); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub inject_into_aggregator |
58
|
|
|
|
|
|
|
{ |
59
|
37
|
|
|
37
|
0
|
97
|
my $initial_snippet = shift; |
60
|
37
|
|
|
|
|
85
|
my $combine_snippet = shift; |
61
|
37
|
|
66
|
|
|
141
|
my $squish_snippet = shift || App::RecordStream::DomainLanguage::Snippet->new('$a'); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $initial_sub = sub |
64
|
|
|
|
|
|
|
{ |
65
|
13
|
|
|
13
|
|
59
|
return $initial_snippet->evaluate_as('SCALAR'); |
66
|
37
|
|
|
|
|
234
|
}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $combine_sub = sub |
69
|
|
|
|
|
|
|
{ |
70
|
43
|
|
|
43
|
|
90
|
my $cookie = shift; |
71
|
43
|
|
|
|
|
95
|
my $record = shift; |
72
|
|
|
|
|
|
|
|
73
|
43
|
|
|
|
|
258
|
return $combine_snippet->evaluate_as('SCALAR', {'$a' => $cookie, '$r' => $record}); |
74
|
37
|
|
|
|
|
178
|
}; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $squish_sub = sub |
77
|
|
|
|
|
|
|
{ |
78
|
13
|
|
|
13
|
|
32
|
my $cookie = shift; |
79
|
|
|
|
|
|
|
|
80
|
13
|
|
|
|
|
85
|
return $squish_snippet->evaluate_as('SCALAR', {'$a' => $cookie}); |
81
|
37
|
|
|
|
|
191
|
}; |
82
|
|
|
|
|
|
|
|
83
|
37
|
|
|
|
|
255
|
return App::RecordStream::Aggregator::InjectInto::Subrefs->new($initial_sub, $combine_sub, $squish_sub); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
for my $ii_name ('ii', 'inject_into') |
87
|
|
|
|
|
|
|
{ |
88
|
|
|
|
|
|
|
for my $agg_name ('agg', 'aggregator') |
89
|
|
|
|
|
|
|
{ |
90
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&inject_into_aggregator, $ii_name . '_' . $agg_name, 'SNIPPET', 'SNIPPET'); |
91
|
|
|
|
|
|
|
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
|
43
|
|
|
43
|
0
|
98
|
my $map_snippet = shift; |
98
|
43
|
|
|
|
|
88
|
my $reduce_snippet = shift; |
99
|
43
|
|
66
|
|
|
154
|
my $squish_snippet = shift || App::RecordStream::DomainLanguage::Snippet->new('$a'); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $map_sub = sub |
102
|
|
|
|
|
|
|
{ |
103
|
49
|
|
|
49
|
|
94
|
my $record = shift; |
104
|
|
|
|
|
|
|
|
105
|
49
|
|
|
|
|
192
|
return $map_snippet->evaluate_as('SCALAR', {'$r' => $record}); |
106
|
43
|
|
|
|
|
258
|
}; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $reduce_sub = sub |
109
|
|
|
|
|
|
|
{ |
110
|
31
|
|
|
31
|
|
72
|
my $cookie1 = shift; |
111
|
31
|
|
|
|
|
58
|
my $cookie2 = shift; |
112
|
|
|
|
|
|
|
|
113
|
31
|
|
|
|
|
173
|
return $reduce_snippet->evaluate_as('SCALAR', {'$a' => $cookie1, '$b' => $cookie2}); |
114
|
43
|
|
|
|
|
180
|
}; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my $squish_sub = sub |
117
|
|
|
|
|
|
|
{ |
118
|
15
|
|
|
15
|
|
41
|
my $cookie = shift; |
119
|
|
|
|
|
|
|
|
120
|
15
|
|
|
|
|
86
|
return $squish_snippet->evaluate_as('SCALAR', {'$a' => $cookie}); |
121
|
43
|
|
|
|
|
155
|
}; |
122
|
|
|
|
|
|
|
|
123
|
43
|
|
|
|
|
245
|
return App::RecordStream::Aggregator::MapReduce::Subrefs->new($map_sub, $reduce_sub, $squish_sub); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
for my $mr_name ('mr', 'map_reduce') |
127
|
|
|
|
|
|
|
{ |
128
|
|
|
|
|
|
|
for my $agg_name ('agg', 'aggregator') |
129
|
|
|
|
|
|
|
{ |
130
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&map_reduce_aggregator, $mr_name . '_' . $agg_name, 'SNIPPET', 'SNIPPET'); |
131
|
|
|
|
|
|
|
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
|
|
|
6
|
|
11
|
my $match_snippet = shift; |
138
|
6
|
|
|
|
|
12
|
my $aggregator = shift; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
my $initial_sub = sub |
141
|
|
|
|
|
|
|
{ |
142
|
2
|
|
|
2
|
|
17
|
return $aggregator->initial(); |
143
|
6
|
|
|
|
|
24
|
}; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my $combine_sub = sub |
146
|
|
|
|
|
|
|
{ |
147
|
12
|
|
|
12
|
|
26
|
my $cookie = shift; |
148
|
12
|
|
|
|
|
20
|
my $record = shift; |
149
|
|
|
|
|
|
|
|
150
|
12
|
100
|
|
|
|
52
|
if($match_snippet->evaluate_as('SCALAR', {'$r' => $record})) |
151
|
|
|
|
|
|
|
{ |
152
|
6
|
|
|
|
|
31
|
$cookie = $aggregator->combine($cookie, $record); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
12
|
|
|
|
|
61
|
return $cookie; |
156
|
6
|
|
|
|
|
26
|
}; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
my $squish_sub = sub |
159
|
|
|
|
|
|
|
{ |
160
|
2
|
|
|
2
|
|
6
|
my $cookie = shift; |
161
|
|
|
|
|
|
|
|
162
|
2
|
|
|
|
|
13
|
return $aggregator->squish($cookie); |
163
|
6
|
|
|
|
|
22
|
}; |
164
|
|
|
|
|
|
|
|
165
|
6
|
|
|
|
|
27
|
return App::RecordStream::Aggregator::InjectInto::Subrefs->new($initial_sub, $combine_sub, $squish_sub); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&_subset_agg, 'subset_aggregator', 'SNIPPET', 'AGGREGATOR'); |
169
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&_subset_agg, 'subset_agg', 'SNIPPET', 'AGGREGATOR'); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub _xform_agg |
172
|
|
|
|
|
|
|
{ |
173
|
3
|
|
|
3
|
|
6
|
my $aggregator = shift; |
174
|
3
|
|
|
|
|
4
|
my $snippet = shift; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
my $initial_sub = sub |
177
|
|
|
|
|
|
|
{ |
178
|
1
|
|
|
1
|
|
9
|
return $aggregator->initial(); |
179
|
3
|
|
|
|
|
11
|
}; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
my $combine_sub = sub |
182
|
|
|
|
|
|
|
{ |
183
|
3
|
|
|
3
|
|
4
|
my $cookie = shift; |
184
|
3
|
|
|
|
|
7
|
my $record = shift; |
185
|
|
|
|
|
|
|
|
186
|
3
|
|
|
|
|
7
|
return $aggregator->combine($cookie, $record); |
187
|
3
|
|
|
|
|
14
|
}; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
my $squish_sub = sub |
190
|
|
|
|
|
|
|
{ |
191
|
1
|
|
|
1
|
|
3
|
my $cookie = shift; |
192
|
|
|
|
|
|
|
|
193
|
1
|
|
|
|
|
4
|
my $result = $aggregator->squish($cookie); |
194
|
|
|
|
|
|
|
|
195
|
1
|
|
|
|
|
5
|
return $snippet->evaluate_as('SCALAR', {'$r' => $result}); |
196
|
3
|
|
|
|
|
15
|
}; |
197
|
|
|
|
|
|
|
|
198
|
3
|
|
|
|
|
13
|
return App::RecordStream::Aggregator::InjectInto::Subrefs->new($initial_sub, $combine_sub, $squish_sub); |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_fn(\&_xform_agg, 'xform', 'AGGREGATOR', 'SNIPPET'); |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
1; |