line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Algorithm::LossyCount::Entry; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
11
|
use v5.10; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
323
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
5752
|
|
|
5752
|
0
|
12715
|
my ($class, %params) = @_; |
7
|
|
|
|
|
|
|
|
8
|
5752
|
|
33
|
|
|
22214
|
my $num_allowed_errors = delete $params{num_allowed_errors} |
9
|
|
|
|
|
|
|
// Carp::croak('Missing mandatory parameter: "num_allowed_errors"'); |
10
|
5752
|
50
|
|
|
|
12613
|
if (%params) { |
11
|
0
|
|
|
|
|
0
|
Carp::croak( |
12
|
|
|
|
|
|
|
'Unknown parameter(s): ', |
13
|
0
|
|
|
|
|
0
|
join ', ', map { qq/"$_"/ } sort keys %params, |
14
|
|
|
|
|
|
|
) |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
bless +{ |
18
|
5752
|
|
|
|
|
51069
|
frequency => 1, |
19
|
|
|
|
|
|
|
num_allowed_errors => $num_allowed_errors, |
20
|
|
|
|
|
|
|
} => $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
10108
|
|
|
10108
|
0
|
65899
|
sub frequency { $_[0]->{frequency} } |
24
|
|
|
|
|
|
|
|
25
|
8963
|
|
|
8963
|
0
|
21888
|
sub increment_frequency { ++$_[0]->{frequency} } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub num_allowed_errors { |
28
|
18951
|
|
|
18951
|
0
|
24316
|
my ($self, $new_value) = @_; |
29
|
|
|
|
|
|
|
|
30
|
18951
|
100
|
|
|
|
52883
|
$self->{num_allowed_errors} = $new_value if defined $new_value; |
31
|
18951
|
|
|
|
|
86048
|
$self->{num_allowed_errors}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub survive_in_bucket { |
35
|
9988
|
|
|
9988
|
0
|
14605
|
my ($self, $current_bucket) = @_; |
36
|
|
|
|
|
|
|
|
37
|
9988
|
50
|
|
|
|
22673
|
unless (defined $current_bucket) { |
38
|
0
|
|
|
|
|
0
|
Carp::croak('survive_in_bucket() requires 1 parameter.'); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
9988
|
|
|
|
|
16347
|
$self->frequency + $self->num_allowed_errors > $current_bucket; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |