| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package KinoSearch1::Store::InvIndex; |
|
2
|
40
|
|
|
40
|
|
241
|
use strict; |
|
|
40
|
|
|
|
|
73
|
|
|
|
40
|
|
|
|
|
2659
|
|
|
3
|
40
|
|
|
40
|
|
202
|
use warnings; |
|
|
40
|
|
|
|
|
75
|
|
|
|
40
|
|
|
|
|
1108
|
|
|
4
|
40
|
|
|
40
|
|
197
|
use KinoSearch1::Util::ToolSet; |
|
|
40
|
|
|
|
|
185
|
|
|
|
40
|
|
|
|
|
12452
|
|
|
5
|
40
|
|
|
40
|
|
221
|
use base qw( KinoSearch1::Util::Class ); |
|
|
40
|
|
|
|
|
74
|
|
|
|
40
|
|
|
|
|
9891
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
|
8
|
40
|
|
|
40
|
|
371
|
__PACKAGE__->init_instance_vars( |
|
9
|
|
|
|
|
|
|
create => 0, |
|
10
|
|
|
|
|
|
|
path => undef, |
|
11
|
|
|
|
|
|
|
); |
|
12
|
|
|
|
|
|
|
} |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->ready_get(qw( create path )); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=begin comment |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $outstream = $invindex->open_outstream($filename); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Given a filename, return an OutStream object. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=end comment |
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
|
|
0
|
0
|
0
|
sub open_outstream { shift->abstract_death } |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=begin comment |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $instream = $invindex->open_instream($filename); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Given a filename, return an InStream object. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=end comment |
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
0
|
0
|
0
|
sub open_instream { shift->abstract_death } |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=begin comment |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my @files = $invindex->list; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Return a list of all the files in the InvIndex |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=end comment |
|
45
|
|
|
|
|
|
|
=cut |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
0
|
0
|
sub list { shift->abstract_death } |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=begin comment |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $truth = $invindex->file_exists($filename); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Indicate whether the invindex contains a file with the given filename. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=end comment |
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
0
|
0
|
0
|
sub file_exists { shift->abstract_death } |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=begin comment |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$invindex->rename_file( $from, $to ); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Rename a file. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=end comment |
|
67
|
|
|
|
|
|
|
=cut |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
0
|
0
|
0
|
sub rename_file { shift->abstract_death } |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=begin comment |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$invindex->delete_file($filename); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Delete a file from the invindex. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=end comment |
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
0
|
0
|
sub delete_file { shift->abstract_death } |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=begin comment |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $file_contents = $invindex->slurp_file($filename); |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Return a scalar with the file's contents. Only for small files, obviously. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=end comment |
|
89
|
|
|
|
|
|
|
=cut |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
0
|
0
|
0
|
sub slurp_file { shift->abstract_death } |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=begin comment |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $lock = $invindex->make_lock( |
|
96
|
|
|
|
|
|
|
lock_name => $name, |
|
97
|
|
|
|
|
|
|
timeout => $timeout, # milliseconds |
|
98
|
|
|
|
|
|
|
); |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Factory method for creating a KinoSearch1::Store::Lock subclassed object. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=end comment |
|
103
|
|
|
|
|
|
|
=cut |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
0
|
0
|
0
|
sub make_lock { shift->abstract_death } |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=begin comment |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
$invindex->run_while_locked( |
|
110
|
|
|
|
|
|
|
lock_name => $name, |
|
111
|
|
|
|
|
|
|
timeout => $timeout, # milliseconds |
|
112
|
|
|
|
|
|
|
do_body => \&do_some_stuff, |
|
113
|
|
|
|
|
|
|
); |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Create a Lock object and obtain a lock, run the subroutine specified by |
|
116
|
|
|
|
|
|
|
the do_body parameter, then release the lock and discard the Lock object. |
|
117
|
|
|
|
|
|
|
The hash-style argument labels include all the arguments to make_lock, plus |
|
118
|
|
|
|
|
|
|
do_body. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=end comment |
|
121
|
|
|
|
|
|
|
=cut |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub run_while_locked { |
|
124
|
192
|
|
|
192
|
0
|
5076
|
my ( $self, %args ) = @_; |
|
125
|
192
|
|
|
|
|
525
|
my $do_body = delete $args{do_body}; |
|
126
|
192
|
|
|
|
|
961
|
my $lock = $self->make_lock( %args, invindex => $self, ); |
|
127
|
192
|
|
|
|
|
478
|
my $locked; |
|
128
|
192
|
|
|
|
|
319
|
eval { |
|
129
|
192
|
|
|
|
|
778
|
$locked = $lock->obtain; |
|
130
|
192
|
|
|
|
|
658
|
$do_body->(); |
|
131
|
|
|
|
|
|
|
}; |
|
132
|
192
|
50
|
|
|
|
930
|
$lock->release if $lock->is_locked; |
|
133
|
192
|
50
|
|
|
|
2053
|
confess $@ if $@; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=begin comment |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
$invindex->close() |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Release any reserved resources. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=end comment |
|
143
|
|
|
|
|
|
|
=cut |
|
144
|
|
|
|
|
|
|
|
|
145
|
0
|
|
|
0
|
0
|
|
sub close { shift->abstract_death } |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
__END__ |