[ZODB-Dev] Questions on ZODB BTrees versus bsddb BTrees

Terry Jones terry at jon.es
Thu May 4 07:12:01 EDT 2006


I've just read the ZODB/ZEO Programming Guide (Release 3.6.0,
A.M. Kuchling, January 5, 2006) and I'd like to ask a few questions.

Are the following all correct?

 - The BTrees supported by ZODB have nothing to do with Berkeley DB Btrees
   (apart from the fact that they're both implementations of BTrees).

 - ZODB BTrees do not allow duplicate keys (a la bsddb).

 - ZODB BTrees do not allow you to set up secondary keys (a la bsddb).

And:

 - Is the byValue() ZODB BTree method officially deprecated? Scheduled for
   deprecation / removal?

 - Does byValue() use any kind of secondary index structure, or does it
   walk the whole tree? I guess the latter, seeing as to implement the
   former you'd ideally like something like a BTree allowing duplicate
   keys...


Assuming the first three above are correct, and that I would like both
duplicate keys and secondary keys in an application with ZODB-like
transparent persistent object storage, it looks like I have the following
options:

 1. Use both ZODB and bsddb in the same application, dealing with things
    like locking and transactions across both object types in a somewhat
    manual way.

    This would have the additional major downside of making it harder to
    use ZEO for storage, right? (Yes, I could pickle the entire bsddb
    databases and hand them to ZEO, but that's not really what I had in
    mind.)

 2. Try to add support for bsddb BTrees (with duplicate keys) to ZODB. I
    guess this is feasible, but it looks like it would make for some
    fundamental changes, as you would no longer have the dictionary-like
    interface to the keys of such a BTree.

    I guess this option would take a serious amount of work (which may not
    even be wanted by the ZODB maintainers).

 3. Redesign what I'm doing so as to only need ZODB BTrees. This is quite
    far from optimal (in terms of space and time), but might be the
    quickest to implement.

    However, this may not solve the problem. If a fundamental need is to
    (e.g.) find all values >= X, where duplicates are allowed but you're
    using trees that do not allow duplicate keys, this is difficult.  Hence
    the question about byValue().

If someone with more knowledge of ZODB and the BTrees therein and bsddb
feels like confirming, correcting, or commenting on the above summary, and
options, that would be great.

Regards,
Terry


More information about the ZODB-Dev mailing list