Class PrefetchingIterator<T>

java.lang.Object
com.github.basking2.sdsai.itrex.iterators.ParallelIteratorIterator<T>
com.github.basking2.sdsai.itrex.iterators.PrefetchingIterator<T>
All Implemented Interfaces:
Iterator<T>

public class PrefetchingIterator<T> extends ParallelIteratorIterator<T>
An iterator that prefetches and caches some number of elements from another iterator. Sometimes it is expensive for an iterator to return a value. In these situations it is sometimes preferable to pre-fetch a few objects, and asynchronously replenish them. Order is preserved, so if there is a particularly slow fetch, it may stall future fetches. This is just a kind of ParallelIteratorIterator that uses a single iterator.
  • Constructor Details

    • PrefetchingIterator

      public PrefetchingIterator(Executor executor, int prefetch, Iterator<T> iterator)