dbTalk Databases Forums  

When get() change the key/data length value ?

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


Discuss When get() change the key/data length value ? in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default When get() change the key/data length value ? - 07-22-2006 , 10:56 AM






Hello,

I am very surprised when I introduce a variable as key/data length
because the function get() alter the key/data length value. Due to this
problem I have to do reset the value of key/data length.

Could some one tell me in which case get() alter the key/data length
value. My database have fix length key/data that does not cause buffer
too small error.
The fact to reset each time the key/data length value cause loss of
performance.

This is a sample of my code:

int key_data_length= sizeof(int); // I think this line is sufficient.
while ( get(&key, key_data_length, DB_NEXT_NODUP) )
{
while ( get(&key, key_data_length, DB_NEXT_DUP) );
key_data_length = sizeof(int);
// Why this last line ??? This decrease performance.
// Why the get() change the key_data_length. Note that all
// data/key in my data base are fixed length to int.
//
}

Thank you.


Reply With Quote
  #2  
Old   
Michael Cahill
 
Posts: n/a

Default Re: When get() change the key/data length value ? - 07-23-2006 , 11:47 PM






Hi,

Quote:
This is a sample of my code:

int key_data_length= sizeof(int); // I think this line is sufficient.
while ( get(&key, key_data_length, DB_NEXT_NODUP) )
If this "get" is a function you have implemented that calls DB, there
is no way that it could be modifying key_data_length, since you are
passing by value.

If this is shorthand for a call to this cursor method:

dbc->c_get(dbc, &key, key_data_length, DB_NEXT_NODUP)

then I'm surprised that it compiles. Aren't there warnings?

The third parameter in this call (where you are passing key_data_lenth)
should be a pointer to a DBT that will hold the data value part of the
key/data pair.

If I've misunderstood, can you please post the code that actually makes
the call to Berkeley DB?

Regards,
Michael.



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.