my $self = bless {
type => TYPE_HASH,
base_offset => length(SIG_FILE),
- engine => 'DBM::Deep::Engine',
+ engine => DBM::Deep::Engine->new,
}, $class;
foreach my $param ( keys %$self ) {
? $args->{root}
: DBM::Deep::_::Root->new( $args );
- if (!defined($self->_fh)) { $self->{engine}->open( $self ); }
+ $self->{engine}->setup_fh( $self );
return $self;
}
# double-check file inode, in case another process
# has optimize()d our file while we were waiting.
if ($stats[1] != $self->_root->{inode}) {
- $self->{engine}->open( $self ); # re-open
+ $self->{engine}->close( $self );
+ $self->{engine}->setup_fh( $self );
flock($self->_fh, $type); # re-lock
+
+ # This may not be necessary after re-opening
$self->_root->{end} = (stat($self->_fh))[7]; # re-end
}
}
$self->unlock();
$self->{engine}->close( $self );
- $self->{engine}->open( $self );
-
+ $self->{engine}->setup_fh( $self );
+
return 1;
}
? $self->_root->{filter_store_value}->($_[2])
: $_[2];
- my $md5 = $DBM::Deep::Engine::DIGEST_FUNC->($key);
+ my $md5 = $self->{engine}{digest}->($key);
unless ( _is_writable( $self->_fh ) ) {
$self->_throw_error( 'Cannot write to a readonly filehandle' );
##
my $tag = $self->{engine}->load_tag($self, $self->_base_offset);
if (!$tag) {
- $tag = $self->{engine}->create_tag($self, $self->_base_offset, SIG_INDEX, chr(0) x $DBM::Deep::Engine::INDEX_SIZE);
+ $tag = $self->{engine}->create_tag($self, $self->_base_offset, SIG_INDEX, chr(0) x $self->{engine}{index_size});
}
my $ch = 0;
while ($tag->{signature} ne SIG_BLIST) {
my $num = ord(substr($md5, $ch, 1));
- my $ref_loc = $tag->{offset} + ($num * $DBM::Deep::Engine::LONG_SIZE);
+ my $ref_loc = $tag->{offset} + ($num * $self->{engine}{long_size});
my $new_tag = $self->{engine}->index_lookup($self, $tag, $num);
if (!$new_tag) {
seek($fh, $ref_loc + $self->_root->{file_offset}, SEEK_SET);
- print( $fh pack($DBM::Deep::Engine::LONG_PACK, $self->_root->{end}) );
+ print( $fh pack($self->{engine}{long_pack}, $self->_root->{end}) );
- $tag = $self->{engine}->create_tag($self, $self->_root->{end}, SIG_BLIST, chr(0) x $DBM::Deep::Engine::BUCKET_LIST_SIZE);
+ $tag = $self->{engine}->create_tag(
+ $self, $self->_root->{end},
+ SIG_BLIST,
+ chr(0) x $self->{engine}{bucket_list_size},
+ );
$tag->{ref_loc} = $ref_loc;
$tag->{ch} = $ch;
my $self = shift->_get_self;
my $key = shift;
- my $md5 = $DBM::Deep::Engine::DIGEST_FUNC->($key);
+ my $md5 = $self->{engine}{digest}->($key);
##
# Request shared lock for reading
my $self = $_[0]->_get_self;
my $key = $_[1];
- my $md5 = $DBM::Deep::Engine::DIGEST_FUNC->($key);
+ my $md5 = $self->{engine}{digest}->($key);
##
# Request exclusive lock for writing
my $self = $_[0]->_get_self;
my $key = $_[1];
- my $md5 = $DBM::Deep::Engine::DIGEST_FUNC->($key);
+ my $md5 = $self->{engine}{digest}->($key);
##
# Request shared lock for reading
return;
}
- $self->{engine}->create_tag($self, $self->_base_offset, $self->_type, chr(0) x $DBM::Deep::Engine::INDEX_SIZE);
+ $self->{engine}->create_tag($self, $self->_base_offset, $self->_type, chr(0) x $self->{engine}{index_size});
$self->unlock();
my ($args) = @_;
my $self = bless {
- file => undef,
- fh => undef,
- file_offset => 0,
- end => 0,
- autoflush => undef,
- locking => undef,
- debug => undef,
- filter_store_key => undef,
+ file => undef,
+ fh => undef,
+ file_offset => 0,
+ end => 0,
+ autoflush => undef,
+ locking => undef,
+ locked => 0,
+ filter_store_key => undef,
filter_store_value => undef,
- filter_fetch_key => undef,
+ filter_fetch_key => undef,
filter_fetch_value => undef,
- autobless => undef,
- locked => 0,
+ autobless => undef,
%$args,
}, $class;
See L<FILTERS> below.
-=item * debug
-
-Setting I<debug> mode will make all errors non-fatal, dump them out to
-STDERR, and continue on. This is for debugging purposes only, and probably
-not what you want. This is an optional parameter, and defaults to 0 (disabled).
-
-B<NOTE>: This parameter is considered deprecated and should not be used anymore.
-
=back
=head1 TIE INTERFACE
my $root = $db->_root();
This is useful for changing options after the object has already been created,
-such as enabling/disabling locking, or debug modes. You can also
-store your own temporary user data in this structure (be wary of name
-collision), which is then accessible from any child hash or array.
+such as enabling/disabling locking. You can also store your own temporary user
+data in this structure (be wary of name collision), which is then accessible from
+any child hash or array.
=head1 CUSTOM DIGEST ALGORITHM
---------------------------- ------ ------ ------ ------ ------ ------ ------
File stmt bran cond sub pod time total
---------------------------- ------ ------ ------ ------ ------ ------ ------
- blib/lib/DBM/Deep.pm 95.2 83.8 70.0 98.2 100.0 58.0 91.0
- blib/lib/DBM/Deep/Array.pm 100.0 91.1 100.0 100.0 n/a 26.7 98.0
- blib/lib/DBM/Deep/Hash.pm 95.3 80.0 100.0 100.0 n/a 15.3 92.4
- Total 96.2 84.8 74.4 98.8 100.0 100.0 92.4
+ blib/lib/DBM/Deep.pm 95.1 81.6 70.3 100.0 100.0 33.4 91.0
+ blib/lib/DBM/Deep/Array.pm 100.0 91.1 100.0 100.0 n/a 27.8 98.0
+ blib/lib/DBM/Deep/Engine.pm 97.8 85.6 75.0 100.0 0.0 25.8 90.8
+ blib/lib/DBM/Deep/Hash.pm 100.0 87.5 100.0 100.0 n/a 13.0 97.2
+ Total 97.5 85.4 76.6 100.0 46.9 100.0 92.5
---------------------------- ------ ------ ------ ------ ------ ------ ------
=head1 MORE INFORMATION