[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    GDBM kab backend test code
From:       Rik Hemsley <rik () rikkus ! demon ! co ! uk>
Date:       1999-07-20 20:05:03
[Download RAW message or body]


I've had a go at using gdbm as a database backend for saving objects.

As I've said before, I don't know if it's possible to save QString to a text
file as the values may be 16 bit. Of course it could be encoded but that's
probably not very efficient.

gdbm allows for storing arbritary types using arbritary keys.

This fits with the model I have used in my ab_test/v2 code where every Entity
is stored in the time-honoured key,value format.

The code I'm checking in (in pim/kab_backend_test) creates an Entity (just
a simplified version, containing two QStrings) and saves it to the
KabGDBMBackend, which is derived from KabBackend. It then loads this entity
back.

This is really code that I've written to see if it works, but it serves
as a demonstration of how to save and load objects of any type and reference
them using keys.

I make use of streaming to write QStrings (and of course any other object) to
a QDataStream, which uses a QByteArray as its QIODevice. This QByteArray is
then used for the raw data to save.

I think this is an efficient method for both storage and retrieval. There's
not much overhead, just the streaming, which I presume is fairly efficient.
Streaming Qt types is very fast in Empath where I use it to index Maildir.

I'd appreciate it if someone would have a look at this (it should compile
anywhere with Qt and gdbm - no namespaces Don ;) and let me know what they
think.

I would suggest that this may be a real possibility for a bare-bones backend.
It doesn't provide any searching/sorting facilities, but I think it'll be
impossible to find a backend that does, unless it understands our value types,
including how to read QString. I think the searching/sorting will have to be
implemented within kab.

Cheers,
Rik


--
KDE - Colour outside the lines  : http://www.kde.org
[[without]] - software for KDE  : http://without.netpedia.net

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic