BerkeleyDB 4.6 and GtkTreeModel

Over the vacation, I've been hacking on a few different projects, mostly Mono related this time. I've updated Joshua Tauber's BDB wrapper from 4.3 to 4.6. It has many hacks to make DB_RECNO databases more friendly. If you truly are interested in using it with 4.6, I suggest you diff the two versions and remove a few hacks I have.

Now, to the GtkTreeModel.

Having implemented many GtkTreeModel's over the last few years, I'm certainly not naive to the fundamental flaws it has for large data sets. However, we work with what we have, so I decided to make a BdbListStore which implements GtkTreeModel and fronts a BDB DB_RECNO database.

The reason I chose to front a DBRECNO instead of DBBTREE, which many people use, is so that GtkTreeIter iteration overhead and GtkTreePath conversions were simple and fast. You can see how bad GtkTreeIter iteration can kill you when you initially attach a GtkTreeModel to a GtkTreeView. Anyway, DBRECNO is still a btree, it just uses record numbers instead of user defined keys. The other caveat is that you use the flag DBRENUMBER. This keeps the keys within the tree juxtapose.

To keep deserialization overhead down, I used the generics based LRUCache found on Code Project. BDB already rocks at cache management, so this really was simply to not have to do the deserialization of objects on every render.

The original hack was in C which can be found here.

The C# version (BdbListStore<T>) can be found here. You will also need this for BdbCache<T>, this and this for the LRUCache implementation.

As an aside, I added highlighting to my gitweb. Email me if you want the horrible hack it contains. Its based on another hack floating on the web with some fixes to handle non-highlightable files.

-- Christian Hergert 2009-01-01

Back to Index