Interface IntervalIterator
-
- All Known Implementing Classes:
AbstractCompositeDocumentIterator.AbstractCompositeIndexIntervalIterator
,AbstractCompositeDocumentIterator.AbstractCompositeIntervalIterator
,AlignDocumentIterator.AlignIndexIntervalIterator
,AlignDocumentIterator.AlignIntervalIterator
,AndDocumentIterator.AndIndexIntervalIterator
,AndDocumentIterator.AndIntervalIterator
,AnnotationDocumentIterator.AnnotationIntervalIterator
,ConsecutiveDocumentIterator.ConsecutiveIndexIntervalIterator
,ConsecutiveDocumentIterator.ConsecutiveIntervalIterator
,ContainmentDocumentIterator.ContainmentIntervalIterator
,DifferenceDocumentIterator.DifferenceIntervalIterator
,InclusionDocumentIterator.InclusionIntervalIterator
,IndexIntervalIterator
,IntervalIterators.FakeIterator
,LowPassDocumentIterator.LowPassIntervalIterator
,OrderedAndDocumentIterator.OrderedAndIndexIntervalIterator
,OrderedAndDocumentIterator.OrderedAndIntervalIterator
,OrDocumentIterator.OrIndexIntervalIterator
,OrDocumentIterator.OrIntervalIterator
public interface IntervalIterator
An iterator over intervals.An interval iterator is lazy—it has just a
nextInterval()
method and nohasNext()
method.This interface specifies a method
extent()
returning a positive integer that is supposed to approximate the minimum possible length of an interval returned by this iterator. This method returns -1 if this value cannot be computed.
-
-
Method Summary
Modifier and Type Method Description int
extent()
Returns an approximation of a lower bound for the length of an interval returned by this iterator.void
intervalTerms(LongSet terms)
Provides the set of terms that span the current interval.Interval
nextInterval()
Returns the next interval provided by this interval iterator, ornull
if no more intervals are available.IntervalIterator
reset()
Resets the internal state of this iterator for a new document.
-
-
-
Method Detail
-
reset
IntervalIterator reset() throws IOException
Resets the internal state of this iterator for a new document.To reduce object creation, interval iterators are usually created in a lazy fashion by document iterator when they are needed. However, this implies that every time the document iterator is moved, some internal state of the interval iterator must be reset (e.g., because on the new document some of the component interval iterators are now
IntervalIterators.TRUE
). The semantics of this method is largely implementation dependent, with the important exception that the return value must beIntervalIterators.FALSE
if the first call tonextInterval()
will returnnull
.- Returns:
IntervalIterators.FALSE
if this interval iterator will returnnull
at the first call tonextInterval()
; this interval iterator, otherwise.- Throws:
IOException
-
extent
int extent()
Returns an approximation of a lower bound for the length of an interval returned by this iterator.- Returns:
- an approximation of a lower bound for the length of an interval.
-
nextInterval
Interval nextInterval() throws IOException
Returns the next interval provided by this interval iterator, ornull
if no more intervals are available.- Returns:
- the next interval, or
null
if no more intervals are available. - Throws:
IOException
-
intervalTerms
void intervalTerms(LongSet terms)
Provides the set of terms that span the current interval.For each interval returned by MG4J, there is a set of terms that caused the interval to be returned. The terms appear inside the interval, and certainly at its extremes.
Note that the results of this method must be taken with a grain of salt: there might be different sets of terms causing the current interval, and only one will be returned.
- Parameters:
terms
- a set of integers that will be filled with the terms spanning the current interval.
-
-