dbTalk Databases Forums  

DBT question - BerkeleyDB - www.sleepycat.com

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


Discuss DBT question - BerkeleyDB - www.sleepycat.com in the comp.databases.berkeley-db forum.



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

Default DBT question - BerkeleyDB - www.sleepycat.com - 09-30-2003 , 09:18 AM






Hi!

I don't know if anyone can respond to this:

Is is possible to put the DBT in a struct, then declare an array of
DBTs? This array will be declared dynamically.

I want to call DBcursor->c_get and DB->get multiple times and store
the result(s) in this structure. Then close the cursors.

I know berkeley manages the memory and what the DBT points to, but how
long will these DBT references last? Will berkeley handle all the
memory/disk manangement? Will this work successfully? I am going to be
testing this, but if it will not work it would be nice to know now.
Will this work if the DB->set_cachesize is small?

Thanks in advance to anyone who responds.

typedef struct {
DBT key;
DBT data;
} GCT_MITEM;

GCT_MITEM mydbts[100];



From Berkeley help file:
When returning a key/data item to the application, Berkeley DB will
store into the data structure element a pointer to a byte string of
size bytes, and the memory to which the pointer refers will be
allocated and managed by Berkeley DB.

Reply With Quote
  #2  
Old   
Keith Bostic
 
Posts: n/a

Default Re: DBT question - BerkeleyDB - www.sleepycat.com - 10-01-2003 , 03:20 PM






niagara_man (AT) hotmail (DOT) com (Derick Smith) wrote in message news:<99805581.0309300618.549f9c1b (AT) posting (DOT) google.com>...
Quote:
Is is possible to put the DBT in a struct, then declare an array of
DBTs? This array will be declared dynamically.

I want to call DBcursor->c_get and DB->get multiple times and store
the result(s) in this structure. Then close the cursors.
The documentation you should review is the "Retrieved key/data
permanence for C/C++" section of the Berkeley DB Reference
Guide, included in your download package and also available at:

http://www.sleepycat.com/docs/ref/am_misc/perm.html

Basically, if Berkeley DB is managing the memory used to store
returned key/data pairs, that memory may be re-used as soon as
the next call made to Berkeley DB using the handle for which
the key/data pair was returned.

Of course, if you use the DB_DBT_{MALLOC,REALLOC,USERMEM} flags,
then the memory holding the returned key/data pairs is owned by
the application, and is available until the application decides
to reclaim it.

Regards,
--keith

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Keith Bostic bostic (AT) sleepycat (DOT) com
Sleepycat Software Inc. keithbosticim (ymsgid)
118 Tower Rd. +1-781-259-3139
Lincoln, MA 01773 http://www.sleepycat.com


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.