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
|
|
949
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
44
|
|
17
|
2
|
|
|
2
|
|
4
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
54
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package LucyX::Index::ByteBufDocReader; |
20
|
2
|
|
|
2
|
|
6
|
use base qw( Lucy::Index::DocReader ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
353
|
|
21
|
2
|
|
|
2
|
|
602
|
use Lucy::Document::HitDoc; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
77
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.006000_002'; |
23
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
24
|
2
|
|
|
2
|
|
7
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
835
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Inside-out member vars. |
27
|
|
|
|
|
|
|
our %width; |
28
|
|
|
|
|
|
|
our %field; |
29
|
|
|
|
|
|
|
our %instream; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
6
|
|
|
6
|
1
|
335
|
my ( $either, %args ) = @_; |
33
|
6
|
|
|
|
|
9
|
my $width = delete $args{width}; |
34
|
6
|
|
|
|
|
7
|
my $field = delete $args{field}; |
35
|
6
|
|
|
|
|
56
|
my $self = $either->SUPER::new(%args); |
36
|
6
|
50
|
|
|
|
152
|
confess("Missing required param 'width'") unless defined $width; |
37
|
6
|
50
|
|
|
|
10
|
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
|
|
|
|
|
16
|
$width{$$self} = $width; |
40
|
6
|
|
|
|
|
5
|
$field{$$self} = $field; |
41
|
|
|
|
|
|
|
|
42
|
6
|
|
|
|
|
14
|
my $segment = $self->get_segment; |
43
|
6
|
|
|
|
|
32
|
my $metadata = $self->get_segment->fetch_metadata("bytebufdocs"); |
44
|
6
|
50
|
|
|
|
12
|
if ($metadata) { |
45
|
6
|
50
|
|
|
|
15
|
if ( $metadata->{format} != 1 ) { |
46
|
0
|
|
|
|
|
0
|
confess("Unrecognized format: '$metadata->{format}'"); |
47
|
|
|
|
|
|
|
} |
48
|
6
|
|
|
|
|
18
|
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
|
|
|
|
|
19
|
return $self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub fetch_doc { |
57
|
3
|
|
|
3
|
1
|
163
|
my ( $self, $doc_id ) = @_; |
58
|
3
|
|
|
|
|
6
|
my $field = $field{$$self}; |
59
|
3
|
|
|
|
|
6
|
my %fields = ( $field => '' ); |
60
|
3
|
|
|
|
|
7
|
$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
|
21
|
my ( $self, $doc_id, $buf ) = @_; |
69
|
24
|
|
|
|
|
17
|
my $instream = $instream{$$self}; |
70
|
24
|
50
|
|
|
|
34
|
if ($instream) { |
71
|
24
|
|
|
|
|
20
|
my $width = $width{$$self}; |
72
|
24
|
|
|
|
|
43
|
$instream->seek( $width * $doc_id ); |
73
|
24
|
|
|
|
|
54
|
$instream->read( $$buf, $width ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub close { |
78
|
6
|
|
|
6
|
0
|
7
|
my $self = shift; |
79
|
6
|
|
|
|
|
7
|
delete $width{$$self}; |
80
|
6
|
|
|
|
|
35
|
delete $instream{$$self}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub DESTROY { |
84
|
6
|
|
|
6
|
|
191
|
my $self = shift; |
85
|
6
|
|
|
|
|
7
|
delete $width{$$self}; |
86
|
6
|
|
|
|
|
7
|
delete $field{$$self}; |
87
|
6
|
|
|
|
|
9
|
delete $instream{$$self}; |
88
|
6
|
|
|
|
|
586
|
$self->SUPER::DESTROY; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |