[Xapian-discuss] Re: Closing a DB

Olly Betts olly at survex.com
Thu Aug 23 02:18:56 BST 2007


On Fri, Aug 10, 2007 at 10:14:52AM +0100, Richard Boulton wrote:
> David Morris wrote:
> >Is there a method to get
> >information from the DB object? As in, is it open, etc, etc. That way I can
> >assert for it in my tests.
> 
> No - because if you have the DB object around, you have a reference to 
> it, so it won't be closed...

You could try to open the DB for writing if you want to test that it's
actually been closed, but that's a bit heavyweight for an assertion.

> >Thing is, if the database has been explicitly closed, any access to
> >it can throw an exception, and none of the objects will have cope
> >with anything, right?
> >
> >(I haven't actually looked at the internals, but) this would mean
> >that every call would have a little bit of overhead to check to see
> >if the DB has been closed, but that's about it.
> 
> Yes - however, some of the accesses are performed very frequently in 
> performance critical situations: eg, access to posting lists is 
> performed very frequently when doing a match.  It may not make much of 
> an impact to add a check, but I'm wary of doing so without first 
> measuring the effect...

I'm not too concerned about that (it should simply be a flag check
or comparing a pointer to NULL or similar) though it would be good to
check that the extra overhead isn't measurable.

The main issue I see here is simply that this is likely to touch a lot
of places in the code, which makes it potentially rather disruptive.  

It would certainly be good to be able to sort this out though.

Cheers,
    Olly



More information about the Xapian-discuss mailing list