471,613 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,613 software developers and data experts.

dynamic tables and serialization of vectors

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?
Jul 19 '05 #1
1 2306
Ninan Thomas wrote:
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.

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Tan Thuan Seah | last post: by
4 posts views Thread by Leslaw Bieniasz | last post: by
15 posts views Thread by rwf_20 | last post: by
15 posts views Thread by Herby | last post: by
60 posts views Thread by Peter Olcott | last post: by
reply views Thread by todddeluca | last post: by
13 posts views Thread by Ninan | last post: by
11 posts views Thread by toton | last post: by
11 posts views Thread by William | last post: by
1 post views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.