line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RecordStream::Aggregator::Mode; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = "4.0.24"; |
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
3044
|
use strict; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
163
|
|
6
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
152
|
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
279
|
use App::RecordStream::Aggregator::InjectInto::Field; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
130
|
|
9
|
6
|
|
|
6
|
|
31
|
use App::RecordStream::DomainLanguage::Registry; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
148
|
|
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
34
|
use base qw(App::RecordStream::Aggregator::InjectInto::Field); |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
1493
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#sub new -- passed through |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#sub new_from_valuation -- passed through |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub initial { |
18
|
1
|
|
|
1
|
0
|
4
|
return {}; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub combine_field |
22
|
|
|
|
|
|
|
{ |
23
|
9
|
|
|
9
|
0
|
11
|
my $this = shift; |
24
|
9
|
|
|
|
|
12
|
my $cookie = shift; |
25
|
9
|
|
|
|
|
12
|
my $value = shift; |
26
|
|
|
|
|
|
|
|
27
|
9
|
|
|
|
|
17
|
$cookie->{$value}++; |
28
|
9
|
|
|
|
|
27
|
return $cookie; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub squish { |
32
|
1
|
|
|
1
|
0
|
7
|
my $this = shift; |
33
|
1
|
|
|
|
|
2
|
my $cookie = shift; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
5
|
my @keys = keys %$cookie; |
36
|
1
|
|
|
|
|
3
|
my $max_key = shift @keys; |
37
|
1
|
|
|
|
|
2
|
my $max_value = $cookie->{$max_key}; |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
2
|
foreach my $key ( @keys ) { |
40
|
5
|
|
|
|
|
6
|
my $value = $cookie->{$key}; |
41
|
5
|
100
|
|
|
|
11
|
if ( $max_value < $value ) { |
42
|
1
|
|
|
|
|
2
|
$max_key = $key; |
43
|
1
|
|
|
|
|
2
|
$max_value = $value; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
3
|
return $max_key; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub short_usage |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
|
|
0
|
0
|
|
return "most common value for a field"; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub long_usage |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
0
|
|
print <
|
58
|
|
|
|
|
|
|
Usage: mode, |
59
|
|
|
|
|
|
|
Finds the most common value for a field and returns it. |
60
|
|
|
|
|
|
|
Will load all values into memory. |
61
|
|
|
|
|
|
|
EOF |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
App::RecordStream::Aggregator->register_implementation('mode', __PACKAGE__); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'mode', 'VALUATION'); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |