| 1 | package DBM::Deep::Sector::File; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 47 | ▶ | use 5.006_000; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 47 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 47 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 47 | ▶ | use base qw( DBM::Deep::Sector ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 47 | ▶ | use DBM::Deep::Sector::File::BucketList (); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 47 | ▶ | use DBM::Deep::Sector::File::Index (); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 47 | ▶ | use DBM::Deep::Sector::File::Null (); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 47 | ▶ | use DBM::Deep::Sector::File::Reference (); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 47 | ▶ | use DBM::Deep::Sector::File::Scalar (); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 47 | my $STALE_SIZE = 2; | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | sub base_size { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 70549 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base_size: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 70549 | return $self->engine->SIG_SIZE + $STALE_SIZE; | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub free_meth { die "free_meth must be implemented in a child class" } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
free_meth: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | sub free { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 488 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
free: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 488 | my $e = $self->engine; | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 488 | $e->storage->print_at( $self->offset, $e->SIG_FREE ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # Skip staleness counter | ||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 488 | $e->storage->print_at( $self->offset + $self->base_size, | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | chr(0) x ($self->size - $self->base_size), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 488 | my $free_meth = $self->free_meth; | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 488 | $e->$free_meth( $self->offset, $self->size ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 488 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | =head2 load( $offset ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | This will instantiate and return the sector object that represents the data | ||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | found at $offset. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | sub load { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 22546 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 22546 | my ($engine, $offset) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # Add a catch for offset of 0 or 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 22546 | ▶ | return if !$offset || $offset <= 1; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $offset or $offset <= 1
MC/DC100%2/2
not $offset or $offset <= 1
not $offset
$offset <= 1
Truth table100%3/3
not(A) or B
A= not $offsetB= $offset <= 1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 22540 | my $type = $engine->storage->read_at( $offset, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 22540 | ▶ | return if $type eq chr(0); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 22540 | ▶ | if ( $type eq $engine->SIG_ARRAY || $type eq $engine->SIG_HASH ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition100%3/3
$type eq $engine->SIG_ARRAY or $type eq $engine->SIG_HASH
MC/DC100%2/2
$type eq $engine->SIG_ARRAY or $type eq $engine->SIG_HASH
$type eq $engine->SIG_ARRAY
$type eq $engine->SIG_HASH
Truth table100%3/3
A or B
A= $type eq $engine->SIG_ARRAYB= $type eq $engine->SIG_HASH
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 8703 | return DBM::Deep::Sector::File::Reference->new({ | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | engine => $engine, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | offset => $offset, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # XXX Don't we need key_md5 here? | ||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | elsif ( $type eq $engine->SIG_BLIST ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 5668 | return DBM::Deep::Sector::File::BucketList->new({ | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | engine => $engine, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | offset => $offset, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | elsif ( $type eq $engine->SIG_INDEX ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 4088 | return DBM::Deep::Sector::File::Index->new({ | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | engine => $engine, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | offset => $offset, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | elsif ( $type eq $engine->SIG_NULL ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 91 | return DBM::Deep::Sector::File::Null->new({ | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | engine => $engine, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | offset => $offset, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | elsif ( $type eq $engine->SIG_DATA ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 3985 | return DBM::Deep::Sector::File::Scalar->new({ | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | engine => $engine, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | offset => $offset, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # This was deleted from under us, so just return and let the caller figure it out. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | elsif ( $type eq $engine->SIG_FREE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | DBM::Deep->_throw_error( "'$offset': Don't know what to do with type '$type'" ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 47 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||