From: rkinyon Date: Thu, 25 May 2006 18:21:56 +0000 (+0000) Subject: r13306@rob-kinyons-powerbook58: rob | 2006-05-18 16:15:49 -0400 X-Git-Tag: 0-99_03~30 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e5a9d386f8a0eeba8777a0ac98c78274baff3efb;p=dbsrgits%2FDBM-Deep.git r13306@rob-kinyons-powerbook58: rob | 2006-05-18 16:15:49 -0400 Converted FETCH --- diff --git a/lib/DBM/Deep.pm b/lib/DBM/Deep.pm index a1c3781..961da94 100644 --- a/lib/DBM/Deep.pm +++ b/lib/DBM/Deep.pm @@ -514,17 +514,7 @@ sub FETCH { ## $self->lock( LOCK_SH ); - my $tag = $self->_engine->find_blist( $self->_base_offset, $md5 );#, { create => 1 } ); - #XXX This needs to autovivify - if (!$tag) { - $self->unlock(); - return; - } - - ## - # Get value from bucket list - ## - my $result = $self->_engine->get_bucket_value( $tag, $md5, $orig_key ); + my $result = $self->_engine->read_value( $self->_base_offset, $key, $orig_key ); $self->unlock(); diff --git a/lib/DBM/Deep/Engine.pm b/lib/DBM/Deep/Engine.pm index 13976e8..54ec75d 100644 --- a/lib/DBM/Deep/Engine.pm +++ b/lib/DBM/Deep/Engine.pm @@ -54,20 +54,22 @@ sub write_value { sub read_value { my $self = shift; - my ($offset, $key) = @_; + my ($offset, $key, $orig_key) = @_; my $dig_key = $self->apply_digest( $key ); - my $tag = $self->find_blist( $offset, $dig_key ); - return $self->get_bucket_value( $tag, $dig_key, $key ); + my $tag = $self->find_blist( $offset, $dig_key ) or return; + return $self->get_bucket_value( $tag, $dig_key, $orig_key ); } sub delete_key { my $self = shift; - my ($offset, $key) = @_; + my ($offset, $key, $orig_key) = @_; my $dig_key = $self->apply_digest( $key ); - my $tag = $self->find_blist( $offset, $dig_key ); - return $self->delete_bucket( $tag, $dig_key, $key ); + my $tag = $self->find_blist( $offset, $dig_key ) or return; + my $value = $self->get_bucket_value( $tag, $dig_key, $orig_key ); + $self->delete_bucket( $tag, $dig_key, $orig_key ); + return $value; } sub key_exists { @@ -75,7 +77,8 @@ sub key_exists { my ($offset, $key) = @_; my $dig_key = $self->apply_digest( $key ); - my $tag = $self->find_blist( $offset, $dig_key ); + # exists() returns the empty string, not undef + my $tag = $self->find_blist( $offset, $dig_key ) or return ''; return $self->bucket_exists( $tag, $dig_key, $key ); }