Class CachingDocumentIterator

  • All Implemented Interfaces:

    public class CachingDocumentIterator
    extends Object
    implements DocumentIterator
    A decorator that caches the intervals produced by the underlying document iterator.

    Often, scores exhaust the intervals produced by a document iterator to compute their result. However, often you also need those intervals for other purposes (maybe just because you are aggregating several interval-based scorers). Decorating a document iterator with an instance of this class you get again a document iterator, but its intervals can be retrieved several times by calling intervalIterator(Index), intervalIterator() and intervalIterators(). Important: calls are not nestable: when you require again an iterator, the one previously returned is no longer valid, and when the current document changes (e.g., because of a call to nextDocument()) the previously returned interval iterators are invalidated.

    Sebastiano Vigna