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)
// 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.
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.