Class PrefetchIterator<K>

  • Type Parameters:
    K - the iterator data type
    All Implemented Interfaces:
    Iterator<K>

    public class PrefetchIterator<K>
    extends Object
    implements Iterator<K>
    An iterator that pre-fetches a number of items in order to calculate the size of the result if possible. This iterator loads at least a number of items, and then tries to load some more items until the timeout is reached or the maximum number of entries are read.

    Prefetching is only done when size() is called.

    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<K>
      • next

        public K next()
        Specified by:
        next in interface Iterator<K>
      • remove

        public void remove()
        Specified by:
        remove in interface Iterator<K>
      • size

        public long size()
        Get the size if known. This call might pre-fetch data. The returned value is unknown if the actual size is larger than the number of pre-fetched elements, unless the end of the iterator has been reached already.
        Returns:
        the size, or -1 if unknown