Opened 17 years ago

Closed 16 years ago

#206 closed enhancement (fixed)

Serialization for Xapian::Query doesn't work for PostingSource queries.

Reported by: Armin Ronacher Owned by: Richard Boulton
Priority: normal Milestone: 1.1.0
Component: Library API Version: SVN trunk
Severity: minor Keywords:
Cc: Blocked By: #295
Blocking: Operating System: All

Description (last modified by Richard Boulton)

Attempting to serialise a query containing a PostingSource subquery raises a UnimplementedError exception. Much of the code to implement this will be part of the fix to ticket #295 - we will need to provide an extra argument to the Query::unserialise method() to provide a way to lookup possible PostingSource classes by name.

Attachments (5)

serialise_query_and_document.patch (3.1 KB ) - added by Richard Boulton 16 years ago.
Patch implementing this.
pythontests.patch (2.2 KB ) - added by Richard Boulton 16 years ago.
Tests of this feature, in python
serialisationcontext.patch (27.0 KB ) - added by Richard Boulton 16 years ago.
Patch to allow serialisation of queries containing posting sources
serialisationcontext2.patch (27.6 KB ) - added by Richard Boulton 16 years ago.
Updated patch implementing SerialisationContext.
serialisationcontext4.patch (31.5 KB ) - added by Richard Boulton 16 years ago.
Patch with tests, ready to apply I think

Download all attachments as: .zip

Change History (22)

comment:1 by Olly Betts, 17 years ago

Blocking: 120 added
Operating System: All
Severity: normalenhancement
Status: newassigned

Only requires API additions, not changes, so suitable for 1.0.x.

comment:3 by Richard Boulton, 17 years ago

Description: modified (diff)
Milestone: 1.1

comment:4 by Richard Boulton, 17 years ago

Blocking: 120 removed

(In #120) Remove the unfixed dependencies so we can close this bug - they're all marked for the 1.1.0 milestone.

comment:5 by Olly Betts, 17 years ago

Owner: changed from New Bugs to Olly Betts
Status: assignednew

comment:6 by Olly Betts, 16 years ago

Milestone: 1.1.01.1.1

Bumping milestone to 1.1.1 as there's no patch yet and this isn't an incompatible change.

by Richard Boulton, 16 years ago

Patch implementing this.

by Richard Boulton, 16 years ago

Attachment: pythontests.patch added

Tests of this feature, in python

comment:7 by Richard Boulton, 16 years ago

Blocked By: 295 added
Owner: changed from Olly Betts to Richard Boulton
Status: newassigned

Added patches implementing this, and testing it (just with the python bindings, though).

Current patch won't support serialising queries which use PostingSources, but I think that's a reasonable restriction for now. To support it, we'll need to pass an extra argument to the unserialise method giving the list of PostingSources available to be unserialised to, and add ways to serialise and clone Posting sources. This is implemented in the patch attached to ticket #295, so I'm adding a dependency on that ticket for this bug. I'm planning to implement some C++ level tests for this, and then apply the patch, since I could do with the feature for some upcoming work.

comment:8 by Richard Boulton, 16 years ago

Description: modified (diff)
Milestone: 1.1.11.1.0
Summary: Implement simple serialization for Xapian::Document and Xapian::QuerySerialization for Xapian::Query doesn't work for PostingSource queries.

Changeset [11829] applies this patch, together with some tests, and fixes most of this bug. It's not possible to serialise queries containing postingsources, so I'm updating the title and description to reflect this. Also marking this for 1.1.0, since it's just about done, and the final fix may require a tweak to the API.

by Richard Boulton, 16 years ago

Attachment: serialisationcontext.patch added

Patch to allow serialisation of queries containing posting sources

comment:9 by Richard Boulton, 16 years ago

I've just attached a patch which adds a SerialisationContext object which allows users to register their own posting sources (or weighting schemes). The patch modifies the query unserialisation methods to use this, and also modifies the remoteserver to use this internally.

The patch is lacking tests (both in core and in the bindings) - though it passes the existing testsuite. It would probably be best if RemoteServer was also modified to expose the SerialisationContext, too.

[It also fails to delete old registered posting sources or weighting schemes when they're replaced by one of the same name - this is just an oversight which is marked by FIXME in the patch, and which is easily resolved.]

Comments on the design welcome!

comment:10 by Olly Betts, 16 years ago

It seems unreasonable to tell people not to use serialising for persistence, since that seems an obvious use for this feature, especially for queries. We should at least be able to promise that it'll work when the remote protocol version hasn't changed.

comment:11 by Richard Boulton, 16 years ago

I've reworded the comment about persistence to say this: [11846].

comment:12 by Richard Boulton, 16 years ago

Notes about comments from Olly on IRC about the unapplied serialisationcontext.patch (paraphrased by me):

  • don't say "the copy is shallow" - talk in terms of reference counted handles? Do whatever is done elsewhere.
  • "if when" in a doc comment
  • comment about why dtor is needed should just be an internal comment, not documentation.
  • @private not needed in private: section
  • say "standard ones" instead of "hard-coded ones".
  • add comment to remoteserver.cc to show where to register your own subclasses
  • update comment in xapian-tcpsrv.cc

by Richard Boulton, 16 years ago

Attachment: serialisationcontext2.patch added

Updated patch implementing SerialisationContext.

comment:13 by Richard Boulton, 16 years ago

serialisationcontext2.patch contains an updated implementation, addressing all the points mentioned above. It still lacks tests, but other than this, I think it's probably ready to go.

comment:14 by Olly Betts, 16 years ago

Milestone: 1.1.01.1.1

Let's not add yet another blocker to getting 1.1.0 out. We're at the point where a 1.1.0 release is within sight and there are many new features which are solid and a number of people are interested in using. 1.1.0 will be clearly identified as a development release so we shouldn't keep pushing it back by striving for perfection in the 1.1.0 release.

Since this is an entirely new API feature, so we can mark it as experimental if you're worried that the API may need to change.

comment:15 by Richard Boulton, 16 years ago

Now that I have a nearly complete patch, I'm not so worried about the API needing to change incompatibly: the changes the current patch makes to the files in include/xapian/ are:

  • Changing the prototype of a method in Query::Internal (but that's not part of the API, so should be fine, I think). Might break ABI, though; I'd need to do a deeper analysis to determine that.
  • Adding static Query unserialise(const std::string & s, const SerialisationContext & ctx); to the Query class. This shouldn't be any kind of problem.
  • Adding "friend class SerialisationContext" to Xapian::Weight. This shouldn't be any kind of problem.
  • Adding xapian/serialisationcontext.h - also shouldn't be any problem.

If I get a completed patch, I'd still like to consider applying it before 1.1.0, (unless we're really getting close to having 1.1.0 ready; currently I think we're still around a month of work from it) - my experience is that patches sitting in the tracker tend to decay quite quickly, and need a fair bit of work to apply. There is quite a bit of code here, but it doesn't have many deep interactions with other parts of xapian, so I feel that there's a fairly low risk of destabilisation due to it.

comment:16 by Olly Betts, 16 years ago

ABI changes aren't an issue for 1.1.x (though ideally we should probably try to group ABI breaking changes into just a few point releases).

I was really just trying to set the milestone to reflect the actual status - this doesn't deserve to block a 1.1.0 release, so milestone:1.1.0 is the wrong setting.

I don't currently feel I have a good grasp of what really needs to be done before 1.1.0, hence I've been checking through milestone:1.1.0 bugs.

Other non-destabilising changes are generally OK too, though if we're working on those that presumably means we aren't working on the changes that are required to release, so some self-discipline is probably going to be needed here!

by Richard Boulton, 16 years ago

Attachment: serialisationcontext4.patch added

Patch with tests, ready to apply I think

comment:17 by Richard Boulton, 16 years ago

I've attached a patch which contains unittests, and is fully ready to apply, I think.

I'll wait a couple of days for comment, and then apply it if there are no problems.

comment:18 by Richard Boulton, 16 years ago

Milestone: 1.1.11.1.0
Resolution: fixed
Status: assignedclosed

Applied this patch, with a few further tweaks, so marking this ticket as closed.

Also marking as for the 1.1.0 milestone, since it will be in that release.

Note: See TracTickets for help on using tickets.