line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package KinoSearch1::Index::CompoundFileReader; |
2
|
34
|
|
|
34
|
|
59594
|
use strict; |
|
34
|
|
|
|
|
70
|
|
|
34
|
|
|
|
|
1151
|
|
3
|
34
|
|
|
34
|
|
197
|
use warnings; |
|
34
|
|
|
|
|
71
|
|
|
34
|
|
|
|
|
814
|
|
4
|
34
|
|
|
34
|
|
2927
|
use KinoSearch1::Util::ToolSet; |
|
34
|
|
|
|
|
65
|
|
|
34
|
|
|
|
|
4875
|
|
5
|
34
|
|
|
34
|
|
181
|
use base qw( KinoSearch1::Store::InvIndex ); # !! |
|
34
|
|
|
|
|
74
|
|
|
34
|
|
|
|
|
4755
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
34
|
|
|
34
|
|
383
|
__PACKAGE__->init_instance_vars( |
9
|
|
|
|
|
|
|
# members / constructor params |
10
|
|
|
|
|
|
|
invindex => undef, |
11
|
|
|
|
|
|
|
seg_name => undef, |
12
|
|
|
|
|
|
|
# members |
13
|
|
|
|
|
|
|
instream => undef, |
14
|
|
|
|
|
|
|
entries => undef, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
34
|
|
|
34
|
|
2184
|
use KinoSearch1::Store::InStream; |
|
34
|
|
|
|
|
77
|
|
|
34
|
|
|
|
|
15453
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub init_instance { |
21
|
99
|
|
|
99
|
1
|
176
|
my $self = shift; |
22
|
99
|
|
|
|
|
191
|
my ( $seg_name, $invindex ) = @{$self}{ 'seg_name', 'invindex' }; |
|
99
|
|
|
|
|
418
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# read in names and lengths for all the "files" within the compound file |
25
|
99
|
|
|
|
|
474
|
my $instream = $self->{instream} |
26
|
|
|
|
|
|
|
= $invindex->open_instream("$seg_name.cfs"); |
27
|
99
|
|
|
|
|
896
|
my $num_entries = $instream->lu_read('V'); |
28
|
99
|
|
|
|
|
1209
|
my @offsets_and_names = $instream->lu_read( 'QT' x $num_entries ); |
29
|
99
|
|
|
|
|
270
|
my $offset = shift @offsets_and_names; |
30
|
99
|
|
|
|
|
166
|
my %entries; |
31
|
99
|
|
|
|
|
302
|
while (@offsets_and_names) { |
32
|
893
|
|
|
|
|
1353
|
my $filename = shift @offsets_and_names; |
33
|
893
|
|
66
|
|
|
13275
|
my $next_offset = shift @offsets_and_names || $instream->length; |
34
|
893
|
|
|
|
|
3005
|
$entries{$filename} = { |
35
|
|
|
|
|
|
|
offset => $offset, |
36
|
|
|
|
|
|
|
len => $next_offset - $offset, |
37
|
|
|
|
|
|
|
}; |
38
|
893
|
|
|
|
|
1973
|
$offset = $next_offset; |
39
|
|
|
|
|
|
|
} |
40
|
99
|
|
|
|
|
414
|
$self->{entries} = \%entries; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub open_instream { |
44
|
861
|
|
|
861
|
0
|
1353
|
my ( $self, $filename ) = @_; |
45
|
861
|
|
|
|
|
1688
|
my $entry = $self->{entries}{$filename}; |
46
|
861
|
50
|
|
|
|
1716
|
croak("filename '$filename' is not accessible") unless defined $entry; |
47
|
861
|
50
|
|
|
|
17156
|
open( my $duped_fh, '<&=', $self->{instream}->get_fh ) |
48
|
|
|
|
|
|
|
or confess("Couldn't dupe filehandle: $!"); |
49
|
861
|
|
|
|
|
10351
|
return KinoSearch1::Store::InStream->new( $duped_fh, $entry->{offset}, |
50
|
|
|
|
|
|
|
$entry->{len} ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub slurp_file { |
54
|
1
|
|
|
1
|
0
|
821
|
my ( $self, $filename ) = @_; |
55
|
1
|
|
|
|
|
5
|
my $instream = $self->open_instream($filename); |
56
|
1
|
|
|
|
|
9
|
my $contents |
57
|
|
|
|
|
|
|
= $instream->lu_read( 'a' . $self->{entries}{$filename}{len} ); |
58
|
1
|
|
|
|
|
4
|
$instream->close; |
59
|
1
|
|
|
|
|
25
|
return $contents; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
39
|
|
|
39
|
0
|
142
|
sub close { shift->{instream}->close } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |