[
https://issues.apache.org/jira/browse/LUCENE-6226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14372693#comment-14372693
]
Paul Elschot commented on LUCENE-6226:
--------------------------------------
As to the API, at LUCENE-6308 I used the same approach for positions as
DocSetIterator does for documents, basically this:
{code}
public abstract class SpansEnum extends DocIdSetIterator {
public static final int NO_MORE_POSITIONS = Integer.MAX_VALUE;
/**
* Returns the next start position for the current doc.
* There is always at least one start/end position per doc.
* After the last start/end position at the current doc this returns {@link
#NO_MORE_POSITIONS}.
*/
public abstract int nextStartPosition() throws IOException;
...
{code}
The interval iterator here has this:
{code}
public interface IntervalIterator {
...
/**
* Move to the next interval. Do not call before {@link #reset(int)}
* @return false if intervals are exhausted for this document, otherwise true
*/
public boolean nextInterval() throws IOException;
...
{code}
which is closer to the current Spans.next().
This subject takes me back to LUCENE-1614, which is nice to reread anyway.
But the question now is: do we want a similar API for intervals/spans iteration
to the one we have for iterating documents, or do we prefer to stay closer to
the current Spans.next() ?
> Add interval iterators to Scorer
> --------------------------------
>
> Key: LUCENE-6226
> URL: https://issues.apache.org/jira/browse/LUCENE-6226
> Project: Lucene - Core
> Issue Type: Improvement
> Reporter: Alan Woodward
> Assignee: Alan Woodward
> Fix For: Trunk, 5.1
>
> Attachments: LUCENE-6226.patch, LUCENE-6226.patch, LUCENE-6226.patch,
> LUCENE-6226.patch, LUCENE-6226.patch, LUCENE-6226.patch, LUCENE-6226.patch
>
>
> This change will allow Scorers to expose which positions within a document
> they have matched, via a new IntervalIterator interface. Consumers get the
> iterator by calling intervals() on the Scorer, then call reset(docId)
> whenever the scorer has advanced and nextInterval() to iterate through
> positions. Once all matching intervals on the current document have been
> exhausted, nextInterval() returns false.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]