Ticket #295 (assigned enhancement)
Add support for multi and remote databases with PostingSources
| Reported by: | richard | Owned by: | richard |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.1.0 |
| Component: | Matcher | Version: | SVN trunk |
| Severity: | normal | Keywords: | |
| Cc: | Blocked By: | ||
| Operating System: | All | Blocking: |
Description
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).
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
