# Please refer to the pack() documentation for further information
my %StP = (
- 1 => 'C', # Unsigned char value
+ 1 => 'C', # Unsigned char value (no order specified, presumably ASCII)
2 => 'n', # Unsigned short in "network" (big-endian) order
4 => 'N', # Unsigned long in "network" (big-endian) order
8 => 'Q', # Usigned quad (no order specified, presumably machine-dependent)
DBM::Deep->_throw_error( "Cannot commit without a transaction" );
}
- #print "TID: " . $self->trans_id, $/;
foreach my $entry (@{ $self->get_entries } ) {
- #print "$entry\n";
# Overwrite the entry in head with the entry in trans_id
my $base = $entry
+ $self->hash_size
sub get_txn_staleness_counter {
my $self = shift;
my ($trans_id) = @_;
+
+ # Hardcode staleness of 0 for the HEAD
+ return 0 unless $trans_id;
+
my $x = unpack( 'N',
$self->storage->read_at(
- $self->trans_loc + 4 * ($trans_id - 1),
+ $self->trans_loc + 4 * $trans_id,
4,
)
);
- print "$trans_id => $x\n";
return $x;
}
sub inc_txn_staleness_counter {
my $self = shift;
my ($trans_id) = @_;
+
+ # Hardcode staleness of 0 for the HEAD
+ return unless $trans_id;
+
$self->storage->print_at(
- $self->trans_loc + 4 * ($trans_id - 1),
+ $self->trans_loc + 4 * $trans_id,
pack( 'N', $self->get_txn_staleness_counter( $trans_id ) + 1 ),
);
}
my $self = shift;
my ($trans_id, $loc) = @_;
- #print "$trans_id => $loc\n";
$self->{entries}{$trans_id} ||= {};
$self->{entries}{$trans_id}{$loc} = undef;
- #use Data::Dumper;print "$self: " . Dumper $self->{entries};
}
sub clear_entries {
my $self = shift;
- #print "Clearing\n";
delete $self->{entries}{$self->trans_id};
}
# --- Above is $header_fixed. Below is $header_var
pack('C', $self->byte_size),
pack('C', $self->max_buckets),
- pack('N', 0 ), # Transaction cctiveness bitfield
- pack('N' . $self->num_txns, 0 ), # Transaction staleness counters
+ pack('N', 0 ), # Transaction activeness bitfield
+ pack('N' . $self->num_txns, 0 x $self->num_txns ), # Transaction staleness counters
pack($StP{$self->byte_size}, 0), # Start of free chain (blist size)
pack($StP{$self->byte_size}, 0), # Start of free chain (data size)
);
if ( @trans_ids ) {
my $old_value = $blist->get_data_for;
foreach my $other_trans_id ( @trans_ids ) {
- next if $blist->get_data_location_for({ trans_id => $other_trans_id, allow_head => 0 });
- #print "write_md5 to save a value\n";
+ next if $blist->get_data_location_for({
+ trans_id => $other_trans_id,
+ allow_head => 0,
+ });
$blist->write_md5({
trans_id => $other_trans_id,
key => $args->{key},
$args->{trans_id} = $engine->trans_id unless exists $args->{trans_id};
my $spot = $self->offset + $self->base_size + $self->{idx} * $self->bucket_size;
- #print "Adding $args->{trans_id} -> $spot\n";
$engine->add_entry( $args->{trans_id}, $spot );
unless ($self->{found}) {
# We have found an entry that is old, so get rid of it
if ( $staleness != (my $s = $e->get_txn_staleness_counter( $args->{trans_id} ) ) ) {
- print "Killing $args->{trans_id} ( $staleness <-> $s )\n";
$e->storage->print_at(
$spot,
pack( $StP{$e->byte_size} . ' N', (0) x 2 ),