[Xapian-devel] ruby bindings odds and ends
olly at survex.com
Thu May 11 15:07:28 BST 2006
On Thu, May 11, 2006 at 01:29:51PM +0100, James Aylett wrote:
> On Thu, May 11, 2006 at 12:05:25AM +0100, Olly Betts wrote:
> > And lastly, for most languages, there's an extra Enquire method -
> > get_matching_terms() which just returns the matching terms as a list or
> > array or similar. I'm not sure why this one case gets special treatment
> > really - I think it's mostly just a historical oddity.
> It is - the aim should be language-specific iterator patterns so you
> can treat the MSet in the appropriate way for the language. I don't
> know which bindings languages actually support that at present
> though... the idea is that get_matching_terms() is a *cheap*
> alternative to getting this right, as it'll probably be easier to use
> in the language than getting the wrapped MSetIterator, which doesn't
> behave in the expected fashion without more work in the bindings.
This actually wraps a TermIterator not an MSetIterator (it wraps
Enquire::get_matching_terms_begin() and ..._end()) - the real oddity is
that none of the other sources of TermIterators get similar treatment.
I can understand that you probably don't want to suck the terms from
Database::allterms_begin() into an array but there are other places
which generally return a modest number of terms.
I suspect whoever added it just had a need to see the terms matching
each document in the MSet and found using the C++ iterators from
whatever language it was clumsy.
But as you say, we really want to wrap as whatever the native equivalent
of an iterator is where we can. I believe that currently Python, C#, and
Ruby wrap as native-style iterators, and PHP5 should soon. I think Java
does too, but I've not looked at that so much.
More information about the Xapian-devel