blib/lib/Lucy.pm

filter: Statementstmt 89.9% 170 / 189 Branchbran 50.0% 13 / 26 Conditioncond 27.2% 3 / 11 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 88.3% 38 / 43 Podpod 50.0% 7 / 14 totaltotal 80.2% 232 / 289 CC 19 SCAR 10.5
CC
19
Cov
82%
new
8.7
lexicon
6.0
posting_list
6.0
CRAP 2.8
« blib/lib/LucyX/Index/ByteBufDocWriter.pm ↑ Summary blib/lib/LucyX/Search/MockMatcher.pm »
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 150 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 150 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 package Lucy;
20  
21 150 ▶use 5.008003;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 150 our $VERSION = '0.008000';
24 150 $VERSION = eval $VERSION;
25 150 our $MAJOR_VERSION = 0.008000;
26  
27 150 ▶use Clownfish 0.008000;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 150 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.6
29 150 ▶ die <<"EOF" if $Clownfish::MAJOR_VERSION > 0.008000;
Branch: 1 branch
BranchTrueFalseTotal
if $Clownfish::MAJOR_VERSION > "0.008" 0 150 150
30 This version of Lucy doesn't support Clownfish $Clownfish::MAJOR_VERSION or
31 higher. You should downgrade Clownfish or, if possible, upgrade Lucy.
32 EOF
33 }
34  
35 150 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
36 150 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
37 150 our @EXPORT_OK = qw(
38 STORABLE_freeze
39 STORABLE_thaw
40 );
41 }
42  
43 # On most UNIX variants, this flag makes DynaLoader pass RTLD_GLOBAL to
44 # dl_open, so extensions can resolve the needed symbols without explicitly
45 # linking against the DSO.
46 150 ▶sub dl_load_flags { 1 }
Subroutine dl_load_flags: called CC=1 SCAR=0.0
Pod documented
47  
48 150 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
49 150 require DynaLoader;
50 150 our @ISA = qw( DynaLoader );
51 # This loads a large number of disparate subs.
52 150 bootstrap Lucy '0.8.0';
53 }
54  
55 {
56 package Lucy::Util::IndexFileNames;
57 150 our $VERSION = '0.008000';
58 150 $VERSION = eval $VERSION;
59 150 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
60 150 push our @ISA, 'Exporter';
61 150 our @EXPORT_OK = qw(
62 extract_gen
63 latest_snapshot
64 );
65 }
66 }
67  
68 {
69 # Temporary back compat.
70 150 package Lucy::Object::Obj;
71 150 ▶ BEGIN { our @ISA = qw( Clownfish::Obj ) }
Subroutine BEGIN: called CC=1 SCAR=0.0
72 }
73  
74 {
75 150 package Lucy::Analysis::RegexTokenizer;
76 150 our $VERSION = '0.008000';
77 150 $VERSION = eval $VERSION;
78  
79 31 ▶ sub _compile_token_re {qr/$_[0]/}
Subroutine _compile_token_re: called CC=1 SCAR=0.0
80  
81 13 ▶ sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
82 13 my ( $either, %args ) = @_;
83 13 my $token_re = delete $args{token_re};
84 13 ▶ $args{pattern} = "$token_re" if $token_re;
Branch: 1 branch
BranchTrueFalseTotal
if $token_re 2 11 13
85 13 return $either->_new(%args);
86 }
87 }
88  
89 {
90 150 package Lucy::Document::Doc;
91 150 our $VERSION = '0.008000';
92 150 $VERSION = eval $VERSION;
93 150 ▶ use Storable (); # Needed by serialize/deserialize.
Subroutine BEGIN: called CC=1 SCAR=0.0
94 150 ▶ use Lucy qw( STORABLE_freeze STORABLE_thaw );
Subroutine BEGIN: called CC=1 SCAR=0.0
95  
96 use overload
97 150 ▶ fallback => 1,
Subroutine BEGIN: called CC=1 SCAR=0.0
98 150 '%{}' => \&get_fields;
99 }
100  
101 {
102 150 package Lucy::Index::DocVector;
103 150 our $VERSION = '0.008000';
104 150 $VERSION = eval $VERSION;
105 150 ▶ use Lucy qw( STORABLE_freeze STORABLE_thaw );
Subroutine BEGIN: called CC=1 SCAR=0.0
106 }
107  
108 {
109 150 package Lucy::Index::Indexer;
110 150 our $VERSION = '0.008000';
111 150 $VERSION = eval $VERSION;
112  
113 311 ▶ sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
114 311 my ( $either, %args ) = @_;
115 311 my $flags = 0;
116 311 ▶ $flags |= CREATE if delete $args{'create'};
Branch: 1 branch
BranchTrueFalseTotal
if delete $args{"create"} 7 304 311
117 311 ▶ $flags |= TRUNCATE if delete $args{'truncate'};
Branch: 1 branch
BranchTrueFalseTotal
if delete $args{"truncate"} 4 307 311
118 311 return $either->_new( %args, flags => $flags );
119 }
120 }
121  
122 {
123 150 package Lucy::Index::IndexReader;
124 150 our $VERSION = '0.008000';
125 150 $VERSION = eval $VERSION;
126 150 ▶ use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
127  
128 0 ▶ sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
129 0 confess(
130 "IndexReader is an abstract class; use open() instead of new()");
131 }
132 0 ▶ sub lexicon {
Subroutine lexicon: not called CC=2 SCAR=17.9
Pod undocumented
133 0 my $self = shift;
134 0 my $lex_reader = $self->fetch("Lucy::Index::LexiconReader");
135 0 ▶ return $lex_reader->lexicon(@_) if $lex_reader;
Branch: 1 branch
BranchTrueFalseTotal
if $lex_reader 0 0 0
136 0 return;
137 }
138 0 ▶ sub posting_list {
Subroutine posting_list: not called CC=2 SCAR=17.9
Pod undocumented
139 0 my $self = shift;
140 0 my $plist_reader = $self->fetch("Lucy::Index::PostingListReader");
141 0 ▶ return $plist_reader->posting_list(@_) if $plist_reader;
Branch: 1 branch
BranchTrueFalseTotal
if $plist_reader 0 0 0
142 0 return;
143 }
144 1 ▶ sub offsets { shift->_offsets->to_arrayref }
Subroutine offsets: called CC=1 SCAR=0.0
Pod documented
145 }
146  
147 {
148 150 package Lucy::Index::Similarity;
149 150 our $VERSION = '0.008000';
150 150 $VERSION = eval $VERSION;
151 150 ▶ use Lucy qw( STORABLE_freeze STORABLE_thaw );
Subroutine BEGIN: called CC=1 SCAR=0.0
152 }
153  
154 {
155 150 package Lucy::Index::TermVector;
156 150 our $VERSION = '0.008000';
157 150 $VERSION = eval $VERSION;
158 150 ▶ use Lucy qw( STORABLE_freeze STORABLE_thaw );
Subroutine BEGIN: called CC=1 SCAR=0.0
159 }
160  
161 {
162 150 package Lucy::Search::Compiler;
163 150 our $VERSION = '0.008000';
164 150 $VERSION = eval $VERSION;
165 150 ▶ use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
166 150 ▶ use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
167  
168 506 ▶ sub new {
Subroutine new: called CC=4 SCAR=21.7
Pod documented
169 506 my ( $either, %args ) = @_;
170 506 ▶ if ( !defined $args{boost} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"boost"}) 0 506 506
171 confess("'parent' is not a Query")
172 unless ( blessed( $args{parent} )
173 0 ▶ and $args{parent}->isa("Lucy::Search::Query") );
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($args{"parent"}) and $args{"parent"}->isa("Lucy::Search::Query") 0 0 0
Condition0%0/3
builtin::blessed($args{"parent"}) and $args{"parent"}->isa("Lucy::Search::Query")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($args{"parent"}) and $args{"parent"}->isa("Lucy::Search::Query")
builtin::blessed($args{"parent"}) $args{"parent"}->isa("Lucy::Search::Query")
Truth table0%0/3
A and B
A= builtin::blessed($args{"parent"})B= $args{"parent"}->isa("Lucy::Search::Query")
ABresult
0X0
100
111
174 0 $args{boost} = $args{parent}->get_boost;
175 }
176 506 return $either->do_new(%args);
177 }
178 }
179  
180 {
181 150 package Lucy::Search::MatchDoc;
182 150 our $VERSION = '0.008000';
183 150 $VERSION = eval $VERSION;
184 150 ▶ use Lucy qw( STORABLE_freeze STORABLE_thaw );
Subroutine BEGIN: called CC=1 SCAR=0.0
185 }
186  
187 {
188 150 package Lucy::Search::Query;
189 150 our $VERSION = '0.008000';
190 150 $VERSION = eval $VERSION;
191 150 ▶ use Lucy qw( STORABLE_freeze STORABLE_thaw );
Subroutine BEGIN: called CC=1 SCAR=0.0
192 }
193  
194 {
195 150 package Lucy::Search::SortRule;
196 150 our $VERSION = '0.008000';
197 150 $VERSION = eval $VERSION;
198 150 ▶ use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
199 150 ▶ use Lucy qw( STORABLE_freeze STORABLE_thaw );
Subroutine BEGIN: called CC=1 SCAR=0.0
200  
201 150 my %types = (
202 field => FIELD(),
203 score => SCORE(),
204 doc_id => DOC_ID(),
205 );
206  
207 28 ▶ sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
208 28 my ( $either, %args ) = @_;
209 28 ▶ my $type = delete $args{type} || 'field';
Condition100%2/2
delete $args{'type'} || 'field'
l!l
1315
MC/DC100%1/1
delete $args{'type'} || 'field'
delete $args{'type'}
Truth table100%2/2
A
A= delete $args{'type'}
Aresult
11
00
210 28 ▶ confess("Invalid type: '$type'") unless defined $types{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $types{$type} 0 28 28
211 28 return $either->_new( %args, type => $types{$type} );
212 }
213 }
214  
215 {
216 150 package Lucy::Search::SortSpec;
217 150 our $VERSION = '0.008000';
218 150 $VERSION = eval $VERSION;
219 150 ▶ use Lucy qw( STORABLE_freeze STORABLE_thaw );
Subroutine BEGIN: called CC=1 SCAR=0.0
220 }
221  
222 {
223 150 package Lucy::Search::TopDocs;
224 150 our $VERSION = '0.008000';
225 150 $VERSION = eval $VERSION;
226 150 ▶ use Lucy qw( STORABLE_freeze STORABLE_thaw );
Subroutine BEGIN: called CC=1 SCAR=0.0
227 }
228  
229 {
230 150 package Lucy::Object::BitVector;
231 150 our $VERSION = '0.008000';
232 150 $VERSION = eval $VERSION;
233 29 ▶ sub to_arrayref { shift->to_array->to_arrayref }
Subroutine to_arrayref: called CC=1 SCAR=0.0
Pod undocumented
234 }
235  
236 {
237 150 package Lucy::Store::FileHandle;
238 150 our $VERSION = '0.008000';
239 150 $VERSION = eval $VERSION;
240 150 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
241 150 push our @ISA, 'Exporter';
242 150 our @EXPORT_OK = qw( build_fh_flags );
243 }
244  
245 3 ▶ sub build_fh_flags {
Subroutine build_fh_flags: called CC=5 SCAR=17.0
Pod undocumented
246 3 my $args = shift;
247 3 my $flags = 0;
248 3 ▶ $flags |= FH_CREATE if delete $args->{create};
Branch: 1 branch
BranchTrueFalseTotal
if delete $args->{"create"} 3 0 3
249 3 ▶ $flags |= FH_READ_ONLY if delete $args->{read_only};
Branch: 1 branch
BranchTrueFalseTotal
if delete $args->{"read_only"} 0 3 3
250 3 ▶ $flags |= FH_WRITE_ONLY if delete $args->{write_only};
Branch: 1 branch
BranchTrueFalseTotal
if delete $args->{"write_only"} 3 0 3
251 3 ▶ $flags |= FH_EXCLUSIVE if delete $args->{exclusive};
Branch: 1 branch
BranchTrueFalseTotal
if delete $args->{"exclusive"} 3 0 3
252 3 return $flags;
253 }
254  
255 0 ▶ sub open {
Subroutine open: not called CC=2 SCAR=17.9
Pod undocumented
256 0 my ( $either, %args ) = @_;
257 0 ▶ $args{flags} ||= 0;
Condition0%0/2
$args{"flags"} ||= 0
l!l
00
MC/DC0%0/1
$args{"flags"} ||= 0
$args{"flags"}
Truth table0%0/2
A
A= $args{"flags"}
Aresult
11
00
258 0 $args{flags} |= build_fh_flags( \%args );
259 0 return $either->_open(%args);
260 }
261 }
262  
263 {
264 150 package Lucy::Store::FSFileHandle;
265 150 our $VERSION = '0.008000';
266 150 $VERSION = eval $VERSION;
267  
268 3 ▶ sub open {
Subroutine open: called CC=2 SCAR=7.0
Pod undocumented
269 3 my ( $either, %args ) = @_;
270 3 ▶ $args{flags} ||= 0;
Condition50%1/2
$args{"flags"} ||= 0
l!l
03
MC/DC0%0/1
$args{"flags"} ||= 0
$args{"flags"}
Truth table50%1/2
A
A= $args{"flags"}
Aresult
11
00
271 3 $args{flags} |= Lucy::Store::FileHandle::build_fh_flags( \%args );
272 3 return $either->_open(%args);
273 }
274 }
275  
276 {
277 150 package Lucy::Store::RAMFileHandle;
278 150 our $VERSION = '0.008000';
279 150 $VERSION = eval $VERSION;
280  
281 0 ▶ sub open {
Subroutine open: not called CC=2 SCAR=17.9
Pod undocumented
282 0 my ( $either, %args ) = @_;
283 0 ▶ $args{flags} ||= 0;
Condition0%0/2
$args{"flags"} ||= 0
l!l
00
MC/DC0%0/1
$args{"flags"} ||= 0
$args{"flags"}
Truth table0%0/2
A
A= $args{"flags"}
Aresult
11
00
284 0 $args{flags} |= Lucy::Store::FileHandle::build_fh_flags( \%args );
285 0 return $either->_open(%args);
286 }
287 }
288  
289 {
290 150 package Lucy::Util::Debug;
291 150 our $VERSION = '0.008000';
292 150 $VERSION = eval $VERSION;
293 150 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
294 150 push our @ISA, 'Exporter';
295 150 our @EXPORT_OK = qw(
296 DEBUG
297 DEBUG_PRINT
298 DEBUG_ENABLED
299 ASSERT
300 set_env_cache
301 num_allocated
302 num_freed
303 num_globals
304 );
305 }
306 }
307  
308 {
309 150 package Lucy::Util::StringHelper;
310 150 our $VERSION = '0.008000';
311 150 $VERSION = eval $VERSION;
312 150 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
313 150 push our @ISA, 'Exporter';
314 150 our @EXPORT_OK = qw(
315 utf8_flag_on
316 utf8_flag_off
317 to_base36
318 utf8ify
319 utf8_valid
320 cat_bytes
321 );
322 }
323 }
324  
325 150 1;
326  
327 __END__
« blib/lib/LucyX/Index/ByteBufDocWriter.pm ↑ Summary blib/lib/LucyX/Search/MockMatcher.pm »