| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Lucene::Iterator; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2073
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw( Class::Accessor::Fast ); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
88
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
44
|
use WebService::Lucene::Document; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw( iterator ) ); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
WebService::Lucene::Iterator - Iterator for lazy document inflation |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use WebService::Lucene::Iterator; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $iterator = WebService::Lucene::Iterator->new( $documents ); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
All search results are returned as L objects |
|
25
|
|
|
|
|
|
|
which get inflated to L objects. |
|
26
|
|
|
|
|
|
|
This module allows us to delay that inflation as late as possible. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 new( $documents ) |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Generates a new iterator that will iterate through |
|
33
|
|
|
|
|
|
|
C<$documents> as requested. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
|
38
|
|
|
|
|
|
|
my ( $class, $documents ) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $self = $class->SUPER::new; |
|
41
|
|
|
|
|
|
|
my $index = 0; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->iterator( |
|
44
|
|
|
|
|
|
|
sub { |
|
45
|
|
|
|
|
|
|
my $document = $documents->[ $index ]; |
|
46
|
|
|
|
|
|
|
return undef unless $document; |
|
47
|
|
|
|
|
|
|
$index++; |
|
48
|
|
|
|
|
|
|
return WebService::Lucene::Document->new_from_entry( $document ); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return $self; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 iterator( [$iterator] ) |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Accessor for the iterator closure. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 next( ) |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Inflates and returns the next document object. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub next { |
|
66
|
|
|
|
|
|
|
return shift->iterator->(); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHORS |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over 4 |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * Brian Cassidy Ebrian.cassidy@nald.caE |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * Adam Paynter Eadam.paynter@nald.caE |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Copyright 2006-2009 National Adult Literacy Database |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
84
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |