line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
18
|
|
|
18
|
|
86491
|
|
|
18
|
|
|
|
|
30
|
|
|
18
|
|
|
|
|
102
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
18
|
|
|
18
|
|
237
|
use namespace::clean; |
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
95
|
|
8
|
18
|
|
|
18
|
|
5543
|
|
|
18
|
|
|
|
|
130
|
|
|
18
|
|
|
|
|
127
|
|
9
|
|
|
|
|
|
|
has start => (is => 'ro', required => 1); |
10
|
|
|
|
|
|
|
has limit => (is => 'ro', required => 1); |
11
|
|
|
|
|
|
|
has total => (is => 'ro', required => 1); |
12
|
|
|
|
|
|
|
has hits => (is => 'ro', required => 1); |
13
|
|
|
|
|
|
|
has maximum_offset => (is => 'ro'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Catmandu::Iterable'; |
16
|
|
|
|
|
|
|
with 'Catmandu::Paged'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
scalar @{$_[0]->hits}; |
19
|
|
|
|
|
|
|
} |
20
|
1
|
|
|
1
|
0
|
2
|
|
|
1
|
|
|
|
|
6
|
|
21
|
|
|
|
|
|
|
my $self = $_[0]; |
22
|
|
|
|
|
|
|
my $start = $self->start; |
23
|
|
|
|
|
|
|
my $limit = $self->limit; |
24
|
1
|
|
|
1
|
1
|
9201
|
my $max_offset = $self->maximum_offset; |
25
|
1
|
|
|
|
|
4
|
return 0 if $max_offset && $start + $limit > $max_offset; |
26
|
1
|
|
|
|
|
4
|
$start + $limit < $self->total; |
27
|
1
|
|
|
|
|
2
|
} |
28
|
1
|
50
|
33
|
|
|
5
|
|
29
|
1
|
|
|
|
|
5
|
my $self = $_[0]; |
30
|
|
|
|
|
|
|
my $hits = $self->hits; |
31
|
|
|
|
|
|
|
my $i = 0; |
32
|
|
|
|
|
|
|
sub { |
33
|
1
|
|
|
1
|
0
|
2
|
$hits->[$i++]; |
34
|
1
|
|
|
|
|
3
|
}; |
35
|
1
|
|
|
|
|
2
|
} |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
4
|
[@{$_[0]->hits}]; |
38
|
1
|
|
|
|
|
5
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
scalar @{$_[0]->hits}; |
41
|
|
|
|
|
|
|
} |
42
|
6
|
|
|
6
|
0
|
9
|
|
|
6
|
|
|
|
|
113
|
|
43
|
|
|
|
|
|
|
my ($self, $cb) = @_; |
44
|
|
|
|
|
|
|
my $hits = $self->hits; |
45
|
|
|
|
|
|
|
for my $hit (@$hits) { |
46
|
1
|
|
|
1
|
0
|
2
|
$cb->($hit); |
|
1
|
|
|
|
|
4
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
$self->count; |
49
|
|
|
|
|
|
|
} |
50
|
1
|
|
|
1
|
0
|
2
|
|
51
|
1
|
|
|
|
|
3
|
$_[0]->hits->[0]; |
52
|
1
|
|
|
|
|
3
|
} |
53
|
100
|
|
|
|
|
185
|
|
54
|
|
|
|
|
|
|
1; |
55
|
1
|
|
|
|
|
5
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=pod |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
1
|
0
|
6
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Catmandu::Hits - Iterable object that wraps Catmandu::Store search hits |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $store = Catmandu::Store::Solr->new; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $hits = $store->bag->search( |
68
|
|
|
|
|
|
|
query => 'dna' , |
69
|
|
|
|
|
|
|
start => 0 , |
70
|
|
|
|
|
|
|
limit => 100 , |
71
|
|
|
|
|
|
|
sort => 'title desc', |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Every hits is an iterator... |
75
|
|
|
|
|
|
|
$hits->each(sub { ... }); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
printf "Found %s $hits\n" , $hits->total; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $start = $hits->start; |
80
|
|
|
|
|
|
|
my $limit = $hits->limit; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $prev = $hits->previous_page; |
83
|
|
|
|
|
|
|
my $next = $hits->next_page; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 METHODS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
A Catmandu::Hits object provides the following methods in addition to |
88
|
|
|
|
|
|
|
methods of L<Catmandu::Iterable> and L<Catmandu::Paged>. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 total |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns the total number of hits matching the query. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 start |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns the start index for the search results. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 limit |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns the maximum number of search results returned. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 more |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Return true if there are more search results. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L<Catmandu::Bag>, L<Catmandu::Searchable>, L<Catmandu::Store> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |