blib/lib/KinoSearch1/Document/Doc.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 93.3% 14 / 15 Podpod 40.0% 4 / 10 totaltotal 84.1% 53 / 63 CC 4 SCAR 3.3
CC
4
Cov
92%
set_value
2.0
add_field
2.0
set_analyzer
2.0
CRAP 1.4
« blib/lib/KinoSearch1/Search/QueryFilter.pm ↑ Summary blib/lib/KinoSearch1/Index/NormsReader.pm »
1 package KinoSearch1::Document::Doc;
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 # special member - used to keep track of boost
10 _kino_boost => 1,
11 );
12 }
13  
14 15358 ▶sub set_value {
Subroutine set_value: called CC=2 SCAR=7.1
Pod documented
15 15358 my ( $self, $field_name, $value ) = @_;
16 15358 ▶ carp("undef supplied to set_value") unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 15358 15358
17 15358 $self->{$field_name}->set_value($value);
18 }
19  
20 3 ▶sub get_value {
Subroutine get_value: called CC=1 SCAR=0.0
Pod documented
21 3 return $_[0]->{ $_[1] }->get_value;
22 }
23  
24 1 ▶sub get_field { $_[0]->{ $_[1] } }
Subroutine get_field: called CC=1 SCAR=0.0
Pod undocumented
25  
26 1 ▶sub boost_field {
Subroutine boost_field: called CC=1 SCAR=0.0
Pod undocumented
27 1 $_[0]->{ $_[1] }->set_boost( $_[2] );
28 }
29  
30 1 ▶sub set_boost { $_[0]->{_kino_boost} = $_[1] }
Subroutine set_boost: called CC=1 SCAR=0.0
Pod documented
31 14017 ▶sub get_boost { $_[0]->{_kino_boost} }
Subroutine get_boost: called CC=1 SCAR=0.0
Pod documented
32  
33 # set the analyzer for a field
34 0 ▶sub set_analyzer {
Subroutine set_analyzer: not called CC=1 SCAR=6.9
Pod undocumented
35 0 $_[0]->{ $_[1] }->set_analyzer( $_[2] );
36 }
37  
38 248 ▶sub add_field {
Subroutine add_field: called CC=2 SCAR=7.1
Pod undocumented
39 248 my ( $self, $field ) = @_;
40 248 ▶ croak("argument to add_field must be a KinoSearch1::Document::Field")
Branch: 1 branch
BranchTrueFalseTotal
unless $field->isa("KinoSearch1::Document::Field") 0 248 248
41 unless $field->isa('KinoSearch1::Document::Field');
42 248 $self->{ $field->get_name } = $field;
43 }
44  
45 # retrieve all fields
46 42114 ▶sub get_fields {
Subroutine get_fields: called CC=1 SCAR=0.0
Pod undocumented
47 42114 return grep {ref} values %{ $_[0] };
48 }
49  
50 # Return the doc as a hashref, with the field names as hash keys and the
51 # field # values as values.
52 43 ▶sub to_hashref {
Subroutine to_hashref: called CC=2 SCAR=6.9
Pod undocumented
53 43 my $self = shift;
54 43 my %hash;
55 43 $hash{ $_->get_name } = $_->get_value for grep {ref} values %$self;
56 43 return \%hash;
57 }
58  
59 34 1;
60  
61 __END__
« blib/lib/KinoSearch1/Search/QueryFilter.pm ↑ Summary blib/lib/KinoSearch1/Index/NormsReader.pm »