line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more |
2
|
|
|
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
3
|
|
|
|
|
|
|
# this work for additional information regarding copyright ownership. |
4
|
|
|
|
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
5
|
|
|
|
|
|
|
# (the "License"); you may not use this file except in compliance with |
6
|
|
|
|
|
|
|
# the License. You may obtain a copy of the License at |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software |
11
|
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
12
|
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
14
|
|
|
|
|
|
|
# limitations under the License. |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
972
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
45
|
|
17
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
62
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package LucyX::Index::ByteBufDocReader; |
20
|
2
|
|
|
2
|
|
9
|
use base qw( Lucy::Index::DocReader ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
390
|
|
21
|
2
|
|
|
2
|
|
741
|
use Lucy::Document::HitDoc; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
78
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.006000_001'; |
23
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
24
|
2
|
|
|
2
|
|
8
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
775
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Inside-out member vars. |
27
|
|
|
|
|
|
|
our %width; |
28
|
|
|
|
|
|
|
our %field; |
29
|
|
|
|
|
|
|
our %instream; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
6
|
|
|
6
|
1
|
336
|
my ( $either, %args ) = @_; |
33
|
6
|
|
|
|
|
8
|
my $width = delete $args{width}; |
34
|
6
|
|
|
|
|
7
|
my $field = delete $args{field}; |
35
|
6
|
|
|
|
|
58
|
my $self = $either->SUPER::new(%args); |
36
|
6
|
50
|
|
|
|
133
|
confess("Missing required param 'width'") unless defined $width; |
37
|
6
|
50
|
|
|
|
9
|
confess("Missing required param 'field'") unless $field; |
38
|
6
|
50
|
|
|
|
11
|
if ( $width < 1 ) { confess("'width' must be at least 1") } |
|
0
|
|
|
|
|
0
|
|
39
|
6
|
|
|
|
|
12
|
$width{$$self} = $width; |
40
|
6
|
|
|
|
|
6
|
$field{$$self} = $field; |
41
|
|
|
|
|
|
|
|
42
|
6
|
|
|
|
|
13
|
my $segment = $self->get_segment; |
43
|
6
|
|
|
|
|
34
|
my $metadata = $self->get_segment->fetch_metadata("bytebufdocs"); |
44
|
6
|
50
|
|
|
|
11
|
if ($metadata) { |
45
|
6
|
50
|
|
|
|
16
|
if ( $metadata->{format} != 1 ) { |
46
|
0
|
|
|
|
|
0
|
confess("Unrecognized format: '$metadata->{format}'"); |
47
|
|
|
|
|
|
|
} |
48
|
6
|
|
|
|
|
19
|
my $filename = $segment->get_name . "/bytebufdocs.dat"; |
49
|
6
|
50
|
|
|
|
71
|
$instream{$$self} = $self->get_folder->open_in($filename) |
50
|
|
|
|
|
|
|
or confess Clownfish->error; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
18
|
return $self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub fetch_doc { |
57
|
3
|
|
|
3
|
1
|
164
|
my ( $self, $doc_id ) = @_; |
58
|
3
|
|
|
|
|
5
|
my $field = $field{$$self}; |
59
|
3
|
|
|
|
|
7
|
my %fields = ( $field => '' ); |
60
|
3
|
|
|
|
|
8
|
$self->read_record( $doc_id, \$fields{$field} ); |
61
|
3
|
|
|
|
|
66
|
return Lucy::Document::HitDoc->new( |
62
|
|
|
|
|
|
|
doc_id => $doc_id, |
63
|
|
|
|
|
|
|
fields => \%fields, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub read_record { |
68
|
24
|
|
|
24
|
0
|
17
|
my ( $self, $doc_id, $buf ) = @_; |
69
|
24
|
|
|
|
|
22
|
my $instream = $instream{$$self}; |
70
|
24
|
50
|
|
|
|
30
|
if ($instream) { |
71
|
24
|
|
|
|
|
21
|
my $width = $width{$$self}; |
72
|
24
|
|
|
|
|
46
|
$instream->seek( $width * $doc_id ); |
73
|
24
|
|
|
|
|
91
|
$instream->read( $$buf, $width ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub close { |
78
|
6
|
|
|
6
|
0
|
7
|
my $self = shift; |
79
|
6
|
|
|
|
|
9
|
delete $width{$$self}; |
80
|
6
|
|
|
|
|
35
|
delete $instream{$$self}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub DESTROY { |
84
|
6
|
|
|
6
|
|
192
|
my $self = shift; |
85
|
6
|
|
|
|
|
6
|
delete $width{$$self}; |
86
|
6
|
|
|
|
|
7
|
delete $field{$$self}; |
87
|
6
|
|
|
|
|
11
|
delete $instream{$$self}; |
88
|
6
|
|
|
|
|
537
|
$self->SUPER::DESTROY; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |