From: rkinyon Date: Wed, 26 Apr 2006 02:19:10 +0000 (+0000) Subject: Commit right before adding the keylist X-Git-Tag: 0-99_02~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=72e315ac5b05326d864abc064f4e660cd04768c7;p=dbsrgits%2FDBM-Deep.git Commit right before adding the keylist --- diff --git a/lib/DBM/Deep.pm b/lib/DBM/Deep.pm index 75aee67..90005ce 100644 --- a/lib/DBM/Deep.pm +++ b/lib/DBM/Deep.pm @@ -129,7 +129,7 @@ sub _init { $self->{$param} = $args->{$param}; } - $self->{engine}->setup_fh( $self ); + $self->_engine->setup_fh( $self ); $self->{fileobj}->set_db( $self ); @@ -277,7 +277,7 @@ sub optimize { $self->unlock(); $self->_fileobj->close; $self->_fileobj->open; - $self->{engine}->setup_fh( $self ); + $self->_engine->setup_fh( $self ); return 1; } @@ -342,6 +342,11 @@ sub commit { # Accessor methods ## +sub _engine { + my $self = $_[0]->_get_self; + return $self->{engine}; +} + sub _fileobj { my $self = $_[0]->_get_self; return $self->{fileobj}; @@ -464,9 +469,9 @@ sub STORE { ## $self->lock( LOCK_EX ); - my $md5 = $self->{engine}{digest}->($key); + my $md5 = $self->_engine->{digest}->($key); - my $tag = $self->{engine}->find_bucket_list( $self->_base_offset, $md5, { create => 1 } ); + my $tag = $self->_engine->find_blist( $self->_base_offset, $md5, { create => 1 } ); # User may be storing a hash, in which case we do not want it run # through the filtering system @@ -477,7 +482,7 @@ sub STORE { ## # Add key/value to bucket list ## - $self->{engine}->add_bucket( $tag, $md5, $key, $value, undef, $orig_key ); + $self->_engine->add_bucket( $tag, $md5, $key, $value, undef, $orig_key ); $self->unlock(); @@ -491,14 +496,14 @@ sub FETCH { my $self = shift->_get_self; my ($key, $orig_key) = @_; - my $md5 = $self->{engine}{digest}->($key); + my $md5 = $self->_engine->{digest}->($key); ## # Request shared lock for reading ## $self->lock( LOCK_SH ); - my $tag = $self->{engine}->find_bucket_list( $self->_base_offset, $md5 );#, { create => 1 } ); + my $tag = $self->_engine->find_blist( $self->_base_offset, $md5 );#, { create => 1 } ); #XXX This needs to autovivify if (!$tag) { $self->unlock(); @@ -508,7 +513,7 @@ sub FETCH { ## # Get value from bucket list ## - my $result = $self->{engine}->get_bucket_value( $tag, $md5, $orig_key ); + my $result = $self->_engine->get_bucket_value( $tag, $md5, $orig_key ); $self->unlock(); @@ -545,9 +550,9 @@ sub DELETE { ## $self->lock( LOCK_EX ); - my $md5 = $self->{engine}{digest}->($key); + my $md5 = $self->_engine->{digest}->($key); - my $tag = $self->{engine}->find_bucket_list( $self->_base_offset, $md5 ); + my $tag = $self->_engine->find_blist( $self->_base_offset, $md5 ); if (!$tag) { $self->unlock(); return; @@ -556,13 +561,13 @@ sub DELETE { ## # Delete bucket ## - my $value = $self->{engine}->get_bucket_value( $tag, $md5 ); + my $value = $self->_engine->get_bucket_value( $tag, $md5 ); if (defined $value && !ref($value) && $self->_fileobj->{filter_fetch_value}) { $value = $self->_fileobj->{filter_fetch_value}->($value); } - my $result = $self->{engine}->delete_bucket( $tag, $md5, $orig_key ); + my $result = $self->_engine->delete_bucket( $tag, $md5, $orig_key ); ## # If this object is an array and the key deleted was on the end of the stack, @@ -581,14 +586,14 @@ sub EXISTS { my $self = shift->_get_self; my ($key) = @_; - my $md5 = $self->{engine}{digest}->($key); + my $md5 = $self->_engine->{digest}->($key); ## # Request shared lock for reading ## $self->lock( LOCK_SH ); - my $tag = $self->{engine}->find_bucket_list( $self->_base_offset, $md5 ); + my $tag = $self->_engine->find_blist( $self->_base_offset, $md5 ); if (!$tag) { $self->unlock(); @@ -601,7 +606,7 @@ sub EXISTS { ## # Check if bucket exists and return 1 or '' ## - my $result = $self->{engine}->bucket_exists( $tag, $md5 ) || ''; + my $result = $self->_engine->bucket_exists( $tag, $md5 ) || ''; $self->unlock(); @@ -637,9 +642,9 @@ sub CLEAR { $self->lock( LOCK_EX ); #XXX This needs updating to use _release_space - $self->{engine}->write_tag( + $self->_engine->write_tag( $self->_base_offset, $self->_type, - chr(0)x$self->{engine}{index_size}, + chr(0)x$self->_engine->{index_size}, ); $self->unlock(); diff --git a/lib/DBM/Deep/Array.pm b/lib/DBM/Deep/Array.pm index 65af4a7..ae8dba8 100644 --- a/lib/DBM/Deep/Array.pm +++ b/lib/DBM/Deep/Array.pm @@ -61,7 +61,7 @@ sub FETCH { } } - $key = pack($self->{engine}{long_pack}, $key); + $key = pack($self->_engine->{long_pack}, $key); } my $rv = $self->SUPER::FETCH( $key, $orig_key ); @@ -92,7 +92,7 @@ sub STORE { } } - $key = pack($self->{engine}{long_pack}, $key); + $key = pack($self->_engine->{long_pack}, $key); } my $rv = $self->SUPER::STORE( $key, $value, $orig_key ); @@ -124,7 +124,7 @@ sub EXISTS { } } - $key = pack($self->{engine}{long_pack}, $key); + $key = pack($self->_engine->{long_pack}, $key); } my $rv = $self->SUPER::EXISTS( $key ); @@ -153,7 +153,7 @@ sub DELETE { } } - $key = pack($self->{engine}{long_pack}, $key); + $key = pack($self->_engine->{long_pack}, $key); } my $rv = $self->SUPER::DELETE( $key, $orig ); @@ -182,7 +182,7 @@ sub FETCHSIZE { $self->unlock; if ($packed_size) { - return int(unpack($self->{engine}{long_pack}, $packed_size)); + return int(unpack($self->_engine->{long_pack}, $packed_size)); } return 0; @@ -197,7 +197,7 @@ sub STORESIZE { my $SAVE_FILTER = $self->_fileobj->{filter_store_value}; $self->_fileobj->{filter_store_value} = undef; - my $result = $self->STORE('length', pack($self->{engine}{long_pack}, $new_length), 'length'); + my $result = $self->STORE('length', pack($self->_engine->{long_pack}, $new_length), 'length'); $self->_fileobj->{filter_store_value} = $SAVE_FILTER; diff --git a/lib/DBM/Deep/Engine.pm b/lib/DBM/Deep/Engine.pm index 0ceb233..b2070c2 100644 --- a/lib/DBM/Deep/Engine.pm +++ b/lib/DBM/Deep/Engine.pm @@ -253,6 +253,7 @@ sub write_tag { return { signature => $sig, + #XXX Is this even used? size => $size, offset => $offset + SIG_SIZE + $self->{data_size}, content => $content @@ -275,6 +276,7 @@ sub load_tag { return { signature => $sig, + #XXX Is this even used? size => $size, offset => $offset + SIG_SIZE + $self->{data_size}, content => $fileobj->read_at( undef, $size ), @@ -699,7 +701,7 @@ sub bucket_exists { return ($subloc && !$is_deleted) && 1; } -sub find_bucket_list { +sub find_blist { ## # Locate offset for bucket list, given digested key ## diff --git a/lib/DBM/Deep/Hash.pm b/lib/DBM/Deep/Hash.pm index a86ac10..bebc926 100644 --- a/lib/DBM/Deep/Hash.pm +++ b/lib/DBM/Deep/Hash.pm @@ -91,7 +91,7 @@ sub FIRSTKEY { ## $self->lock( $self->LOCK_SH ); - my $result = $self->{engine}->get_next_key($self); + my $result = $self->_engine->get_next_key($self); $self->unlock(); @@ -110,14 +110,14 @@ sub NEXTKEY { ? $self->_fileobj->{filter_store_key}->($_[0]) : $_[0]; - my $prev_md5 = $self->{engine}{digest}->($prev_key); + my $prev_md5 = $self->_engine->{digest}->($prev_key); ## # Request shared lock for reading ## $self->lock( $self->LOCK_SH ); - my $result = $self->{engine}->get_next_key( $self, $prev_md5 ); + my $result = $self->_engine->get_next_key( $self, $prev_md5 ); $self->unlock();