[Xapian-discuss] Perl XS bindings, postlist_begin

Francis Irving francis@flourish.org
Fri, 28 May 2004 14:59:51 +0100


On Fri, May 28, 2004 at 02:32:18PM +0100, Olly Betts wrote:
> I've actually been wondering if it's worth pushing this "uid checking"
> functionality down into the library.  So you could do something like:
> 
> $db->add_or_replace_document($doc, $unique_term);
> 
> And if $unique_term existed this would replace the document it indexed, or
> add the document otherwise.  This is neater for the library user, and
> might be slightly more efficient internally.

That would be fantastic.  Additionally, it would need a function to
delete a document given a unique term.
 
> Shouldn't you use "ne" to compare here?  In Perl, != is for comparing
> numbers...

Doh!  And all this time I thought "ne" was for strings, and "!=" for
everything else.  Shows how often I've used objects in Perl ;)  
It now works, thank you.

> > I can't work out how to cast them, so for now I'm opening a second
> > handle.
> 
> The flaw with doing that is that you'll not notice an update which
> happens in the same unflushed batch as the original addition.  That may
> not be a problem for you - in some setups that just doesn't happen.

Something bad is happening, but I don't quite understand why.
Exception: Db block overwritten at ./index.pl line 68, <F> line 2002.
I shouldn't be reading anything which has been written to in the 
same batch.

Maybe I have a duplicate "unique" identifier, I'll check that first.

> > To add to this, the problem seems to be casting to a Database.
> > The
> > function doesn't appear in WritableDatabase.
>
> Aha!  We'll need to wrap them in both places I think.  I'll whip up
> the obvious patch shortly...

OK, then I can just apply that and have one handle... Thanks!

Francis