| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Plucene::Search::HitCollector; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Plucene::Search::HitCollector |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# used in conjunction with the IndexSearcher |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $searcher = Plucene::Search::IndexSearcher->new($DIRECTORY); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $hc = Plucene::Search::HitCollector->new( collect => |
|
14
|
|
|
|
|
|
|
sub { |
|
15
|
|
|
|
|
|
|
my ($self, $doc, $score) = @_; |
|
16
|
|
|
|
|
|
|
... |
|
17
|
|
|
|
|
|
|
}); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$searcher->search_hc($QUERY, $hc); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This is used in conjunction with the IndexSearcher, in that whenever a |
|
24
|
|
|
|
|
|
|
non-zero scoring document is found, the subref with with the HitCollector |
|
25
|
|
|
|
|
|
|
was made will get called. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 new |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $hc = Plucene::Search::HitCollector->new( collect => |
|
34
|
|
|
|
|
|
|
sub { |
|
35
|
|
|
|
|
|
|
my ($self, $doc, $score) = @_; |
|
36
|
|
|
|
|
|
|
... |
|
37
|
|
|
|
|
|
|
}); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This will create a new Plucene::Search::HitCollector with the passed subref. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
17
|
|
|
17
|
|
4329
|
use strict; |
|
|
17
|
|
|
|
|
38
|
|
|
|
17
|
|
|
|
|
582
|
|
|
44
|
17
|
|
|
17
|
|
94
|
use warnings; |
|
|
17
|
|
|
|
|
55
|
|
|
|
17
|
|
|
|
|
494
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
17
|
|
|
17
|
|
90
|
use Carp qw/confess/; |
|
|
17
|
|
|
|
|
36
|
|
|
|
17
|
|
|
|
|
2710
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# We're having to fake up singleton methods here. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub new { |
|
51
|
178
|
|
|
178
|
1
|
1721
|
my ($self, %stuff) = @_; |
|
52
|
178
|
50
|
|
|
|
783
|
if (!exists $stuff{collect}) { |
|
53
|
0
|
|
|
|
|
0
|
confess("Need to supply definition of collect method"); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
178
|
|
|
|
|
1188
|
bless \%stuff, $self; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 collect |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This is called once for every non-zero scoring document, with the document |
|
61
|
|
|
|
|
|
|
number and its score. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
264
|
|
|
264
|
1
|
1171
|
sub collect { shift->{collect}->(@_) } |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |