blib/lib/KinoSearch1/Search/TermQuery.pm

filter: Statementstmt 86.8% 53 / 61 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.0% 17 / 20 Podpod 16.6% 1 / 6 totaltotal 78.9% 75 / 95 CC 5 SCAR 6.1
CC
5
Cov
83%
to_string
6.0
scorer
3.0
init_instance
2.1
CRAP 1.8
« blib/lib/KinoSearch1/Index/CompoundFileReader.pm ↑ Summary blib/lib/KinoSearch1/Search/Hit.pm »
1 package KinoSearch1::Search::TermQuery;
2 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use KinoSearch1::Util::ToolSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use base qw( KinoSearch1::Search::Query );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 18 ▶use KinoSearch1::Util::ToStringUtils qw( boost_to_string );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 18 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 __PACKAGE__->init_instance_vars(
11 # constructor params / members
12 term => undef,
13 );
14 18 __PACKAGE__->ready_get(qw( term ));
15 }
16  
17 476 ▶sub init_instance {
Subroutine init_instance: called CC=2 SCAR=7.2
Pod documented
18 476 my $self = shift;
19 confess("parameter 'term' is not a KinoSearch1::Index::Term")
20 476 ▶ unless a_isa_b( $self->{term}, 'KinoSearch1::Index::Term' );
Branch: 1 branch
BranchTrueFalseTotal
unless a_isa_b($self->{"term"}, "KinoSearch1::Index::Term") 0 476 476
21 }
22  
23 483 ▶sub create_weight {
Subroutine create_weight: called CC=1 SCAR=0.0
Pod undocumented
24 483 my ( $self, $searcher ) = @_;
25 483 my $weight = KinoSearch1::Search::TermWeight->new(
26 parent => $self,
27 searcher => $searcher,
28 );
29 }
30  
31 6 ▶sub extract_terms { shift->{term} }
Subroutine extract_terms: called CC=1 SCAR=0.0
Pod undocumented
32  
33 0 ▶sub to_string {
Subroutine to_string: not called CC=2 SCAR=17.9
Pod undocumented
34 0 my ( $self, $proposed_field ) = @_;
35 0 my $field = $self->{term}->get_field;
36 0 ▶ my $string = $proposed_field eq $field ? '' : "$field:";
Branch: 1 branch
BranchTrueFalseTotal
$proposed_field eq $field ? : 0 0 0
37 0 $string .= $self->{term}->get_text . boost_to_string( $self->{boost} );
38 0 return $string;
39  
40 }
41  
42 551 ▶sub get_similarity {
Subroutine get_similarity: called CC=1 SCAR=0.0
Pod undocumented
43 551 my ( $self, $searcher ) = @_;
44 551 my $field_name = $self->{term}->get_field;
45 551 return $searcher->get_similarity($field_name);
46 }
47  
48 0 ▶sub equals { shift->todo_death }
Subroutine equals: not called CC=1 SCAR=6.9
Pod undocumented
49  
50 package KinoSearch1::Search::TermWeight;
51 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 18 ▶use KinoSearch1::Util::ToolSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 18 ▶use base qw( KinoSearch1::Search::Weight );
Subroutine BEGIN: called CC=1 SCAR=0.0
55  
56 18 ▶use KinoSearch1::Search::TermScorer;
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58 18 our %instance_vars = __PACKAGE__->init_instance_vars();
59  
60 483 ▶sub init_instance {
Subroutine init_instance: called CC=1 SCAR=0.0
61 483 my $self = shift;
62  
63 $self->{similarity}
64 483 = $self->{parent}->get_similarity( $self->{searcher} );
65  
66 $self->{idf} = $self->{similarity}
67 483 ->idf( $self->{parent}->get_term, $self->{searcher} );
68  
69 # kill this because we don't want its baggage.
70 483 undef $self->{searcher};
71 }
72  
73 481 ▶sub scorer {
Subroutine scorer: called CC=3 SCAR=11.0
74 481 my ( $self, $reader ) = @_;
75 481 my $term = $self->{parent}{term};
76 481 my $term_docs = $reader->term_docs($term);
77 481 ▶ return unless defined $term_docs;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $term_docs 0 481 481
78 481 ▶ return unless $term_docs->get_doc_freq;
Branch: 1 branch
BranchTrueFalseTotal
unless $term_docs->get_doc_freq 65 416 481
79  
80 416 my $norms_reader = $reader->norms_reader( $term->get_field );
81 return KinoSearch1::Search::TermScorer->new(
82 weight => $self,
83 term_docs => $term_docs,
84 similarity => $self->{similarity},
85 416 norms_reader => $norms_reader,
86 );
87 }
88  
89 0 ▶sub to_string {
Subroutine to_string: not called CC=1 SCAR=6.9
90 0 my $self = shift;
91 0 return "weight(" . $self->{parent}->to_string . ")";
92 }
93  
94 18 1;
95  
96 __END__
« blib/lib/KinoSearch1/Index/CompoundFileReader.pm ↑ Summary blib/lib/KinoSearch1/Search/Hit.pm »