Genezzo::Block::RDBlock 0.60 review

by on is a Row Directory Block tied hash class

License: Perl Artistic License
File size: 0K
Developer: Jeffrey I Cohen
0 stars award from is a Row Directory Block tied hash class. A class that lets you treat the contents of a block (byte buffer) as a hash.

Note: This implementation is almost, but not quite, a pushhash. The push hash implementation is Genezzo::Row::RSBlock. It also forms the basis of a tied array in Genezzo::Block::RDBArray.


use Genezzo::Block::RDBlock;
use Genezzo::Block::Std;

local $Genezzo::Block::Std::DEFBLOCKSIZE = 500;

my $buff = "" x 500; # construct an empty byte buffer

my %tied_hash = ();

my $tie_val =
tie %tied_hash, 'Genezzo::Block::RDBlock', (refbufstr => $buff);

# pushhash style
# (note that the "PUSH" pseudo key is not supported)...
my $newkey = $tie_val->HPush("this is a test");

# or array style, your choice
my $pushcount = $tie_val->PUSH(qw(push lots of data));

$tied_hash{$newkey} = "update this entry";

# a hash that supports array style FETCHSIZE
my $getcount = $tie_val->FETCHSIZE(); # Note: not HCount

RDBlock is the basis for persistent tied hashes, pushhashes, and tied arrays. After the hash is tied to the byte buffer, the buffer can be written to persistent storage. The storage is designed such that inserts/appends/pushes are fairly efficient, and deletes are inexpensive. The pctfree/pctused parameters allow some tuning to reserve space in the buffer for updates that "grow" existing values.

Updates that do not change the packed size of data are about as efficient as insert/appends -- just the cost to copy your bytes into the buffer -- but updates that do change the size of stored values can require a large amount of byte shifting to open up storage space. Also, the buffer does not grow to accomodate large values. Wrapper classes are necessary to specify mechanisms for packing complex data structures and techniques to split objects across multiple buffers.


refbufstr (Required) - a reference to the byte buffer used for storage.
blocksize (Optional) - the size of the supplied byte buffer. Default is $Genezzo::Block::Std::DEFBLOCKSIZE.

pctfree (Optional) - the percentage of space kept free for future updates. Default is 30 (percent).

pctused (Optional) - after the block is full, the percentage of space that must be open before inserts are re-enabled. Default is 50 (percent).


Genezzo::Block::RDBlock 0.60 search tags