KiokuDB/Backend/Role/Scan.pm

filter: Statementstmt 100% 24 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 40.0% 2 / 5 totaltotal 92.3% 36 / 39 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
entries_to_ids
1.0
BEGIN
1.0
CRAP 1.0
« KiokuDB/TypeMap/Entry/Std/Compile.pm ↑ Summary KiokuDB/Role/ID/Digest.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB::Backend::Role::Scan;
4 21 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 sub entries_to_ids {
7 284 ▶ my $stream = shift;
Subroutine entries_to_ids: called CC=1 SCAR=0.0
8 284 $stream->filter(sub {[ map { $_->id } @$_ ]});
9 }
10  
11 21 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 21 requires "all_entries";
14  
15 sub root_entries {
16 501 ▶ my $self = shift;
Subroutine root_entries: called CC=1 SCAR=0.0
Pod documented
17 501 ▶ return $self->all_entries->filter(sub {[ grep { $_->root } @$_ ]});
Subroutine __ANON__: called CC=1 SCAR=0.0
18 }
19  
20 sub child_entries {
21 58 ▶ my $self = shift;
Subroutine child_entries: called CC=1 SCAR=0.0
Pod documented
22 58 ▶ return $self->all_entries->filter(sub {[ grep { not $_->root } @$_ ]});
Subroutine __ANON__: called CC=1 SCAR=0.0
23 }
24  
25 sub all_entry_ids {
26 84 ▶ my $self = shift;
Subroutine all_entry_ids: called CC=1 SCAR=0.0
Pod undocumented
27 84 entries_to_ids($self->all_entries);
28 }
29  
30 sub root_entry_ids {
31 175 ▶ my $self = shift;
Subroutine root_entry_ids: called CC=1 SCAR=0.0
Pod undocumented
32 175 entries_to_ids($self->root_entries);
33 }
34  
35 sub child_entry_ids {
36 25 ▶ my $self = shift;
Subroutine child_entry_ids: called CC=1 SCAR=0.0
Pod undocumented
37 25 entries_to_ids($self->child_entries);
38 }
39  
40 21 __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  
« KiokuDB/TypeMap/Entry/Std/Compile.pm ↑ Summary KiokuDB/Role/ID/Digest.pm »