KiokuDB/Backend/Role/TXN/Memory/Scan.pm

filter: Statementstmt 97.6% 42 / 43 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 93.3% 56 / 60 CC 5 SCAR 8.2
CC
5
Cov
96%
all_entries
4.0
clear
2.0
BEGIN
1.0
CRAP 2.3
« KiokuDB/TypeMap/Composite.pm ↑ Summary KiokuDB/TypeMap/Shadow.pm »
1 package KiokuDB::Backend::Role::TXN::Memory::Scan;
2 21 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 21 ▶use Data::Stream::Bulk::Util qw(bulk);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 21 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 21 with qw(
9 KiokuDB::Backend::Role::TXN::Memory
10 KiokuDB::Backend::Role::Clear
11 KiokuDB::Backend::Role::Scan
12 );
13  
14 21 requires qw(
15 all_storage_entries
16 clear_storage
17 );
18  
19 sub clear {
20 232 ▶ my $self = shift;
Subroutine clear: called CC=2 SCAR=7.1
Pod undocumented
21  
22 232 ▶ if ( @{ $self->_txn_stack } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->_txn_stack;}) { } 232 0 232
23 232 %{ $self->_txn_stack->[-1] } = ( %{ $self->_new_frame }, cleared => 1 );
24 } else {
25 0 $self->clear_storage;
26 }
27 }
28  
29 sub all_entries {
30 915 ▶ my $self = shift;
Subroutine all_entries: called CC=4 SCAR=13.9
Pod undocumented
31  
32 915 my $stack = $self->_txn_stack;
33  
34 915 ▶ if ( @$stack ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$stack) { } 829 86 915
35 829 my $frame = $stack->[-1];
36  
37 829 my $flat = $self->_collapsed_txn_stack;
38  
39 829 my $live = bulk(grep { not $_->deleted } values %{ $flat->{live} });
40  
41 829 ▶ if ( $flat->{cleared} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flat->{'cleared'}) { } 132 697 829
42 # return all the inserted entries since the clear
43 132 return $live;
44 } else {
45 697 my $all = $self->all_storage_entries;
46  
47 # create a filter for all the IDs that have been either deleted or superseded in the transaction frame
48 697 my %mask; @mask{ keys %{ $flat->{live} } } = ();
49  
50 697 ▶ my $shadowed = keys %mask ? $all->filter(sub {[ grep { not exists $mask{$_->id} } @$_ ]}) : $all;
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
keys %mask ? : 358 339 697
51  
52 # make note of all read entries in the transaction frame
53 my $noted_shadowed = $shadowed->filter(sub {
54 656 ▶ @{ $frame->{live} }{ map { $_->id } @$_ } = @$_;
Subroutine __ANON__: called CC=1 SCAR=0.0
55 576 return $_;
56 689 });
57  
58 609 return $live->cat($noted_shadowed);
59 }
60 } else {
61 86 return $self->all_storage_entries;
62 }
63 }
64  
65  
66 # ex: set sw=4 et:
67  
68 21 __PACKAGE__
69  
70 __END__
« KiokuDB/TypeMap/Composite.pm ↑ Summary KiokuDB/TypeMap/Shadow.pm »