embeddable early-binded database

C

CAFxX

hi all,
I was wondering whenever it is possible to write an embeddable
early-binding database in c++ (mainly for performance reasons).
the point is that often the programmer knows at compile time the
structure of the tables he uses, so why not trying to take advantage of
this to gain something in speed (and maybe size) (e.g. by allowing the
compiler to inline the right comparison operator)?
conceptually it isn't very different from one of the STL containers like
map, except that instead of a single key-value pair, it can hold
multiple pairs (in the example below i called them indexes) and even
just values (fields).

for example:

// myLog is the user-defined struct
struct myLogStruct {
table::index <time_t> Timestamp;
table::index <unsigned> Resource;
table::field <unsigned> IP;
};

typedef table<myLogStruct> myLogTable;

[...]

// suppose we need to insert a new row
myLogTableInstance.Insert( myTimestamp, myResource, myIP );

// or, similarly,
myLogStructInstance.Timestamp = myTimestamp;
myLogStructInstance.Resource = myResource;
myLogStructInstance.IP = myIP;
myLogTableInstance.Insert( myLogStructInstance );

// then we may need to select all rows with Timestamp greater than some
// value
myLogTableInstance2 = myLogTableInstance.Select(myLogStruct::Timestamp)
> myTimestamp;

// finally, we may need to walk the table
for (myLogTableIterator = myLogTableInstance2.First();
myLogTableIterator != myLogTableInstance2.Last(); myLogTableIterator++)
doSomething();


has anyone ever seen something like this? do you think is it technically
possible (and/or worth)?

bye, CAFxX.
 
C

CAFxX

CAFxX ha scritto:
// then we may need to select all rows with Timestamp greater than some
// value
myLogTableInstance2 = myLogTableInstance.Select(myLogStruct::Timestamp)

sorry, the line above should be

myLogTableInstance2 = myLogTableInstance.Timestamp > myTimestamp;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top