Package io.karma.kommons.util
Class BatchProcessor
java.lang.Object
io.karma.kommons.util.BatchProcessor
A simple, allocation-friendly alternative to parallel streams,
which can process a collection of elements, scaling (mostly)
symmetrically accross all available (or specified) threads.
- Since:
- 04/08/2022
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
R, C extends Collection<R>, U>
CflatProcess
(Collection<T> elements, BiFunction<T, U, ? extends Collection<? extends R>> function, Supplier<C> factory, U userData) static <T,
R, C extends Collection<R>>
CflatProcess
(Collection<T> elements, Function<T, ? extends Collection<? extends R>> function, Supplier<C> factory) static <T,
R, C extends Collection<R>, U>
CflatProcess
(ExecutorService executor, Collection<T> elements, int numBatches, BiFunction<T, U, ? extends Collection<? extends R>> function, Supplier<C> factory, U userData) static <T,
R, C extends Collection<R>>
CflatProcess
(ExecutorService executor, Collection<T> elements, int numBatches, Function<T, ? extends Collection<? extends R>> function, Supplier<C> factory) static <T,
R, C extends Collection<R>, U>
CflatProcess
(ExecutorService executor, Collection<T> elements, BiFunction<T, U, ? extends Collection<? extends R>> function, Supplier<C> factory, U userData) static <T,
R, C extends Collection<R>>
CflatProcess
(ExecutorService executor, Collection<T> elements, Function<T, ? extends Collection<? extends R>> function, Supplier<C> factory) static <T,
R, C extends Collection<R>, U>
Cprocess
(Collection<T> elements, BiFunction<T, U, R> function, Supplier<C> factory, U userData) static <T,
R, C extends Collection<R>>
Cprocess
(Collection<T> elements, Function<T, R> function, Supplier<C> factory) static <T,
R, C extends Collection<R>, U>
Cprocess
(ExecutorService executor, Collection<T> elements, int numBatches, BiFunction<T, U, R> function, Supplier<C> factory, U userData) static <T,
R, C extends Collection<R>>
Cprocess
(ExecutorService executor, Collection<T> elements, int numBatches, Function<T, R> function, Supplier<C> factory) static <T,
R, C extends Collection<R>, U>
Cprocess
(ExecutorService executor, Collection<T> elements, BiFunction<T, U, R> function, Supplier<C> factory, U userData) static <T,
R, C extends Collection<R>>
Cprocess
(ExecutorService executor, Collection<T> elements, Function<T, R> function, Supplier<C> factory)
-
Method Details
-
process
public static <T,R, C processC extends Collection<R>> (ExecutorService executor, Collection<T> elements, int numBatches, Function<T, R> function, Supplier<C> factory) -
process
public static <T,R, C processC extends Collection<R>> (ExecutorService executor, Collection<T> elements, Function<T, R> function, Supplier<C> factory) -
process
public static <T,R, C processC extends Collection<R>> (Collection<T> elements, Function<T, R> function, Supplier<C> factory) -
flatProcess
public static <T,R, C flatProcessC extends Collection<R>> (ExecutorService executor, Collection<T> elements, int numBatches, Function<T, ? extends Collection<? extends R>> function, Supplier<C> factory) -
flatProcess
public static <T,R, C flatProcessC extends Collection<R>> (ExecutorService executor, Collection<T> elements, Function<T, ? extends Collection<? extends R>> function, Supplier<C> factory) -
flatProcess
public static <T,R, C flatProcessC extends Collection<R>> (Collection<T> elements, Function<T, ? extends Collection<? extends R>> function, Supplier<C> factory) -
process
public static <T,R, C processC extends Collection<R>, U> (ExecutorService executor, Collection<T> elements, int numBatches, BiFunction<T, U, R> function, Supplier<C> factory, @Nullable U userData) -
process
public static <T,R, C processC extends Collection<R>, U> (ExecutorService executor, Collection<T> elements, BiFunction<T, U, R> function, Supplier<C> factory, @Nullable U userData) -
process
public static <T,R, C processC extends Collection<R>, U> (Collection<T> elements, BiFunction<T, U, R> function, Supplier<C> factory, @Nullable U userData) -
flatProcess
public static <T,R, C flatProcessC extends Collection<R>, U> (ExecutorService executor, Collection<T> elements, int numBatches, BiFunction<T, U, ? extends Collection<? extends R>> function, Supplier<C> factory, @Nullable U userData) -
flatProcess
public static <T,R, C flatProcessC extends Collection<R>, U> (ExecutorService executor, Collection<T> elements, BiFunction<T, U, ? extends Collection<? extends R>> function, Supplier<C> factory, @Nullable U userData) -
flatProcess
public static <T,R, C flatProcessC extends Collection<R>, U> (Collection<T> elements, BiFunction<T, U, ? extends Collection<? extends R>> function, Supplier<C> factory, @Nullable U userData)
-