buildlib/Lucy/Build/Binding/Plan.pm

filter: Statementstmt 100% 91 / 91 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 11 totaltotal 90.4% 104 / 115 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
bind_all
1.0
CRAP 1.0
« buildlib/Lucy/Build/Binding/Search.pm ↑ Summary buildlib/Lucy/Build/Binding/Object.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 package Lucy::Build::Binding::Plan;
16 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 our $VERSION = '0.008000';
20 1 $VERSION = eval $VERSION;
21  
22 1 ▶sub bind_all {
Subroutine bind_all: called CC=1 SCAR=0.0
Pod undocumented
23 1 my $class = shift;
24 1 $class->bind_architecture;
25 1 $class->bind_blobtype;
26 1 $class->bind_fieldtype;
27 1 $class->bind_float32type;
28 1 $class->bind_float64type;
29 1 $class->bind_fulltexttype;
30 1 $class->bind_int32type;
31 1 $class->bind_int64type;
32 1 $class->bind_schema;
33 1 $class->bind_stringtype;
34 }
35  
36 1 ▶sub bind_architecture {
Subroutine bind_architecture: called CC=1 SCAR=0.0
Pod undocumented
37 1 my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
38 1 my $synopsis = <<'END_SYNOPSIS';
39 package MyArchitecture;
40 use base qw( Lucy::Plan::Architecture );
41  
42 use LucyX::Index::ZlibDocWriter;
43 use LucyX::Index::ZlibDocReader;
44  
45 sub register_doc_writer {
46 my ( $self, $seg_writer ) = @_;
47 my $doc_writer = LucyX::Index::ZlibDocWriter->new(
48 snapshot => $seg_writer->get_snapshot,
49 segment => $seg_writer->get_segment,
50 polyreader => $seg_writer->get_polyreader,
51 );
52 $seg_writer->register(
53 api => "Lucy::Index::DocReader",
54 component => $doc_writer,
55 );
56 $seg_writer->add_writer($doc_writer);
57 }
58  
59 sub register_doc_reader {
60 my ( $self, $seg_reader ) = @_;
61 my $doc_reader = LucyX::Index::ZlibDocReader->new(
62 schema => $seg_reader->get_schema,
63 folder => $seg_reader->get_folder,
64 segments => $seg_reader->get_segments,
65 seg_tick => $seg_reader->get_seg_tick,
66 snapshot => $seg_reader->get_snapshot,
67 );
68 $seg_reader->register(
69 api => 'Lucy::Index::DocReader',
70 component => $doc_reader,
71 );
72 }
73
74 package MySchema;
75 use base qw( Lucy::Plan::Schema );
76
77 sub architecture {
78 shift;
79 return MyArchitecture->new(@_);
80 }
81 END_SYNOPSIS
82 1 my $constructor = <<'END_CONSTRUCTOR';
83 my $arch = Lucy::Plan::Architecture->new;
84 END_CONSTRUCTOR
85 1 $pod_spec->set_synopsis($synopsis);
86 1 $pod_spec->add_constructor( alias => 'new', sample => $constructor, );
87  
88 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
89 parcel => "Lucy",
90 class_name => "Lucy::Plan::Architecture",
91 );
92 1 $binding->set_pod_spec($pod_spec);
93  
94 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
95 }
96  
97 1 ▶sub bind_blobtype {
Subroutine bind_blobtype: called CC=1 SCAR=0.0
Pod undocumented
98 1 my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
99 1 my $synopsis = <<'END_SYNOPSIS';
100 my $string_type = Lucy::Plan::StringType->new;
101 my $blob_type = Lucy::Plan::BlobType->new( stored => 1 );
102 my $schema = Lucy::Plan::Schema->new;
103 $schema->spec_field( name => 'id', type => $string_type );
104 $schema->spec_field( name => 'jpeg', type => $blob_type );
105 END_SYNOPSIS
106 1 my $constructor = <<'END_CONSTRUCTOR';
107 my $blob_type = Lucy::Plan::BlobType->new(
108 stored => 1, # default: false
109 );
110 END_CONSTRUCTOR
111 1 $pod_spec->set_synopsis($synopsis);
112 1 $pod_spec->add_constructor( alias => 'new', sample => $constructor, );
113  
114 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
115 parcel => "Lucy",
116 class_name => "Lucy::Plan::BlobType",
117 );
118 1 $binding->set_pod_spec($pod_spec);
119 1 $binding->add_class_alias('KinoSearch::Plan::BlobType');
120 1 $binding->add_class_alias('KinoSearch::FieldType::BlobType');
121  
122 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
123 }
124  
125 1 ▶sub bind_fieldtype {
Subroutine bind_fieldtype: called CC=1 SCAR=0.0
Pod undocumented
126 1 my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
127 1 my $synopsis = <<'END_SYNOPSIS';
128 my @sortable;
129 for my $field ( @{ $schema->all_fields } ) {
130 my $type = $schema->fetch_type($field);
131 next unless $type->sortable;
132 push @sortable, $field;
133 }
134 END_SYNOPSIS
135 1 $pod_spec->set_synopsis($synopsis);
136  
137 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
138 parcel => "Lucy",
139 class_name => "Lucy::Plan::FieldType",
140 );
141 1 $binding->bind_constructor( alias => 'new', initializer => 'init2' );
142 1 $binding->set_pod_spec($pod_spec);
143 1 $binding->add_class_alias("KinoSearch::Plan::FieldType");
144 1 $binding->add_class_alias("KinoSearch::FieldType");
145  
146 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
147 }
148  
149 1 ▶sub bind_float32type {
Subroutine bind_float32type: called CC=1 SCAR=0.0
Pod undocumented
150 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
151 parcel => "Lucy",
152 class_name => "Lucy::Plan::Float32Type",
153 );
154 1 $binding->bind_constructor( alias => 'new', initializer => 'init2' );
155 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
156 }
157  
158 1 ▶sub bind_float64type {
Subroutine bind_float64type: called CC=1 SCAR=0.0
Pod undocumented
159 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
160 parcel => "Lucy",
161 class_name => "Lucy::Plan::Float64Type",
162 );
163 1 $binding->bind_constructor( alias => 'new', initializer => 'init2' );
164 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
165 }
166  
167 1 ▶sub bind_fulltexttype {
Subroutine bind_fulltexttype: called CC=1 SCAR=0.0
Pod undocumented
168 1 my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
169 1 my $synopsis = <<'END_SYNOPSIS';
170 my $easyanalyzer = Lucy::Analysis::EasyAnalyzer->new(
171 language => 'en',
172 );
173 my $type = Lucy::Plan::FullTextType->new(
174 analyzer => $easyanalyzer,
175 );
176 my $schema = Lucy::Plan::Schema->new;
177 $schema->spec_field( name => 'title', type => $type );
178 $schema->spec_field( name => 'content', type => $type );
179 END_SYNOPSIS
180 1 my $constructor = <<'END_CONSTRUCTOR';
181 my $type = Lucy::Plan::FullTextType->new(
182 analyzer => $analyzer, # required
183 boost => 2.0, # default: 1.0
184 indexed => 1, # default: true
185 stored => 1, # default: true
186 sortable => 1, # default: false
187 highlightable => 1, # default: false
188 );
189 END_CONSTRUCTOR
190 1 $pod_spec->set_synopsis($synopsis);
191 1 $pod_spec->add_constructor(
192 alias => 'new',
193 pod_func => 'init2',
194 sample => $constructor,
195 );
196  
197 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
198 parcel => "Lucy",
199 class_name => "Lucy::Plan::FullTextType",
200 );
201 1 $binding->bind_constructor( alias => 'new', initializer => 'init2' );
202 1 $binding->set_pod_spec($pod_spec);
203 1 $binding->add_class_alias('KinoSearch::Plan::FullTextType');
204 1 $binding->add_class_alias('KinoSearch::FieldType::FullTextType');
205  
206 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
207 }
208  
209 1 ▶sub bind_int32type {
Subroutine bind_int32type: called CC=1 SCAR=0.0
Pod undocumented
210 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
211 parcel => "Lucy",
212 class_name => "Lucy::Plan::Int32Type",
213 );
214 1 $binding->bind_constructor( alias => 'new', initializer => 'init2' );
215 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
216 }
217  
218 1 ▶sub bind_int64type {
Subroutine bind_int64type: called CC=1 SCAR=0.0
Pod undocumented
219 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
220 parcel => "Lucy",
221 class_name => "Lucy::Plan::Int64Type",
222 );
223 1 $binding->bind_constructor( alias => 'new', initializer => 'init2' );
224 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
225 }
226  
227 1 ▶sub bind_schema {
Subroutine bind_schema: called CC=1 SCAR=0.0
Pod undocumented
228 1 my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
229 1 my $synopsis = <<'END_SYNOPSIS';
230 use Lucy::Plan::Schema;
231 use Lucy::Plan::FullTextType;
232 use Lucy::Analysis::EasyAnalyzer;
233
234 my $schema = Lucy::Plan::Schema->new;
235 my $easyanalyzer = Lucy::Analysis::EasyAnalyzer->new(
236 language => 'en',
237 );
238 my $type = Lucy::Plan::FullTextType->new(
239 analyzer => $easyanalyzer,
240 );
241 $schema->spec_field( name => 'title', type => $type );
242 $schema->spec_field( name => 'content', type => $type );
243 END_SYNOPSIS
244 1 my $constructor = <<'END_CONSTRUCTOR';
245 my $schema = Lucy::Plan::Schema->new;
246 END_CONSTRUCTOR
247 1 $pod_spec->set_synopsis($synopsis);
248 1 $pod_spec->add_constructor( alias => 'new', sample => $constructor, );
249  
250 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
251 parcel => "Lucy",
252 class_name => "Lucy::Plan::Schema",
253 );
254 1 $binding->set_pod_spec($pod_spec);
255 1 $binding->add_class_alias("KinoSearch::Plan::Schema");
256 1 $binding->add_class_alias("KinoSearch::Schema");
257  
258 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
259 }
260  
261 1 ▶sub bind_stringtype {
Subroutine bind_stringtype: called CC=1 SCAR=0.0
Pod undocumented
262 1 my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
263 1 my $synopsis = <<'END_SYNOPSIS';
264 my $type = Lucy::Plan::StringType->new;
265 my $schema = Lucy::Plan::Schema->new;
266 $schema->spec_field( name => 'category', type => $type );
267 END_SYNOPSIS
268 1 my $constructor = <<'END_CONSTRUCTOR';
269 my $type = Lucy::Plan::StringType->new(
270 boost => 0.1, # default: 1.0
271 indexed => 1, # default: true
272 stored => 1, # default: true
273 sortable => 1, # default: false
274 );
275 END_CONSTRUCTOR
276 1 $pod_spec->set_synopsis($synopsis);
277 1 $pod_spec->add_constructor(
278 alias => 'new',
279 pod_func => 'init2',
280 sample => $constructor,
281 );
282  
283 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
284 parcel => "Lucy",
285 class_name => "Lucy::Plan::StringType",
286 );
287 1 $binding->bind_constructor( alias => 'new', initializer => 'init2' );
288 1 $binding->set_pod_spec($pod_spec);
289 1 $binding->add_class_alias('KinoSearch::Plan::StringType');
290 1 $binding->add_class_alias('KinoSearch::FieldType::StringType');
291  
292 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
293 }
294  
295 1 1;
« buildlib/Lucy/Build/Binding/Search.pm ↑ Summary buildlib/Lucy/Build/Binding/Object.pm »