[Xapian-discuss] PostingSource::skip_to

Richard Boulton richard at lemurconsulting.com
Fri Nov 21 08:25:55 GMT 2008


On Fri, Nov 21, 2008 at 07:14:15AM +0000, Paul Rudin wrote:
> 
> The documentation says that initially the PostingSource points to a
> position *before* the first position.
> 
> The default skip_to() calls get_docid() before it calls next(). Is this
> OK? If skip_to() is called immediately after construction or reset()
> then get_docid() doesn't have anything sensible to return if it's before
> the first position. Or perhaps I misunderstand something.

That's a good point, and I think the default implementation is probably in
error.  In practice, I suspect the posting sources we have implemented so
far have all returned 0 for get_docid() in this situation (which isn't
actually a valid docid).  I can't easily see how to make the default
posting source skip_to() do anything other than call get_docid(), because
it can't know whether next() has been called yet at all, so perhaps the
easiest fix is to document that posting sources should return 0 from
get_docid() if the posting source iteration hasn't been started yet (ie,
next(), skip_to() and check() haven't been called yet).

(Away from internet in about 2 hours now...)

-- 
Richard



More information about the Xapian-discuss mailing list