dbTalk Databases Forums  

Does Berkeley DB use the random number generator?

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss Does Berkeley DB use the random number generator? in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
gerol80 (Offline)
Junior Member
 
Posts: 6
Join Date: May 2006

Default Does Berkeley DB use the random number generator? - 05-11-2006 , 09:14 AM






I'm comparing some database system, amongst others Berkeley DB. So I wrote an application that fills random data into the different database systems. To be able to compare the database systems it is important that the random data is equal at every pass --- therefore I initialize srand() with a fixed seed.

This works e.g. with SQLite. The random data is equal every time I run the application. But with Berkeley DB the random data is different anytime. How could that be?? Does Berkeley DB initialize srand() with another seed?

Reply With Quote
  #2  
Old   
Florian Weimer
 
Posts: n/a

Default Re: Does Berkeley DB use the random number generator? - 05-11-2006 , 02:02 PM






* gerol:

Quote:
I'm comparing some database system, amongst others Berkeley DB. So I
wrote an application that fills random data into the different database
systems. To be able to compare the database systems it is important that
the random data is equal at every pass --- therefore I initialize
srand() with a fixed seed.
Write your own random number generator, for instance (completely
untested, but the magic number 134775813 shouldn't be too bad):

uint32_t my_seed = 1;

uint32_t my_random(void)
{
my_seed = 134775813 * my_seed + 1;
return my_seed;
}

Then you need not care if anybody else calls rand().


Reply With Quote
  #3  
Old   
TungstenCoil
 
Posts: n/a

Default Re: Does Berkeley DB use the random number generator? - 05-16-2006 , 05:40 PM



I do not know explicitly if the BDB uses rand() (though the source code
is there, you could probably search) but I do have a test framework
that depends on somethign similar, and have had no issue with it.

Since my test framework is multi-threaded, and rand() is not required
to be threadsafe (according to the ANSI/ISO standards), I do have it
resource-locked, however.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.