BerkeleyDB Queue Database Array Size



I've been playing around with BerkeleyDB Queue database type, and I've
found something curious.

I'm tying an array variable to the queue database:
$db = tie @samplearray, 'BerkeleyDB::Queue',
-Flags => DB_CREATE,
-Filename => $config->get('db_queue_filename'),
-Env => $env,
-Len => 300
or print "$BerkeleyDB::Error\n" ;

I'm adding records to the database by pushing values into the array:
push @samplearray, $u or die "can't push $u $!\n";

And I'm pulling records from the beginning of the database using shift:
shift @samplearray;

Everything is working brilliantly - although I haven't tried
multiprocess access to the database which is a desired future step.
The curiosity that I have found is this:

$k = $#samplearray;
print "$k \n";

When the array is not "tied" to the BerkeleyDB, this number will shrink
every time I shift a record out of the array - If I pull out 5 of 5
items, it would report 3,2,1,0,-1. However, when it is tied to the
database, it will always report the maximum queue size until there is
nothing left in the queue, at which point it will return -1 like it
normally would if it was just an array. In the above example - it's
4,4,4,4,-1

I tried calling $db->sync after pulling items out, but the issue still
exists. Being a bit of a newbie, I don't know if this is a problem
with the way I am implementing things, my technical understanding, or
if this is an actual bug. Any guidance is appreciated.

Thanks,
Steve

.



Relevant Pages

  • Re: KirbyBase
    ... creating objects from the database records was much easier. ... Hal, I don't know if you have had a chance to take a look at the beta yet, but I basically tried to implement a uniform way to specify one-to-one links, one-to-many links, and calculated fields in the ... I suppose it would in effect be embedding an array where all the ... My first couple of attempts at adding more complexity to KirbyBase did not honor this concept. ...
    (comp.lang.ruby)
  • Re: KirbyBase
    ... I'm an Object Guy and Jamey is a Database Guy. ... That requires the table name and key field name to be specified ... I suppose it would in effect be embedding an array where all the ... that is) might compress by a factor of 10 or more. ...
    (comp.lang.ruby)
  • Re: using BLOB objects and ...
    ... while saving the array object to the database which is ok but while ... convert it back to object of 4 dimention boolean array which will be ... will let you store your 4 dimensional boolean array in it. ... You may have to modify my suggestion ...
    (comp.lang.java.programmer)
  • Re: using BLOB objects and ...
    ... - You could use Memo if you converted your boolean array into a text string. ... boolean array when you fetch it from the database. ... You might be able to put the whole array in an OLE Object, ...
    (comp.lang.java.programmer)
  • Re: Permutations - 8 columns
    ... Thanks Markos for your input. ... SQL driver to access the database, I will have to use the long way to ... > Dim TotalAccounts As Long, ... We declare and resize an array variable with the ...
    (microsoft.public.excel.programming)