[Xapian-discuss] custom ValueRangeProcessor in Perl?

Olly Betts olly at survex.com
Mon Oct 5 23:21:57 BST 2015


On Wed, Sep 09, 2015 at 11:19:34PM +0000, Eric Wong wrote:
> Hello, I'm using the XS Perl bindings packaged with Debian stable
> and am interested in implementing my a custom ValueRangeProcessor
> (using DateTimeX::Easy for human-friendly date parsing)
> 
> Unfortunately, I'm not sure if it's possible with the
> add_valuerangeprocessor API via Perl.

It isn't currently with the stable versions of Search::Xapian.

The SWIG-generated Perl bindings should support custom VRPs though.  The
SWIG-generated bindings are present in 1.2.x, but are not the standard
Perl bindings.  In 1.3.x, the XS ones have been retired in favour of the
SWIG ones (as the SWIG ones are easier to keep up to date, and provide a
more complete wrapping).  The two aren't 100% compatible though.

> Reading the XS/*ValueRangeProcessor.xs source files, I'm seeing
> "process_value_range" methods being defined (but I can't figure out how
> they're called)

They're only called if you call them (which you normally wouldn't).

> but attempting to define my own classes does not result
> in the methods being called when performing a query.

The C++ QueryParser class will call the operator() method on the C++
object which the Perl object is wrapping.  There isn't anything in
the XS wrappers to turn that into an "upcall" to a Perl method.

This is possible though, e.g. see the perlMatchDecider class in
Xapian.xs for how it is done for MatchDecider.  Since
ValueRangeProcessor also only has one virtual method, you could probably
similarly wrap it such that from perl you could pass a subroutine
reference.

Cheers,
    Olly



More information about the Xapian-discuss mailing list