Each call to {@link #nextDocument()}will return a document pointer, or -1 if no more documents are available. Just after the call to {@link #nextDocument()}, {@link #intervalIterator(Index)} will return an interval iteratorenumerating intervals in the last returned document for the specified index. The latter method may return, as a special result, a special {@link it.unimi.dsi.mg4j.search.IntervalIterators#TRUE TRUE} value: this means that albeit the current document satisfies the query, there is only a generic empty witness to prove it (see {@link it.unimi.dsi.mg4j.search.IntervalIterators#TRUE TRUE} for some elaboration).
Note that this class implements {@link IntIterator}. Nonetheless, for performance reasons, the preferred access to the document pointers is {@link #nextDocument()}.
The {@link #iterator()} method must be an alias for {@link #intervalIterator()}, and shares the same limitations.
A document iterator is usually structured as composite, with operators as internal nodes and {@link it.unimi.dsi.mg4j.index.IndexIterator}s as leaves. The methods {@link #accept(DocumentIteratorVisitor)} and {@link #acceptOnTruePaths(DocumentIteratorVisitor)} implement the visitor pattern.
The {@link #dispose()} method is intended to recursively release all resources associatedto a composite document iterator. Note that this is not always what you want, as you might be, say, pooling {@linkplain it.unimi.dsi.mg4j.index.IndexReader index readers} to reduce the numberof file open/close operations. For this reason, we intentionally avoid calling the method “close”.
Warning: the interval enumeration can be carried out only just after a call to {@link #nextDocument()}. Subsequent calls to {@link #nextDocument()} or even to {@link java.util.Iterator#hasNext()} will reset the internal state of the iterator. In particular, trying to enumerate intervals after a call to {@link java.util.Iterator#hasNext()} will usually throw an {@link java.lang.IllegalStateException}.
|
|
|
|