Class PrefetchIterator<K>

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

    public class PrefetchIterator<K>
    extends java.lang.Object
    implements java.util.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 Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      K next()  
      void remove()  
      long size()
      Get the size if known.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Method Detail

      • hasNext

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

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

        public void remove()
        Specified by:
        remove in interface java.util.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