|
Hi,
I tried using the VMS::IndexedFile on a key that allowed
duplicates, but I get strange results. The keys function returned the
wrong data, and the each function never returns undef so an infinite loop
ensues.
What would really be cool, if you could use some syntax like
this:
@subset = @hash{ 'ABC' };
Which when used on a dup key, would return the set of records
matching 'ABC'. This is pretty much a long shot, since it would require
the tie FETCH method to know it was in array context. I've tried wantarray
in a FETCH routine and it doesn't work.
Another idea might be to include the key criteria on the
TIEHASH method. That way you always tie to a subset of the data instead of
the entire table. Something like the following which
would tie the hash to only those rows matching duplicate key value
"ABC"
$mydupkey = 2;
tie( %h, 'VMS::IndexedFile', [ 'filespec' =>
"TEST.DAT", 'key' => $mydupkey, 'keyval' => "ABC",
'keylen' => 3 ] );
Maybe the best yet is to provide a couple of
methods for accessing data through duplicate keys. Since duplicate keys really don't fit the HASH paradigm, it would
probably be better to just provide a couple of methods that allowed you to
access multiple rows. Of course, you would probably have to disable FETCH,
STORE, DELETE, FIRSTKEY, NEXTKEY since they don't really make sense.
Something like the following which would also access those
rows matching duplicate key value "ABC"
$rv = $obj->First( "ABC", 3, $ctxt
);
while( $rv )
{
$rv =
$obj->Next("ABC",3, $ctxt );
}
thanks for listening...
Kevin Hoffman
|
- Re: Duplicate key reads on VMS::IndexedFile Kevin Hoffman
- Re: Duplicate key reads on VMS::IndexedFile Peter Prymmer
- Re: Duplicate key reads on VMS::IndexedFile Dan Sugalski
- Re: Duplicate key reads on VMS::IndexedFile Peter Prymmer
