[Xapian-discuss] Re: strange problem with number value range in 1.0.4

Ron Kass ron at pidgintech.com
Thu Dec 20 22:09:06 GMT 2007


We wrapped it for our own needs for Perl usage.

Do the following:

in the XS directory, there is a file called Database.xs, towards the end 
of it add the following :

    string
    Database::sortable_serialise(double value)
        CODE:
            try {
                RETVAL = sortable_serialise(value);
            }
            catch (const Error &error) {
                croak( "Exception: %s", error.get_msg().c_str() );
            }
        OUTPUT:
            RETVAL

    double
    Database::sortable_unserialise(string value)
        CODE:
            try {
                RETVAL = sortable_unserialise(value);
            }
            catch (const Error &error) {
                croak( "Exception: %s", error.get_msg().c_str() );
            }
        OUTPUT:
            RETVAL

Note: Place this code just BEFORE

    void
    Database::DESTROY()


Then recompile the Perl-XS (follow the readme file)..

You will now be able to call sortable_serialise (and 
sortable_unserialise) from perl, via any database object.


For example: (just a general example)

    my $XAP_DB = 
Search::Xapian::WritableDatabase->new("/test_database/",DB_CREATE_OR_OPEN);   


    my $TimeStamp = 1035122221;

    my $TimeStamp_Serialized = $XAP_DB->sortable_serialise($TimeStamp);


This will return the funky string thingy you saw in the query, so you 
can now store those as values and use as intended..

In this example we use an actual WritableDatabase, but it can be any 
database.

Note that we did this per our need, and it may very well be not the 
perfect/ideal wrapping, but it works perfectly for us. I think the best 
place to wrap it is part of the actual top Xapian object, but we didn't 
succeed with it right away and it was easier (and enough) for us to do 
on the Database object, so thats what we kept for now...


Hope it helps. Good luck..


Ron


Adam Sjøgren wrote:

> On Thu, 20 Dec 2007 16:36:02 +0000, Olly wrote:
>
>   
>> On Thu, Dec 20, 2007 at 03:56:43PM +0100, Adam Sjøgren wrote:
>>     
>
>   
>>> Is Xapian::sortable_serialise() wrapped in Search::Xapian?
>>>       
>
>   
>> Not currently I'm afraid.
>>     
>
> Ok - I couldn't quite figure out where it would go, by my patented
> monkey-see - monkey-copy method.
>
>   
>>> It didn't seem so when I tried it just now (1.0.4.0-2 from Debian
>>> unstable)
>>>       
>
>   
>> Odd, Debian only seems to have -1 currently:
>>     
>
> Ah - I accidentally bumped the packaging number to -2 when I built a
> local backport to Ubuntu gutsy; I should have said 1.0.4.0-1, sorry.
>
>   
>> Perhaps you're using a privately updated package?  But these issues
>> affect vanilla 1.0.4.0 anyway.
>>     
>
> Yes - the only thing I updated was the debian/changelog (so we can
> easily distinguish locally built packages).
>
>   
>> StringVRP really ought to support a prefix/suffix like NumberVRP does.
>> There's already a wishlist bug for adding this feature to DateVRP, so
>> I've updated that to cover StringVRP too:
>>     
>
>   
>> http://www.xapian.org/cgi-bin/bugzilla/show_bug.cgi?id=220
>>     
>
> Cool.
>
>   
>>> Should I try figuring out how to wrap sortable_serialise, or should I
>>> try to provide a patch for StringVRP that adds the str and prefix
>>> arguments, similar to NumberVRP?
>>>       
>
>   
>> Patches for either or both would certainly be welcome.  I'm currently
>> busy trying to get a 1.0.5 release together.
>>     
>
> My C is rusty and my C++ has never really been shining, but I will see
> if I can find time to have a go at the latter tomorrow; I think we need
> it for our app, so I am motivated :-)
>
>
>   Best regards,
>
>     Adam
>
>   


More information about the Xapian-discuss mailing list