blib/lib/KinoSearch1/Index/IndexReader.pm

filter: Statementstmt 80.3% 45 / 56 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 54.1% 13 / 24 Podpod 8.3% 1 / 12 totaltotal 65.6% 63 / 96 CC 4 SCAR 5.3
CC
4
Cov
82%
__ANON__
3.0
_open_multi_or_segreader
2.0
max_doc
2.0
CRAP 1.7
« blib/lib/KinoSearch1/Search/Searchable.pm ↑ Summary blib/lib/KinoSearch1/Index/Term.pm »
1 package KinoSearch1::Index::IndexReader;
2 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 34 ▶use KinoSearch1::Util::ToolSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 34 ▶use base qw( KinoSearch1::Util::Class );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 34 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 34 __PACKAGE__->init_instance_vars(
9 # constructor params / members
10 invindex => undef,
11 seg_infos => undef,
12 close_invindex => 1,
13 invindex_owner => 1,
14 );
15 34 __PACKAGE__->ready_get(qw( invindex ));
16 }
17  
18 34 ▶use KinoSearch1::Store::FSInvIndex;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 34 ▶use KinoSearch1::Index::SegReader;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 34 ▶use KinoSearch1::Index::MultiReader;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 34 ▶use KinoSearch1::Index::SegInfos;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 34 ▶use KinoSearch1::Index::IndexFileNames qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
23 WRITE_LOCK_NAME WRITE_LOCK_TIMEOUT
24 COMMIT_LOCK_NAME COMMIT_LOCK_TIMEOUT
25 34 );
26  
27 65 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
28 65 my $temp = shift->SUPER::new(@_);
29 65 return $temp->_open_multi_or_segreader;
30 }
31  
32 # Returns a subclass of IndexReader: either a MultiReader or a SegReader,
33 # depending on whether an invindex contains more than one segment.
34 65 ▶sub _open_multi_or_segreader {
Subroutine _open_multi_or_segreader: called CC=2 SCAR=6.9
35 65 my $self = shift;
36  
37 # confirm an InvIndex object or make one using a supplied filepath.
38 65 ▶ if ( !a_isa_b( $self->{invindex}, 'KinoSearch1::Store::InvIndex' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (a_isa_b($self->{"invindex"}, "KinoSearch1::Store::InvIndex")) 1 64 65
39 $self->{invindex} = KinoSearch1::Store::FSInvIndex->new(
40 1 path => $self->{invindex} );
41 }
42 65 my $invindex = $self->{invindex};
43  
44 # read the segments file and decide what to do
45 65 my $reader;
46 $invindex->run_while_locked(
47 lock_name => COMMIT_LOCK_NAME,
48 timeout => COMMIT_LOCK_TIMEOUT,
49 65 ▶ do_body => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
50 65 my $seg_infos = KinoSearch1::Index::SegInfos->new;
51 65 $seg_infos->read_infos($invindex);
52  
53 # create a SegReader for each segment in the invindex
54 65 my @seg_readers;
55 65 for my $sinfo ( $seg_infos->infos ) {
56 94 push @seg_readers,
57 KinoSearch1::Index::SegReader->new(
58 seg_name => $sinfo->get_seg_name,
59 invindex => $invindex,
60 );
61 }
62 # if there's one SegReader use it; otherwise make a MultiReader
63 $reader
64 65 ▶ = @seg_readers == 1
Branch: 1 branch
BranchTrueFalseTotal
@seg_readers == 1 ? : 50 15 65
65 ? $seg_readers[0]
66 : KinoSearch1::Index::MultiReader->new(
67 invindex => $invindex,
68 sub_readers => \@seg_readers,
69 );
70 },
71 65 );
72  
73 65 return $reader;
74 }
75  
76 =begin comment
77  
78 my $num = $reader->max_doc;
79  
80 Return the highest document number available to the reader.
81  
82 =end comment
83 =cut
84  
85 0 ▶sub max_doc { shift->abstract_death }
Subroutine max_doc: not called CC=1 SCAR=6.9
Pod undocumented
86  
87 =begin comment
88  
89 my $num = $reader->num_docs;
90  
91 Return the number of (non-deleted) documents available to the reader.
92  
93 =end comment
94 =cut
95  
96 0 ▶sub num_docs { shift->abstract_death }
Subroutine num_docs: not called CC=1 SCAR=6.9
Pod undocumented
97  
98 =begin comment
99  
100 my $term_docs = $reader->term_docs($term);
101  
102 Given a Term, return a TermDocs subclass.
103  
104 =end comment
105 =cut
106  
107 0 ▶sub term_docs { shift->abstract_death }
Subroutine term_docs: not called CC=1 SCAR=6.9
Pod undocumented
108  
109 =begin comment
110  
111 my $norms_reader = $reader->norms_reader($field_name);
112  
113 Given a field name, return a NormsReader object.
114  
115 =end comment
116 =cut
117  
118 0 ▶sub norms_reader { shift->abstract_death }
Subroutine norms_reader: not called CC=1 SCAR=6.9
Pod undocumented
119  
120 =begin comment
121  
122 $reader->delete_docs_by_term( $term );
123  
124 Delete all the documents available to the reader that index the given Term.
125  
126 =end comment
127 =cut
128  
129 0 ▶sub delete_docs_by_term { shift->abstract_death }
Subroutine delete_docs_by_term: not called CC=1 SCAR=6.9
Pod undocumented
130  
131 =begin comment
132  
133 $boolean = $reader->has_deletions
134  
135 Return true if any documents have been marked as deleted.
136  
137 =end comment
138 =cut
139  
140 0 ▶sub has_deletions { shift->abstract_death }
Subroutine has_deletions: not called CC=1 SCAR=6.9
Pod undocumented
141  
142 =begin comment
143  
144 my $enum = $reader->terms($term);
145  
146 Given a Term, return a TermEnum subclass. The Enum will be be pre-located via
147 $enum->seek($term) to the right spot.
148  
149 =end comment
150 =cut
151  
152 0 ▶sub terms { shift->abstract_death }
Subroutine terms: not called CC=1 SCAR=6.9
Pod undocumented
153  
154 =begin comment
155  
156 my $field_names = $reader->get_field_names(
157 indexed => $indexed_fields_only,
158 );
159  
160 Return a hashref which is a list of field names. If the parameter 'indexed'
161 is true, return only the names of fields which are indexed.
162  
163 =end comment
164 =cut
165  
166 0 ▶sub get_field_names { shift->abstract_death }
Subroutine get_field_names: not called CC=1 SCAR=6.9
Pod undocumented
167  
168 =begin comment
169  
170 my $infos = $reader->generate_field_infos;
171  
172 Return a new FieldInfos object, describing all the fields held by the reader.
173 The FieldInfos object will be consolidated, and thus may not be representative
174 of every field in every segment if there are conflicting definitions.
175  
176 =end comment
177 =cut
178  
179 0 ▶sub generate_field_infos { shift->abstract_death }
Subroutine generate_field_infos: not called CC=1 SCAR=6.9
Pod undocumented
180  
181 =begin comment
182  
183 my @sparse_segreaders = $reader->segreaders_to_merge;
184 my @all_segreaders = $reader->segreaders_to_merge('all');
185  
186 Find segments which are good candidates for merging, as they don't contain
187 many valid documents. Returns an array of SegReaders. If passed an argument,
188 return all SegReaders.
189  
190 =end comment
191 =cut
192  
193 0 ▶sub segreaders_to_merge { shift->abstract_death }
Subroutine segreaders_to_merge: not called CC=1 SCAR=6.9
Pod undocumented
194  
195 =begin comment
196  
197 $reader->close;
198  
199 Release all resources.
200  
201 =end comment
202 =cut
203  
204 0 ▶sub close { shift->abstract_death }
Subroutine close: not called CC=1 SCAR=6.9
Pod undocumented
205  
206 34 1;
207  
208 __END__
« blib/lib/KinoSearch1/Search/Searchable.pm ↑ Summary blib/lib/KinoSearch1/Index/Term.pm »