Plucene/Index/SegmentsTermEnum.pm

filter: Statementstmt 93.4% 43 / 46 Branchbran 58.3% 7 / 12 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 87.5% 7 / 8 Podpod 100% 4 / 4 totaltotal 81.2% 65 / 80 CC 10 SCAR 14.3
CC
10
Cov
83%
new
6.3
next
5.2
doc_freq
2.0
CRAP 4.2
« Plucene/Search/PhraseScorer/Exact.pm ↑ Summary Plucene/Index/Writer.pm »
1 package Plucene::Index::SegmentsTermEnum;
2  
3 =head1 NAME
4  
5 Plucene::Index::SegmentsTermEnum
6  
7 =head1 METHODS
8  
9 =head2 new / term / doc_freq / next
10  
11 as per TermEnum
12  
13 =cut
14  
15 # This only appears to be used with doing wildcard searches.
16  
17 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 18 ▶use Tie::Array::Sorted;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 18 ▶use Plucene::Index::SegmentMergeInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 12 ▶sub term { $_[0]->{term} }
Subroutine term: called CC=1 SCAR=0.0
Pod documented
24 0 ▶sub doc_freq { $_[0]->{doc_freq} }
Subroutine doc_freq: not called CC=1 SCAR=6.9
Pod documented
25  
26 3 ▶sub new {
Subroutine new: called CC=6 SCAR=18.4
Pod documented
27 3 my ($class, $readers, $starts, $t) = @_;
28  
29 3 tie my @queue, "Tie::Array::Sorted";
30 3 for my $i (0 .. $#{$readers}) {
31 9 my $reader = $readers->[$i];
32 9 my $term_enum = $reader->terms($t);
33 9 my $smi =
34 Plucene::Index::SegmentMergeInfo->new($starts->[$i], $term_enum,
35 $reader);
36 9 ▶ if (!$t ? $smi->next : $term_enum->term) { # ???
Branch: 2 branches
BranchTrueFalseTotal
if (!$t ? $smi->next : $term_enum->term) 9 0 9
!$t ? : 0 9 9
37 9 push @queue, $smi;
38 }
39 }
40 3 my $self = bless { queue => \@queue }, $class;
41 3 ▶ if ($t and @queue) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t and @queue) 3 0 3
Condition33%1/3
$t and @queue
!ll&&!rl&&r
003
MC/DC0%0/2
$t and @queue
$t @queue
Truth table33%1/3
A and B
A= $tB= @queue
ABresult
0X0
100
111
42 3 my $top = $queue[0];
43 3 $self->{term} = $top->term_enum->term;
44 3 $self->{doc_freq} = $top->term_enum->doc_freq;
45 }
46 3 return $self;
47 }
48  
49 9 ▶sub next {
Subroutine next: called CC=5 SCAR=16.5
Pod documented
50 9 my $self = shift;
51 9 my $top = $self->{queue}[0];
52 9 ▶ if (!$top) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($top) 0 9 9
53 0 undef $self->{term};
54 0 return;
55 }
56  
57 9 $self->{term} = $top->term;
58 9 $self->{doc_freq} = 0;
59 9 ▶ while ($top && $self->{term}->eq($top->term)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($top and $self->{"term"}->eq($top->term)) 9 9 18
Condition66%2/3
$top and $self->{"term"}->eq($top->term)
!ll&&!rl&&r
099
MC/DC50%1/2
$top and $self->{"term"}->eq($top->term)
$top $self->{"term"}->eq($top->term)
Truth table66%2/3
A and B
A= $topB= $self->{"term"}->eq($top->term)
ABresult
0X0
100
111
60 9 $self->{doc_freq} += $top->term_enum->doc_freq;
61  
62 # This might look funny, but it's right. The pop takes $top off
63 # the queue, and when it has ->next called on it, its comparison
64 # value changes; the queue is tied as a Tie::Array::Sorted, so
65 # when it gets added back on, it may be put somewhere else.
66 9 pop @{ $self->{queue} };
67 9 ▶ if ($top->next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($top->next) 9 0 9
68 9 unshift @{ $self->{queue} }, $top;
69 }
70 9 $top = $self->{queue}[0];
71 }
72 9 return 1;
73 }
74  
75 18 1;
« Plucene/Search/PhraseScorer/Exact.pm ↑ Summary Plucene/Index/Writer.pm »