my $self = shift;
my ($trans_id, $base_offset, $key) = @_;
-# print "Trying to read $key from $base_offset ($trans_id)\n" if $key > 400;
my ($_val_offset, $_is_del) = $self->_find_value_offset({
offset => $base_offset,
trans_id => $trans_id,
return $self->_read_value({
keyloc => $key_tag->{start},
offset => $val_offset,
+ key => $key,
});
}
};
}
+ local $::DEBUG = 1;
+ print "get_next_key: $_val_offset\n" if $::DEBUG;
return $self->traverse_index( $temp, $_val_offset, 0 );
}
# Need to create a new keytag, too
if ( $bucket_tag->{is_new} ) {
-# print "Creating new keytag\n";
my $keytag_loc = $self->_storage->request_space(
$self->tag_size( $self->{keyloc_size} ),
);
# If we have a subloc to return or we don't want to create a new
# entry, we need to return now.
$args->{create} ||= 0;
-# print "Found ($subloc) at $index ($args->{create})\n";
return ($self->load_tag( $subloc ), $bucket_tag) if $subloc || !$args->{create};
my $keytag_loc = $self->_storage->request_space(
# There's space left in this bucket
if ( defined $index ) {
-# print "There's space left in the bucket for $keytag_loc\n";
substr( $bucket_tag->{content}, $index * $self->{key_size}, $self->{key_size} ) =
$args->{key_md5} . pack( "$self->{long_pack}", $keytag_loc );
}
# We need to split the index
else {
-# print "Splitting the index for $keytag_loc\n";
$self->split_index( $bucket_tag, $args->{key_md5}, $keytag_loc );
}
my $self = shift;
my ($args) = @_;
- return $self->read_from_loc( $args->{keyloc}, $args->{offset} );
+ return $self->read_from_loc( $args->{keyloc}, $args->{offset}, $args->{key} );
}
sub _mark_as_deleted {
$obj->{base_offset} = $self->_storage->request_space(
$self->tag_size( $self->{keyloc_size} ),
);
- warn "INITIAL BASE OFFSET: $obj->{base_offset}\n";
my $value_spot = $self->_storage->request_space(
$self->tag_size( $self->{index_size} ),
}
else {
$obj->{base_offset} = $bytes_read;
- warn "REOPEN BASE OFFSET: $obj->{base_offset}\n";
my ($_val_offset, $_is_del) = $self->_find_value_offset({
offset => $obj->{base_offset},
# first things first, get us about 1000 keys so the optimize() will take
# at least a few seconds on any machine, and re-open db with locking
##
- for (1..1000) { $db->STORE( $_, $_ ); }
+ for (11..11) { $db->STORE( $_, $_ +1 ); }
undef $db;
##
exit( 0 );
}
-
+=pod
# parent fork
ok( defined($pid), "fork was successful" ); # make sure fork was successful
autoflush => 1,
locking => 1
);
-
+
# sleep for 1 second to make sure optimize() is running in the other fork
sleep(1);
# now check some existing values from before
is( $db->{key1}, 'value1', "key1's value is still there after optimize" );
is( $db->{a}{c}, 'value2', "key2's value is still there after optimize" );
+=cut
}