| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package KiokuDB::Role::Scan; |
|
4
|
3
|
|
|
3
|
|
2893
|
use MooseX::Role::Parameterized; |
|
|
3
|
|
|
|
|
168699
|
|
|
|
3
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
83567
|
use namespace::clean -except => 'meta'; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
22
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
parameter result_class => ( |
|
9
|
|
|
|
|
|
|
isa => "Str", |
|
10
|
|
|
|
|
|
|
is => "ro", |
|
11
|
|
|
|
|
|
|
required => 1, |
|
12
|
|
|
|
|
|
|
); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
role { |
|
15
|
|
|
|
|
|
|
my $meta = shift; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $result_class = $meta->result_class; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
with qw(KiokuDB::Role::Verbosity); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has backend => ( |
|
22
|
|
|
|
|
|
|
does => "KiokuDB::Backend::Role::Scan", |
|
23
|
|
|
|
|
|
|
is => "ro", |
|
24
|
|
|
|
|
|
|
required => 1, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has scan_all => ( |
|
28
|
|
|
|
|
|
|
isa => "Bool", |
|
29
|
|
|
|
|
|
|
is => "ro", |
|
30
|
|
|
|
|
|
|
default => 1, |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has scan_ids => ( |
|
34
|
|
|
|
|
|
|
isa => "Bool", |
|
35
|
|
|
|
|
|
|
is => "ro", |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has entries => ( |
|
39
|
|
|
|
|
|
|
does => "Data::Stream::Bulk", |
|
40
|
|
|
|
|
|
|
is => "ro", |
|
41
|
|
|
|
|
|
|
lazy_build => 1, |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _build_entries { |
|
45
|
24
|
|
|
24
|
|
36
|
my $self = shift; |
|
46
|
|
|
|
|
|
|
|
|
47
|
24
|
|
|
|
|
595
|
my $backend = $self->backend; |
|
48
|
|
|
|
|
|
|
|
|
49
|
24
|
100
|
|
|
|
624
|
my $set = $self->scan_all ? "all" : "root"; |
|
50
|
24
|
100
|
|
|
|
625
|
my $type = $self->scan_ids ? "entry_ids" : "entries"; |
|
51
|
|
|
|
|
|
|
|
|
52
|
24
|
|
|
|
|
60
|
my $method = join("_", $set, $type); |
|
53
|
|
|
|
|
|
|
|
|
54
|
24
|
|
|
|
|
124
|
$backend->$method; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has [qw(block_callback entry_callback)] => ( |
|
58
|
|
|
|
|
|
|
isa => "CodeRef|Str", |
|
59
|
|
|
|
|
|
|
is => "ro", |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has results => ( |
|
63
|
|
|
|
|
|
|
isa => $result_class, |
|
64
|
|
|
|
|
|
|
is => "ro", |
|
65
|
|
|
|
|
|
|
handles => qr/.*/, |
|
66
|
|
|
|
|
|
|
lazy_build => 1, |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
requires "process_block"; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
method _build_results => sub { |
|
72
|
26
|
|
|
26
|
|
30
|
my $self = shift; |
|
|
|
|
|
18
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
26
|
|
|
|
|
731
|
my $res = $result_class->new; |
|
75
|
|
|
|
|
|
|
|
|
76
|
26
|
|
|
|
|
40
|
my $i = my $j = 0; |
|
77
|
|
|
|
|
|
|
|
|
78
|
26
|
|
|
|
|
674
|
while ( my $next = $self->entries->next ) { |
|
79
|
26
|
|
|
|
|
1829
|
$i += @$next; |
|
80
|
26
|
|
|
|
|
41
|
$j += @$next; |
|
81
|
|
|
|
|
|
|
|
|
82
|
26
|
100
|
|
|
|
67
|
if ( $j > 13 ) { # luv primes |
|
83
|
5
|
|
|
|
|
12
|
$j = 0; |
|
84
|
5
|
|
|
|
|
40
|
$self->v("\rscanning... $i"); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
26
|
|
|
|
|
111
|
$self->process_block( block => $next, results => $res ); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
26
|
|
|
|
|
974
|
$self->v("\rscanned $i entries \n"); |
|
91
|
|
|
|
|
|
|
|
|
92
|
26
|
|
|
|
|
716
|
return $res; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
}; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__PACKAGE__ |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=pod |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 NAME |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
KiokuDB::Role::Scan - A role for entry scanning. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
package My::Entry::Processor; |
|
109
|
|
|
|
|
|
|
use Moose; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
with 'KiokuDB::Role::Scan' => { result_class => "My::Entry::Processor::Results" }; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub process_block { |
|
114
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$args{results}; # intermediate results |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
foreach my $entry ( @{ $args{block} } ) { |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $scan = My::Entry::Processor->new( |
|
126
|
|
|
|
|
|
|
backend => $some_backend, |
|
127
|
|
|
|
|
|
|
); |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $res = $scan->results; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$res->foo; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
$scan->foo; # delegates to result |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This role is used by classes like L<KiokuDB::LinkChecker> to scan the whole |
|
138
|
|
|
|
|
|
|
database and computing summary results. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 ROLE PARAMETERS |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=over 4 |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item result_class |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
The class of the results. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Will be used when creating the results initially by calling C<new> and also |
|
149
|
|
|
|
|
|
|
sets up an attribute with delegations. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=back |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|