[Xapian-discuss] Patch submission

Olly Betts olly at survex.com
Wed Dec 23 08:43:59 GMT 2009


On Wed, Dec 23, 2009 at 09:05:25AM +0200, henka at cityweb.co.za wrote:
> Following on from ticket #420
> 
> > The documentation for {{{WritableDatabase::close}}} should really be for
> > {{{Database::close}}}, but this method doesn't seem to be wrapped for Perl
> > anyway currently, so I've not applied that bit...
> 
> I take it from the docs that Search::Xapian::Database is for searching,
> and Search::Xapian::WritableDatabase is for indexing (for all practical
> purposes anyway).

Roughly, though WritableDatabase is a subclass of Database, so supports all
its own (read-only) operations Database does, as well as the writing
operations.

> Would it not then make sense to also have close() wrapped for Perl in
> Search::Xapian::WritableDatabase?

Because it is a subclass, it's actually Database's close() you are wrapping.
Though maybe you need to explicitly wrap it for the subclass too in XS -
I vaguely remember some issue like that, and we seem to have explicit wrappers
for at least some Database methods in WritableDatabase.

But anyway, close() is useful on Database too is my main point above (mostly
because it ensures the file handles are closed right away and so they're
available for reuse; for a remote database, it ensures the server process
exits).

> I've patched Search::Xapian::WritableDatabase to include a $idx->close()
> call, and this /appears/ to be working in my indexing code - but maybe
> only because it's followed by a $idx=S::X::WD->new()?

You didn't include this new wrapper in the patch, just the documentation for
it...

> If Search::Xapian::WritableDatabase is not supposed to have a close(),
> then how can I access the database object to call the close() method?

Because WritableDatabase is a subclass of Database, a WritableDatabase object
*is* a Database object.

Cheers,
    Olly



More information about the Xapian-discuss mailing list