line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package KiokuDB::Backend::Role::Scan; |
4
|
21
|
|
|
21
|
|
8446
|
use Moose::Role; |
|
21
|
|
|
|
|
37
|
|
|
21
|
|
|
|
|
117
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub entries_to_ids { |
7
|
|
|
|
|
|
|
my $stream = shift; |
8
|
|
|
|
|
|
|
$stream->filter(sub {[ map { $_->id } @$_ ]}); |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
21
|
|
|
21
|
|
78571
|
use namespace::clean -except => 'meta'; |
|
21
|
|
|
|
|
47
|
|
|
21
|
|
|
|
|
135
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
requires "all_entries"; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub root_entries { |
16
|
573
|
|
|
573
|
1
|
1716
|
my $self = shift; |
17
|
573
|
|
|
573
|
|
2988
|
return $self->all_entries->filter(sub {[ grep { $_->root } @$_ ]}); |
|
573
|
|
|
|
|
108213
|
|
|
4276
|
|
|
|
|
91193
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub child_entries { |
21
|
66
|
|
|
66
|
1
|
115
|
my $self = shift; |
22
|
66
|
|
|
66
|
|
265
|
return $self->all_entries->filter(sub {[ grep { not $_->root } @$_ ]}); |
|
66
|
|
|
|
|
11605
|
|
|
264
|
|
|
|
|
5744
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub all_entry_ids { |
26
|
108
|
|
|
108
|
0
|
207
|
my $self = shift; |
27
|
108
|
|
|
|
|
646
|
entries_to_ids($self->all_entries); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub root_entry_ids { |
31
|
231
|
|
|
231
|
0
|
481
|
my $self = shift; |
32
|
231
|
|
|
|
|
787
|
entries_to_ids($self->root_entries); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub child_entry_ids { |
36
|
33
|
|
|
33
|
0
|
72
|
my $self = shift; |
37
|
33
|
|
|
|
|
115
|
entries_to_ids($self->child_entries); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__PACKAGE__ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
KiokuDB::Backend::Role::Scan - Root set iteration |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
with qw(KiokuDB::Backend::Role::Scan); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub all_entries { |
55
|
|
|
|
|
|
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# return all root set entries |
58
|
|
|
|
|
|
|
return Data::Stream::Bulk::Foo->new(...); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This is a role for iterative scanning of all entries in a backend. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
It is used for database backups, and various other tasks. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 REQUIRED METHODS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over 4 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item all_entries |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Should return a L<Data::Stream::Bulk> stream enumerating all entries in the |
74
|
|
|
|
|
|
|
database. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 OPTIONAL METHODS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
These method have default implementations defined in terms of C<all_entries> |
81
|
|
|
|
|
|
|
but maybe overridden if there is a more optimal solution than just filtering |
82
|
|
|
|
|
|
|
that stream. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over 4 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item root_entries |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Should return a L<Data::Stream::Bulk> of just the root entries. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item child_entries |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Should return a L<Data::Stream::Bulk> of everything but the root entries. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|