line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Algorithm::SpatialIndex::Storage::Memory; |
2
|
4
|
|
|
4
|
|
5296
|
use 5.008001; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
133
|
|
3
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
110
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
111
|
|
5
|
4
|
|
|
4
|
|
21
|
use Carp qw(croak); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
203
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
755
|
use parent 'Algorithm::SpatialIndex::Storage'; |
|
4
|
|
|
|
|
380
|
|
|
4
|
|
|
|
|
21
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Class::XSAccessor { |
10
|
4
|
|
|
|
|
40
|
getters => { |
11
|
|
|
|
|
|
|
_options => 'options', |
12
|
|
|
|
|
|
|
}, |
13
|
4
|
|
|
4
|
|
256
|
}; |
|
4
|
|
|
|
|
7
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub init { |
16
|
3
|
|
|
3
|
1
|
7
|
my $self = shift; |
17
|
3
|
|
|
|
|
8
|
$self->{nodes} = []; |
18
|
3
|
|
|
|
|
9
|
$self->{options} = {}; |
19
|
3
|
|
|
|
|
9
|
$self->{buckets} = []; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub fetch_node { |
23
|
2393
|
|
|
2393
|
1
|
9052
|
my $self = shift; |
24
|
2393
|
|
|
|
|
4103
|
my $index = shift; |
25
|
2393
|
|
|
|
|
3104
|
my $nodes = $self->{nodes}; |
26
|
2393
|
50
|
|
|
|
9526
|
return($index > $#$nodes ? undef : $nodes->[$index]); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub store_node { |
30
|
323
|
|
|
323
|
1
|
372
|
my $self = shift; |
31
|
323
|
|
|
|
|
357
|
my $node = shift; |
32
|
323
|
|
|
|
|
409
|
my $nodes = $self->{nodes}; |
33
|
323
|
|
|
|
|
458
|
my $id = $node->id; |
34
|
323
|
100
|
|
|
|
581
|
if (not defined $id) { |
35
|
279
|
|
|
|
|
270
|
$id = $#{$nodes} + 1; |
|
279
|
|
|
|
|
412
|
|
36
|
279
|
|
|
|
|
500
|
$node->id($id); |
37
|
|
|
|
|
|
|
} |
38
|
323
|
|
|
|
|
433
|
$nodes->[$id] = $node; |
39
|
323
|
|
|
|
|
1031
|
return $id; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub get_option { |
43
|
9
|
|
|
9
|
1
|
13
|
my $self = shift; |
44
|
9
|
|
|
|
|
37
|
return $self->_options->{shift()}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub set_option { |
48
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
49
|
0
|
|
|
|
|
0
|
my $key = shift; |
50
|
0
|
|
|
|
|
0
|
my $value = shift; |
51
|
0
|
|
|
|
|
0
|
$self->_options->{$key} = $value; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub store_bucket { |
55
|
662
|
|
|
662
|
1
|
768
|
my $self = shift; |
56
|
662
|
|
|
|
|
673
|
my $bucket = shift; |
57
|
662
|
|
|
|
|
2339
|
$self->{buckets}->[$bucket->node_id] = $bucket; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub fetch_bucket { |
61
|
2051
|
|
|
2051
|
1
|
46519
|
my $self = shift; |
62
|
2051
|
|
|
|
|
2176
|
my $node_id = shift; |
63
|
2051
|
|
|
|
|
12847
|
return $self->{buckets}->[$node_id]; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub delete_bucket { |
67
|
44
|
|
|
44
|
1
|
110
|
my $self = shift; |
68
|
44
|
|
|
|
|
49
|
my $node_id = shift; |
69
|
44
|
50
|
|
|
|
118
|
$node_id = $node_id->node_id if ref($node_id); |
70
|
44
|
|
|
|
|
98
|
my $buckets = $self->{buckets}; |
71
|
44
|
|
|
|
|
57
|
$buckets->[$node_id] = undef; |
72
|
44
|
|
33
|
|
|
229
|
pop(@$buckets) while @$buckets and not defined $buckets->[-1]; |
73
|
44
|
|
|
|
|
167
|
return(); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
__END__ |