| 1 | package DBM::Deep::Hash; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 46 | ▶ | use 5.006_000; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 46 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 46 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 46 | ▶ | no warnings 'recursion'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 46 | ▶ | use base 'DBM::Deep'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub _get_self { | ||||||||||||||||||||||||||||
| 12 | 60427 | ▶ | eval { local $SIG{'__DIE__'}; tied( %{$_[0]} ) } || $_[0] | ||||||||||||||||||||||||||
|
Subroutine
_get_self: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 19 | ▶ | sub _repr { return {} } | ||||||||||||||||||||||||||
|
Subroutine
_repr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub TIEHASH { | ||||||||||||||||||||||||||||
| 18 | 757 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
TIEHASH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 757 | my $args = $class->_get_args( @_ ); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 755 | $args->{type} = $class->TYPE_HASH; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 755 | return $class->_init($args); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub FETCH { | ||||||||||||||||||||||||||||
| 27 | 2588 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 28 | 2588 | ▶ | DBM::Deep->_throw_error( "Cannot use an undefined hash key." ) unless defined $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | my $key = ($self->_engine->storage->{filter_store_key}) | ||||||||||||||||||||||||||||
| 30 | 2586 | ▶ | ? $self->_engine->storage->{filter_store_key}->($_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | : $_[0]; | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 2586 | return $self->SUPER::FETCH( $key, $_[0] ); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | sub STORE { | ||||||||||||||||||||||||||||
| 37 | 1472 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 38 | 1472 | ▶ | DBM::Deep->_throw_error( "Cannot use an undefined hash key." ) unless defined $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | my $key = ($self->_engine->storage->{filter_store_key}) | ||||||||||||||||||||||||||||
| 40 | 1470 | ▶ | ? $self->_engine->storage->{filter_store_key}->($_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | : $_[0]; | ||||||||||||||||||||||||||||
| 42 | 1470 | my $value = $_[1]; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1470 | return $self->SUPER::STORE( $key, $value, $_[0] ); | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | sub EXISTS { | ||||||||||||||||||||||||||||
| 48 | 124 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
EXISTS: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 49 | 124 | ▶ | DBM::Deep->_throw_error( "Cannot use an undefined hash key." ) unless defined $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | my $key = ($self->_engine->storage->{filter_store_key}) | ||||||||||||||||||||||||||||
| 51 | 122 | ▶ | ? $self->_engine->storage->{filter_store_key}->($_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | : $_[0]; | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 122 | return $self->SUPER::EXISTS( $key ); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | sub DELETE { | ||||||||||||||||||||||||||||
| 58 | 37 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
DELETE: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 59 | 37 | ▶ | DBM::Deep->_throw_error( "Cannot use an undefined hash key." ) unless defined $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | my $key = ($self->_engine->storage->{filter_store_key}) | ||||||||||||||||||||||||||||
| 61 | 35 | ▶ | ? $self->_engine->storage->{filter_store_key}->($_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | : $_[0]; | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 35 | return $self->SUPER::DELETE( $key, $_[0] ); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # Locate and return first key (in no particular order) | ||||||||||||||||||||||||||||
| 68 | sub FIRSTKEY { | ||||||||||||||||||||||||||||
| 69 | 153 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 153 | $self->lock_shared; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 153 | my $result = $self->_engine->get_next_key( $self ); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 153 | $self->unlock; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | return ($result && $self->_engine->storage->{filter_fetch_key}) | ||||||||||||||||||||||||||||
| 78 | 153 | ▶ | ? $self->_engine->storage->{filter_fetch_key}->($result) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$result and $self->_engine->storage->{"filter_fetch_key"}
MC/DC100%2/2
$result and $self->_engine->storage->{"filter_fetch_key"}
$result
$self->_engine->storage->{"filter_fetch_key"}
Truth table100%3/3
A and B
A= $resultB= $self->_engine->storage->{"filter_fetch_key"}
| |||||||||||||||||||||||||||||
| 79 | : $result; | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | # Return next key (in no particular order), given previous one | ||||||||||||||||||||||||||||
| 83 | sub NEXTKEY { | ||||||||||||||||||||||||||||
| 84 | 378 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | my $prev_key = ($self->_engine->storage->{filter_store_key}) | ||||||||||||||||||||||||||||
| 87 | 378 | ▶ | ? $self->_engine->storage->{filter_store_key}->($_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | : $_[0]; | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 378 | $self->lock_shared; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 378 | my $result = $self->_engine->get_next_key( $self, $prev_key ); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 378 | $self->unlock; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | return ($result && $self->_engine->storage->{filter_fetch_key}) | ||||||||||||||||||||||||||||
| 97 | 378 | ▶ | ? $self->_engine->storage->{filter_fetch_key}->($result) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$result and $self->_engine->storage->{"filter_fetch_key"}
MC/DC100%2/2
$result and $self->_engine->storage->{"filter_fetch_key"}
$result
$self->_engine->storage->{"filter_fetch_key"}
Truth table100%3/3
A and B
A= $resultB= $self->_engine->storage->{"filter_fetch_key"}
| |||||||||||||||||||||||||||||
| 98 | : $result; | ||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 27 | ▶ | sub first_key { (shift)->FIRSTKEY(@_) } | ||||||||||||||||||||||||||
|
Subroutine
first_key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 102 | 51 | ▶ | sub next_key { (shift)->NEXTKEY(@_) } | ||||||||||||||||||||||||||
|
Subroutine
next_key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | sub _clear { | ||||||||||||||||||||||||||||
| 105 | 1 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
_clear: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 1 | ▶ | while ( defined(my $key = $self->first_key) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 1 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 2 | $self->_engine->delete_key( $self, $key, $key ); | |||||||||||||||||||||||||||
| 110 | } while defined($key = $self->next_key($key)); | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 1 | return; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | sub _copy_node { | ||||||||||||||||||||||||||||
| 117 | 21 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_copy_node: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 118 | 21 | my ($db_temp) = @_; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 21 | my $key = $self->first_key(); | |||||||||||||||||||||||||||
| 121 | 21 | ▶ | while ($key) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 40 | my $value = $self->get($key); | |||||||||||||||||||||||||||
| 123 | 40 | $self->_copy_value( \$db_temp->{$key}, $value ); | |||||||||||||||||||||||||||
| 124 | 40 | $key = $self->next_key($key); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 21 | return 1; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 46 | 1; | |||||||||||||||||||||||||||
| 131 | __END__ | ||||||||||||||||||||||||||||