Revision history for DBM::Deep.
1.0004 Sep 25 00:00:00 2007 EDT
- - Fixed the Changes file
+ - Fixed the Changes file (wrong version was displayed for 1.0003)
- Added filter sugar methods to be more API-compatible with other DBMs
- - Implemented _dump_file in order to display the file structure.
- - Arrays now clean up after themselves better.
+ - Implemented _dump_file in order to display the file structure. As a
+ result, the following bugs are fixed:
+ - Arrays and hashes now clean up after themselves better.
- Bucketlists now clean up after themselves better.
- Reindexing properly clears the old bucketlist before freeing it.
sub exists { (shift)->EXISTS( @_ ) }
sub clear { (shift)->CLEAR( @_ ) }
-sub _dump_file {
- my $self = shift->_get_self;
- return $self->_engine->_dump_file;
-}
+sub _dump_file {shift->_get_self->_engine->_dump_file;}
1;
__END__
sub increment_refcount {
my $self = shift;
- my $e = $self->engine;
- my $refcount = unpack(
- $StP{$e->byte_size},
- $e->storage->read_at(
- $self->offset + $self->base_size + 2 * $e->byte_size, $e->byte_size,
- ),
- );
+ my $refcount = $self->get_refcount;
$refcount++;
- $e->storage->print_at(
- $self->offset + $self->base_size + 2 * $e->byte_size,
- pack( $StP{$e->byte_size}, $refcount ),
- );
+ $self->write_refcount( $refcount );
return $refcount;
}
sub decrement_refcount {
my $self = shift;
- my $e = $self->engine;
- my $refcount = unpack(
- $StP{$e->byte_size},
- $e->storage->read_at(
- $self->offset + $self->base_size + 2 * $e->byte_size, $e->byte_size,
- ),
- );
+ my $refcount = $self->get_refcount;
$refcount--;
- $e->storage->print_at(
- $self->offset + $self->base_size + 2 * $e->byte_size,
- pack( $StP{$e->byte_size}, $refcount ),
- );
+ $self->write_refcount( $refcount );
return $refcount;
}
);
}
+sub write_refcount {
+ my $self = shift;
+ my ($num) = @_;
+
+ my $e = $self->engine;
+ $e->storage->print_at(
+ $self->offset + $self->base_size + 2 * $e->byte_size,
+ pack( $StP{$e->byte_size}, $num ),
+ );
+}
+
package DBM::Deep::Engine::Sector::BucketList;
our @ISA = qw( DBM::Deep::Engine::Sector );
);
$db->{foo} = [];
-#$db->{bar} = $db->{foo};
+$db->{bar} = $db->{foo};
warn -s $filename, $/;
warn $db->_dump_file, $/;
$db->begin_work;
delete $db->{foo};
-# delete $db->{bar};
+ delete $db->{bar};
warn -s $filename, $/;
warn $db->_dump_file, $/;
warn -s $filename, $/;
warn $db->_dump_file, $/;
+
+$db->{foo} = 1;
+
+warn -s $filename, $/;
+warn $db->_dump_file, $/;
}
}
-plan tests => 192;
+plan tests => 202;
use t::common qw( new_fh );
use File::Spec;
'0.981', '0.982', '0.983',
'0.99_01', '0.99_02', '0.99_03', '0.99_04',
'1.00', '1.000', '1.0000', '1.0001', '1.0002',
- '1.0003',
+ '1.0003', '1.0004',
);
foreach my $input_filename (
eval "use DBM::Deep::10002";
$db = DBM::Deep::10002->new( $output_filename );
}
- elsif ( $v =~ /^1\.000[3]/ ) {
+ elsif ( $v =~ /^1\.000[34]/ ) {
push @INC, 'lib';
eval "use DBM::Deep";
$db = DBM::Deep->new( $output_filename );
my %opts = (
man => 0,
help => 0,
- version => '1.0003',
+ version => '1.0004',
autobless => 1,
);
GetOptions( \%opts,
elsif ( $ver =~ /^1\.000?[0-2]?/) {
$ver = 2;
}
- elsif ( $ver =~ /^1\.000[3]/) {
+ elsif ( $ver =~ /^1\.000[34]/) {
$ver = 3;
}
else {