Plucene/Search/HitCollector.pm

filter: Statementstmt 93.3% 14 / 15 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 91.6% 22 / 24 CC 2 SCAR 3.2
CC
2
Cov
88%
new
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Plucene/Index/FieldsWriter.pm ↑ Summary Plucene/Search/Filter.pm »
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 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 17 ▶use Carp qw/confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 # We're having to fake up singleton methods here.
49  
50 191 ▶sub new {
Subroutine new: called CC=2 SCAR=7.6
Pod documented
51 191 my ($self, %stuff) = @_;
52 191 ▶ if (!exists $stuff{collect}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $stuff{"collect"}) 0 191 191
53 0 confess("Need to supply definition of collect method");
54 }
55 191 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 366 ▶sub collect { shift->{collect}->(@_) }
Subroutine collect: called CC=1 SCAR=0.0
Pod documented
66  
67 17 1;
« Plucene/Index/FieldsWriter.pm ↑ Summary Plucene/Search/Filter.pm »