dsh_t vs dbh_t

David Relson relson at osagesoftware.com
Mon Jun 7 20:01:57 CEST 2004


Matthias,

Reading the code in datastore.c and datastore_*db.c, I just noticed that
the line between the (abstract) datastore level and the (concrete)
database level has gotten blurred.  

First, many of the db_xxx() functions have a "dsh_t *" pointer as their
first argument (though it's declared as a "void *").  The first thing
that these functions do is "dbh_t *dbh = (dsh_t *)dsh->dbh.

Others of the db_xxx() functions have a "dbh_t *" pointer as their first
argument, which is fine.

As a cleanup, db_xxx() functions will be converted from the "dsh_t *"
parameter to a "dbh_t *" parameter.

Secondly, db_open() calls dsh_init() so it can return a "dsh_t *" to its
caller, i.e. ds_open().  This is an instance of a (low level) database
routine calling a (high level) datastore routine in order to return a
(high level) datastore type -- all of which is a hierarchy violation. 
db_open() should return a "dbh_t *" and let ds_open() worry about the
dsh_init() call.

A drawback of this is that dsh_init() needs to know whether the data is
byte-swapped or not, which means function "bool db_is_swapped(void
*vhandle)" needs to be defined in each of the datastore_*.c modules.

I'm working on a patch to clean all this up.  Likely, it will affect the
txn code :-(

David

-- 
David Relson                   Osage Software Systems, Inc.
relson at osagesoftware.com       Ann Arbor, MI 48103
www.osagesoftware.com          tel:  734.821.8800



More information about the bogofilter-dev mailing list