Opened 14 years ago

Closed 8 years ago

Last modified 8 years ago

#498 closed enhancement (fixed)

Expose PostingSource::set_maxweight() to bindings

Reported by: Richard Boulton Owned by: Olly Betts
Priority: normal Milestone: 1.3.4
Component: Xapian-bindings Version: SVN trunk
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Operating System: All

Description

It looks like the protected method PostingSource::set_maxweight() isn't available to wrapped PostingSources. This means that they cannot cause the maxweight value for a posting source to be changed during the match process. However, they can still return a custom maxweight by overriding their get_maxweight(); method, which appears to be wrapped correctly, such that it will be called by the matcher.

The documentation comment on the python PostingSource base class indicates that subclasses should call set_maxweight(); (this is the documentation which automatically comes from C++). This is a bit confusing for users.

It would be best to allow wrapped subclasses access to set_maxweight(). Alternatively, the documentation should be updated to reflect that subclasses should just implement get_maxweight() and that the maxweight value cannot be changed during the search process.

In addition, we don't seem to have any test coverage in the Xapian bindings for PostingSources which return non-zero weights. This should be added.

Change History (5)

comment:1 by Olly Betts, 13 years ago

However, they can still return a custom maxweight by overriding their get_maxweight(); method, which appears to be wrapped correctly, such that it will be called by the matcher.

That won't work as get_maxweight() isn't virtual.

Not sure what's up with set_maxweight() - there's code generated for it, but it doesn't seem to be callable.

comment:2 by Olly Betts, 12 years ago

Milestone: 1.2.x1.3.x

We should look at this for 1.3.x in case it requires API changes.

comment:3 by Olly Betts, 8 years ago

Milestone: 1.3.x1.3.5
Status: newassigned

Had a quick poke, and the only sane ways I can see to get this wrapped is to either just make it public in the C++ API, or to create a PostingSource subclass which is wrapped for the bindings instead of the actual PostingSource class and provides a public method.

I don't see any code generated (as comment:1 claims) - I guess SWIG used to generate code for this case which wasn't usable, and has since been fixed not to generate it.

I don't see a big downside to just making this public in C++. Not sure if it should be hidden from the doxygen documentation, or noted as probably only useful from subclasses, or what.

Marking for 1.3.5.

comment:4 by Olly Betts, 8 years ago

Milestone: 1.3.51.3.4
Resolution: fixed
Status: assignedclosed

I've just made this method public and added a note that it's probably only useful to call from subclasses in [e8e70234ca1e98222aebd2a895de86a567a66d1b].

comment:5 by Olly Betts, 8 years ago

Added a regression test that this now works for python and python3 in [55d29626c43d059b1a1648f33fdd984fd20174e9].

Note: See TracTickets for help on using tickets.