[Xapian-tickets] [Xapian] #295: Add support for multi databases with PostingSources
Xapian
nobody at xapian.org
Fri Sep 5 13:49:24 BST 2008
#295: Add support for multi databases with PostingSources
-------------------------+--------------------------------------------------
Reporter: richard | Owner: richard
Type: enhancement | Status: new
Priority: normal | Milestone: 1.1.0
Component: Matcher | Version: SVN HEAD
Severity: normal | Keywords:
Blockedby: | Platform: All
Blocking: |
-------------------------+--------------------------------------------------
Currently, PostingSources don't work with multiple database searches.
The attached patch adds support for this, as follows:
- The PostingSource.reset() method acquires a database parameter. This
is passed a subdatabase to iterate over, and is guaranteed to be called by
the matcher before any of the other methods are.
- PostingSource also acquires a clone() method, which should return a
copy of the posting source, with the same initial parameters.
The matcher then clones the posting source for each subdatabase, and calls
reset() to set up an iteration over each database.
Drawbacks with the patch:
- Because I want to supply a "Xapian::Database" reference rather than a
"const Xapian::Database::Internal *" to the reset() method, I have
construct a new Xapian::Database object in queryoptimiser.cc (line 68).
However, this requires me to cast the const away, since there is no way to
construct a Xapian::Database object otherwise. This works, and might even
be safe (the only non-const methods on Database are reopen() and
keep_alive(), which probably shouldn't be called in the middle of
iteration, anyway), but is very ugly.
- SWIG complains about the clone() method, because it returns a raw
pointer, which SWIG doesn't know how to handle. My patch just tells SWIG
to ignore this method, but this means that SWIG wrapped languages can't
subclass PostingSource in a way which will work with multiple databases.
An alternative to the clone() problem might be to require classes to
provide "serialise" and "unserialise" methods. This could even allow
(with some extra work) PostingSources to work with remote databases (we'd
have to provide some way to register posting sources by name, similar to
that used for Weight objects).
--
Ticket URL: <http://trac.xapian.org/ticket/295>
Xapian <http://xapian.org/>
Xapian
More information about the Xapian-tickets
mailing list