Mailing List Archive

Question about behaviour of IntervalIterator
Hi,
I'm trying to play around with my own IntervalSource and found out that
"nextInterval" method of IntervalIterator will be called sometimes even
after "nextDoc"/"docID"/"advance" method returns NO_MORE_DOCS.
After I dug a bit more I found that FilteringIntervalIterator.reset is
calling an inner iterator's "nextInterval" regardless of what the result of
"nextDoc", and also most (if not all) existing IntervalIterator's
implementation do considered the case where "nextInterval" is called after
"nextDoc" returns NO_MORE_DOCS.
I'm a bit confused here since I thought in most places lucene assumes
undefined behavior after NO_MORE_DOCS are returned for those method should
be called only after "advance", but for "nextInterval" seems its not the
case. Should we change the current behavior of "nextInterval"
implementations or add some caution comment to javadoc?

Thanks
Patrick Zhai
Re: Question about behaviour of IntervalIterator [ In reply to ]
Some of the minimum-interval algorithms will call nextInterval() or start() even after the interval has been exhausted, so we need to handle those situations properly. Improved java doc would definitely be helpful though, and maybe we should update checkIntervals() in TestIntervals to test what happens when calling nextInterval() after it has returned NO_MORE_INTERVALS. Do you want to open an issue?

- Alan

> On 19 Nov 2020, at 08:17, Haoyu Zhai <zhai7631@gmail.com> wrote:
>
> Hi,
> I'm trying to play around with my own IntervalSource and found out that "nextInterval" method of IntervalIterator will be called sometimes even after "nextDoc"/"docID"/"advance" method returns NO_MORE_DOCS.
> After I dug a bit more I found that FilteringIntervalIterator.reset is calling an inner iterator's "nextInterval" regardless of what the result of "nextDoc", and also most (if not all) existing IntervalIterator's implementation do considered the case where "nextInterval" is called after "nextDoc" returns NO_MORE_DOCS.
> I'm a bit confused here since I thought in most places lucene assumes undefined behavior after NO_MORE_DOCS are returned for those method should be called only after "advance", but for "nextInterval" seems its not the case. Should we change the current behavior of "nextInterval" implementations or add some caution comment to javadoc?
>
> Thanks
> Patrick Zhai


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
Re: Question about behaviour of IntervalIterator [ In reply to ]
Thanks Alan,
I've opened an issue:
https://issues.apache.org/jira/browse/LUCENE-9618
And also a PR including a unit test to demonstrate the issue:
https://github.com/apache/lucene-solr/pull/2090
Seems we're not on the exact same point, originally I'm asking about
whether nextInterval() are supposed to be called after NO_MORE_DOCS is
returned. But we definitely should update doc/test for behavior after
NO_MORE_INTERVALS returned as well.

Patrick

Alan Woodward <romseygeek@gmail.com> ?2020?11?19??? ??1:36???

> Some of the minimum-interval algorithms will call nextInterval() or
> start() even after the interval has been exhausted, so we need to handle
> those situations properly. Improved java doc would definitely be helpful
> though, and maybe we should update checkIntervals() in TestIntervals to
> test what happens when calling nextInterval() after it has returned
> NO_MORE_INTERVALS. Do you want to open an issue?
>
> - Alan
>
> > On 19 Nov 2020, at 08:17, Haoyu Zhai <zhai7631@gmail.com> wrote:
> >
> > Hi,
> > I'm trying to play around with my own IntervalSource and found out that
> "nextInterval" method of IntervalIterator will be called sometimes even
> after "nextDoc"/"docID"/"advance" method returns NO_MORE_DOCS.
> > After I dug a bit more I found that FilteringIntervalIterator.reset is
> calling an inner iterator's "nextInterval" regardless of what the result of
> "nextDoc", and also most (if not all) existing IntervalIterator's
> implementation do considered the case where "nextInterval" is called after
> "nextDoc" returns NO_MORE_DOCS.
> > I'm a bit confused here since I thought in most places lucene assumes
> undefined behavior after NO_MORE_DOCS are returned for those method should
> be called only after "advance", but for "nextInterval" seems its not the
> case. Should we change the current behavior of "nextInterval"
> implementations or add some caution comment to javadoc?
> >
> > Thanks
> > Patrick Zhai
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>