Class ParallelMappingIterator<T,R>
java.lang.Object
com.github.basking2.sdsai.itrex.iterators.ParallelMappingIterator<T,R>
- All Implemented Interfaces:
Iterator<R>
A ParallelMappingIterator will map elements in threads, using an executor service.
-
Constructor Summary
ConstructorDescriptionParallelMappingIterator
(boolean ordered, Iterator<T> inputs, Executor executor, int breadth, MappingIterator.Mapper<T, R> mappingFunction) Constructor with a default error handler.ParallelMappingIterator
(boolean ordered, Iterator<T> inputs, Executor executor, int breadth, MappingIterator.Mapper<T, R> mappingFunction, Consumer<Throwable> reportError) Constructor. -
Method Summary
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, remove
-
Constructor Details
-
ParallelMappingIterator
public ParallelMappingIterator(boolean ordered, Iterator<T> inputs, Executor executor, int breadth, MappingIterator.Mapper<T, R> mappingFunction) Constructor with a default error handler.- Parameters:
ordered
- If true, results from this iterator will be emitted in the same order they are read. If true, this will cause head-of-line blocking if a slow element is encountered, but often this is acceptable.inputs
- The inputs to map.executor
- The executor service to dispatch work into.breadth
- How many concurrent tasks should be started.mappingFunction
- A function to map from type T to R.
-
ParallelMappingIterator
public ParallelMappingIterator(boolean ordered, Iterator<T> inputs, Executor executor, int breadth, MappingIterator.Mapper<T, R> mappingFunction, Consumer<Throwable> reportError) Constructor.- Parameters:
ordered
- If true, results from this iterator will be emitted in the same order they are read. If true, this will cause head-of-line blocking if a slow element is encountered, but often this is acceptable.inputs
- The inputs to map.executor
- The executor service to dispatch work into.breadth
- How many concurrent tasks should be started.mappingFunction
- A function to map from type T to R.reportError
- If the mapping function throws an exception, how is it handled?
-
-
Method Details