line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RecordStream::Aggregator::DistinctCount; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = "4.0.23"; |
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
3302
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
144
|
|
6
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
128
|
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
324
|
use App::RecordStream::Aggregator; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
110
|
|
9
|
6
|
|
|
6
|
|
380
|
use App::RecordStream::DomainLanguage::Registry; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
116
|
|
10
|
6
|
|
|
6
|
|
29
|
use App::RecordStream::DomainLanguage::Valuation::KeySpec; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
132
|
|
11
|
|
|
|
|
|
|
|
12
|
6
|
|
|
6
|
|
29
|
use base qw(App::RecordStream::Aggregator::Aggregation); |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
2019
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new |
15
|
|
|
|
|
|
|
{ |
16
|
1
|
|
|
1
|
0
|
13
|
my $class = shift; |
17
|
1
|
|
|
|
|
3
|
my $field = shift; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
10
|
return new_from_valuation($class, App::RecordStream::DomainLanguage::Valuation::KeySpec->new($field)); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new_from_valuation |
23
|
|
|
|
|
|
|
{ |
24
|
10
|
|
|
10
|
0
|
20
|
my $class = shift; |
25
|
10
|
|
|
|
|
20
|
my ($valuation) = @_; |
26
|
|
|
|
|
|
|
|
27
|
10
|
|
|
|
|
27
|
my $this = |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
'valuation' => $valuation, |
30
|
|
|
|
|
|
|
}; |
31
|
10
|
|
|
|
|
22
|
bless $this, $class; |
32
|
|
|
|
|
|
|
|
33
|
10
|
|
|
|
|
28
|
return $this; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub squish |
37
|
|
|
|
|
|
|
{ |
38
|
40
|
|
|
40
|
0
|
83
|
my ($this, $cookie) = @_; |
39
|
|
|
|
|
|
|
|
40
|
40
|
|
|
|
|
123
|
return scalar(keys(%$cookie)); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub short_usage |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
|
|
0
|
0
|
0
|
return "count unique values from provided field"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub long_usage |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
|
|
0
|
0
|
0
|
return <
|
51
|
|
|
|
|
|
|
Usage: dct, |
52
|
|
|
|
|
|
|
Finds the number of unique values for a field and returns it. Will load all |
53
|
|
|
|
|
|
|
values into memory. |
54
|
|
|
|
|
|
|
EOF |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub argct |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
0
|
0
|
0
|
return 1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub initial |
63
|
|
|
|
|
|
|
{ |
64
|
40
|
|
|
40
|
0
|
97
|
return {}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub combine |
68
|
|
|
|
|
|
|
{ |
69
|
312
|
|
|
312
|
0
|
593
|
my ($this, $cookie, $record) = @_; |
70
|
|
|
|
|
|
|
|
71
|
312
|
|
|
|
|
820
|
my $value = $this->{'valuation'}->evaluate_record($record); |
72
|
|
|
|
|
|
|
|
73
|
312
|
|
|
|
|
624
|
$cookie->{$value} = 1; |
74
|
|
|
|
|
|
|
|
75
|
312
|
|
|
|
|
922
|
return $cookie; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
App::RecordStream::Aggregator->register_implementation('dcount', __PACKAGE__); |
79
|
|
|
|
|
|
|
App::RecordStream::Aggregator->register_implementation('dct', __PACKAGE__); |
80
|
|
|
|
|
|
|
App::RecordStream::Aggregator->register_implementation('distinctcount', __PACKAGE__); |
81
|
|
|
|
|
|
|
App::RecordStream::Aggregator->register_implementation('distinctct', __PACKAGE__); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'dcount', 'VALUATION'); |
84
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'dct', 'VALUATION'); |
85
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'distinctcount', 'VALUATION'); |
86
|
|
|
|
|
|
|
App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'distinctct', 'VALUATION'); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |