dbTalk Databases Forums  

dynamic tables and serialization of vectors

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


Discuss dynamic tables and serialization of vectors in the comp.databases.berkeley-db forum.



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

Default dynamic tables and serialization of vectors - 10-22-2003 , 07:22 AM






I am posting this to two not so directly related groups. But i feel it
belongs to both.
I am trying to create a database at runtime in Berkeley DB and insert
and retrieve values from it. So I cannot pre compile the schema into a
C++ struct, as explained in the sleepycat documentation.
1) What is the most effecient way to do this? (This is a Berkeley DB
question)

Now coming to the C++ part. To explain the context to C++ newsgroup
readers, Berkeley DB has the concept of key , value pairs to insert
data
Dbt key, value
struct Dbt {
void *data;
int size;
----
-----// some other not so relevant fields
}

They are defined as generic pointers.Also one has to enter the size
in bytes occupied by the pointer.
The solution I came up with is to define a vector.
vector<myType> *x
where myType is a union of int , string and may be some more data
types like timestamp.
Insert the column values into the vector.
My question is how to convert x into a void * pointer and serialize
the data.
I need to find the length in bytes occupied by vector to serialize it.
How to find it. Is raw_storage_iterator the way to go?

Reply With Quote
  #2  
Old   
Juan Antonio Domínguez Pérez
 
Posts: n/a

Default Re: dynamic tables and serialization of vectors - 10-22-2003 , 12:29 PM






Ninan Thomas wrote:
Quote:
I am posting this to two not so directly related groups. But i feel it
belongs to both.
I am trying to create a database at runtime in Berkeley DB and insert
and retrieve values from it. So I cannot pre compile the schema into a
C++ struct, as explained in the sleepycat documentation.
1) What is the most effecient way to do this? (This is a Berkeley DB
question)
You are at the rigth way. Keep the elements using a vector, easy to use
with your algorithms, and keep persistence in a bdb. When you want to
write the db file, do dynamic allocation and write the complete buffer.
You cant do it any other way, because you cannot be confident of the
vector implementation; anyway, the raw_storage_iterator will not be of
any use for you, because the elements are an union of diferent types and
you must (?) choose in any way the member of the union you want to storage.



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.