line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
18
|
|
98
|
use strict; |
|
18
|
|
|
|
|
211
|
|
|
18
|
|
|
|
|
600
|
|
18
|
18
|
|
|
18
|
|
90
|
use warnings; |
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
420
|
|
19
|
|
|
|
|
|
|
|
20
|
18
|
|
|
18
|
|
22569
|
use Tie::Array::Sorted; |
|
18
|
|
|
|
|
63101
|
|
|
18
|
|
|
|
|
517
|
|
21
|
18
|
|
|
18
|
|
11716
|
use Plucene::Index::SegmentMergeInfo; |
|
18
|
|
|
|
|
148
|
|
|
18
|
|
|
|
|
151
|
|
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
4
|
1
|
14
|
sub term { $_[0]->{term} } |
24
|
0
|
|
|
0
|
1
|
0
|
sub doc_freq { $_[0]->{doc_freq} } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
1
|
|
|
1
|
1
|
4
|
my ($class, $readers, $starts, $t) = @_; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
12
|
tie my @queue, "Tie::Array::Sorted"; |
30
|
1
|
|
|
|
|
17
|
for my $i (0 .. $#{$readers}) { |
|
1
|
|
|
|
|
6
|
|
31
|
3
|
|
|
|
|
48
|
my $reader = $readers->[$i]; |
32
|
3
|
|
|
|
|
25
|
my $term_enum = $reader->terms($t); |
33
|
3
|
|
|
|
|
44
|
my $smi = |
34
|
|
|
|
|
|
|
Plucene::Index::SegmentMergeInfo->new($starts->[$i], $term_enum, |
35
|
|
|
|
|
|
|
$reader); |
36
|
3
|
50
|
|
|
|
25
|
if (!$t ? $smi->next : $term_enum->term) { # ??? |
|
|
50
|
|
|
|
|
|
37
|
3
|
|
|
|
|
41
|
push @queue, $smi; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
1
|
|
|
|
|
24
|
my $self = bless { queue => \@queue }, $class; |
41
|
1
|
50
|
33
|
|
|
13
|
if ($t and @queue) { |
42
|
1
|
|
|
|
|
15
|
my $top = $queue[0]; |
43
|
1
|
|
|
|
|
12
|
$self->{term} = $top->term_enum->term; |
44
|
1
|
|
|
|
|
23
|
$self->{doc_freq} = $top->term_enum->doc_freq; |
45
|
|
|
|
|
|
|
} |
46
|
1
|
|
|
|
|
14
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub next { |
50
|
3
|
|
|
3
|
1
|
48
|
my $self = shift; |
51
|
3
|
|
|
|
|
15
|
my $top = $self->{queue}[0]; |
52
|
3
|
50
|
|
|
|
23
|
if (!$top) { |
53
|
0
|
|
|
|
|
0
|
undef $self->{term}; |
54
|
0
|
|
|
|
|
0
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
12
|
$self->{term} = $top->term; |
58
|
3
|
|
|
|
|
18
|
$self->{doc_freq} = 0; |
59
|
3
|
|
66
|
|
|
23
|
while ($top && $self->{term}->eq($top->term)) { |
60
|
3
|
|
|
|
|
13
|
$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
|
3
|
|
|
|
|
15
|
pop @{ $self->{queue} }; |
|
3
|
|
|
|
|
14
|
|
67
|
3
|
50
|
|
|
|
30
|
if ($top->next) { |
68
|
3
|
|
|
|
|
5
|
unshift @{ $self->{queue} }, $top; |
|
3
|
|
|
|
|
16
|
|
69
|
|
|
|
|
|
|
} |
70
|
3
|
|
|
|
|
45
|
$top = $self->{queue}[0]; |
71
|
|
|
|
|
|
|
} |
72
|
3
|
|
|
|
|
15
|
return 1; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |