| 1 | package DBM::Deep::Hash; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 53 | ▶ | use 5.008_004; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 53 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 53 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 53 | ▶ | no warnings 'recursion'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 53 | ▶ | use base 'DBM::Deep'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub _get_self { | ||||||||||||||||||||||||||||
| 12 | # See the note in Array.pm as to why this is commented out. | ||||||||||||||||||||||||||||
| 13 | # eval { local $SIG{'__DIE__'}; tied( %{$_[0]} ) } || $_[0] | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # During global destruction %{$_[0]} might get tied to undef, so we | ||||||||||||||||||||||||||||
| 16 | # need to check that case if tied returns false. | ||||||||||||||||||||||||||||
| 17 | 63344 | ▶ | tied %{$_[0]} or local *@, eval { exists $_[0]{_}; 1 } ? $_[0] : undef | ||||||||||||||||||||||||||
|
Subroutine
_get_self: called CC=3 SCAR=11.0
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 21 | ▶ | sub _repr { return {} } | ||||||||||||||||||||||||||
|
Subroutine
_repr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | sub TIEHASH { | ||||||||||||||||||||||||||||
| 23 | 785 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
TIEHASH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 785 | my $args = $class->_get_args( @_ ); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 783 | $args->{type} = $class->TYPE_HASH; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 783 | return $class->_init($args); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | sub FETCH { | ||||||||||||||||||||||||||||
| 32 | 2622 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 33 | 2622 | ▶ | DBM::Deep->_throw_error( "Cannot use an undefined hash key." ) unless defined $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | my $key = ($self->_engine->storage->{filter_store_key}) | ||||||||||||||||||||||||||||
| 35 | 2620 | ▶ | ? $self->_engine->storage->{filter_store_key}->($_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | : $_[0]; | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 2620 | return $self->SUPER::FETCH( $key, $_[0] ); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | sub STORE { | ||||||||||||||||||||||||||||
| 42 | 1512 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 43 | 1512 | ▶ | DBM::Deep->_throw_error( "Cannot use an undefined hash key." ) unless defined $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | my $key = ($self->_engine->storage->{filter_store_key}) | ||||||||||||||||||||||||||||
| 45 | 1510 | ▶ | ? $self->_engine->storage->{filter_store_key}->($_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | : $_[0]; | ||||||||||||||||||||||||||||
| 47 | 1510 | my $value = $_[1]; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 1510 | return $self->SUPER::STORE( $key, $value, $_[0] ); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | sub EXISTS { | ||||||||||||||||||||||||||||
| 53 | 125 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
EXISTS: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 54 | 125 | ▶ | DBM::Deep->_throw_error( "Cannot use an undefined hash key." ) unless defined $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | my $key = ($self->_engine->storage->{filter_store_key}) | ||||||||||||||||||||||||||||
| 56 | 123 | ▶ | ? $self->_engine->storage->{filter_store_key}->($_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | : $_[0]; | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 123 | return $self->SUPER::EXISTS( $key ); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub DELETE { | ||||||||||||||||||||||||||||
| 63 | 48 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
DELETE: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 64 | 48 | ▶ | DBM::Deep->_throw_error( "Cannot use an undefined hash key." ) unless defined $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | my $key = ($self->_engine->storage->{filter_store_key}) | ||||||||||||||||||||||||||||
| 66 | 46 | ▶ | ? $self->_engine->storage->{filter_store_key}->($_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | : $_[0]; | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 46 | return $self->SUPER::DELETE( $key, $_[0] ); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | # Locate and return first key (in no particular order) | ||||||||||||||||||||||||||||
| 73 | sub FIRSTKEY { | ||||||||||||||||||||||||||||
| 74 | 162 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 162 | $self->lock_shared; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 162 | my $result = $self->_engine->get_next_key( $self ); | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 159 | $self->unlock; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | return ($result && $self->_engine->storage->{filter_fetch_key}) | ||||||||||||||||||||||||||||
| 83 | 159 | ▶ | ? $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"}
| |||||||||||||||||||||||||||||
| 84 | : $result; | ||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | # Return next key (in no particular order), given previous one | ||||||||||||||||||||||||||||
| 88 | sub NEXTKEY { | ||||||||||||||||||||||||||||
| 89 | 383 | ▶ | my $self = shift->_get_self; | ||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | my $prev_key = ($self->_engine->storage->{filter_store_key}) | ||||||||||||||||||||||||||||
| 92 | 383 | ▶ | ? $self->_engine->storage->{filter_store_key}->($_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | : $_[0]; | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 383 | $self->lock_shared; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 383 | my $result = $self->_engine->get_next_key( $self, $prev_key ); | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 383 | $self->unlock; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | return ($result && $self->_engine->storage->{filter_fetch_key}) | ||||||||||||||||||||||||||||
| 102 | 383 | ▶ | ? $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"}
| |||||||||||||||||||||||||||||
| 103 | : $result; | ||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 33 | ▶ | sub first_key { (shift)->FIRSTKEY(@_) } | ||||||||||||||||||||||||||
|
Subroutine
first_key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | 52 | ▶ | sub next_key { (shift)->NEXTKEY(@_) } | ||||||||||||||||||||||||||
|
Subroutine
next_key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | sub _clear { | ||||||||||||||||||||||||||||
| 110 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_clear: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 1 | ▶ | while ( defined(my $key = $self->first_key) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 1 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 2 | $self->_engine->delete_key( $self, $key, $key ); | |||||||||||||||||||||||||||
| 115 | } while defined($key = $self->next_key($key)); | ||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 1 | return; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | sub _copy_node { | ||||||||||||||||||||||||||||
| 122 | 23 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_copy_node: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 123 | 23 | my ($db_temp) = @_; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 23 | my $key = $self->first_key(); | |||||||||||||||||||||||||||
| 126 | 23 | ▶ | while (defined $key) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 41 | my $value = $self->get($key); | |||||||||||||||||||||||||||
| 128 | 41 | $self->_copy_value( \$db_temp->{$key}, $value ); | |||||||||||||||||||||||||||
| 129 | 41 | $key = $self->next_key($key); | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 23 | return 1; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 53 | 1; | |||||||||||||||||||||||||||
| 136 | __END__ | ||||||||||||||||||||||||||||