[Xapian-discuss] Explicit index close, allowing another create in same process

Richard Boulton richard at tartarus.org
Thu Nov 5 09:08:35 GMT 2009


2009/11/5 Henry <henka at cityweb.co.za>:
> Just to confirm:  when using the Perl bindings, if I want to explicitly
> close a database (which implies ->flush), I can use "$index = undef;"
>  right?

Doing this will cause the database to be closed if (and only if) there
are no other objects still around holding a reference to the database
open.  For example, if you've got an Enquire object with a reference
to the database lying around, the database will only be closed when
that Enquire object is also dereferenced.

Unfortunately, in the 1.0.x release series, there is no way to
explicitly close a database, so you'll just have to ensure there are
no such references lying around.  In the development series, databases
have grown a "close()" method to allow databases to be closed without
having to chase down all the references.

> I know this is supposed to happen automatically when the script exits, but I
> need to perform a close/create in the same process (I'm segmenting very
> large single-site indexes so they can be distributed).

I'd recommend calling flush() explicitly, at least.  That way, you'll
be able to be informed of any errors which occur during the commit of
the database.  (Exceptions can't safely be thrown from C++
destructors, so errors which occur at that point are discarded.)

-- 
Richard



More information about the Xapian-discuss mailing list