473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 2356
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Tan Thuan Seah | last post by:
Hi all, I was told this in one of the university course I was doing. In C we may expect good performance for: double a, c, d; for (i=0; i<N; i++) for(j=0; j<N; j++) a = a + c *d;
4
by: Leslaw Bieniasz | last post by:
Cracow, 20.10.2004 Hello, As far as I understand, the generic programming basically consists in using templates for achieving a static polymorphism of the various code fragments, and their...
15
by: rwf_20 | last post by:
I just wanted to throw this up here in case anyone smarter than me has a suggestion/workaround: Problem: I have a classic producer/consumer system which accepts 'commands' from a socket and...
15
by: Herby | last post by:
This is a follow on from my previous thread about clr/safe and STL.NET ...
60
by: Peter Olcott | last post by:
I need to know how to get the solution mentioned below to work. The solution is from gbayles Jan 29 2001, 12:50 pm, link is provided below: >...
0
by: todddeluca | last post by:
I am posting code for calling almost any python function from php, because it seems generally useful. Please feel free to suggest improvements or tell me this has already been done better...
13
by: Ninan | last post by:
struct A { int a; int b; virtual ~A(); } struct B : public A { int c;
11
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
11
by: William | last post by:
I'm looking for an example that would show how to serialize a c++ object at it's simplest w/o using any other api's. I have a class that I want to serialize and then pass to my obj-c class so I can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.