public static final class ParallelCollectors.Batching
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T,R,RR> java.util.stream.Collector<T,?,java.util.concurrent.CompletableFuture<RR>> |
parallel(java.util.function.Function<T,R> mapper,
java.util.stream.Collector<R,?,RR> collector,
java.util.concurrent.Executor executor,
int parallelism)
A convenience
Collector used for executing parallel computations on a custom Executor
and returning them as a CompletableFuture containing a result of the application of the user-provided Collector. |
static <T,R> java.util.stream.Collector<T,?,java.util.concurrent.CompletableFuture<java.util.stream.Stream<R>>> |
parallel(java.util.function.Function<T,R> mapper,
java.util.concurrent.Executor executor,
int parallelism)
A convenience
Collector used for executing parallel computations on a custom Executor
and returning them as CompletableFuture containing a Stream of these elements. |
static <T,R> java.util.stream.Collector<T,?,java.util.stream.Stream<R>> |
parallelToOrderedStream(java.util.function.Function<T,R> mapper,
java.util.concurrent.Executor executor,
int parallelism)
A convenience
Collector used for executing parallel computations on a custom Executor
and returning a Stream instance returning results as they arrive while maintaining the initial order. |
static <T,R> java.util.stream.Collector<T,?,java.util.stream.Stream<R>> |
parallelToStream(java.util.function.Function<T,R> mapper,
java.util.concurrent.Executor executor,
int parallelism)
A convenience
Collector used for executing parallel computations on a custom Executor
and returning a Stream instance returning results as they arrive. |
public static <T,R,RR> java.util.stream.Collector<T,?,java.util.concurrent.CompletableFuture<RR>> parallel(java.util.function.Function<T,R> mapper,
java.util.stream.Collector<R,?,RR> collector,
java.util.concurrent.Executor executor,
int parallelism)
Collector used for executing parallel computations on a custom Executor
and returning them as a CompletableFuture containing a result of the application of the user-provided Collector.
CompletableFuture<List<String>> result = Stream.of(1, 2, 3)
.collect(parallel(i -> foo(i), toList(), executor, 2));
T - the type of the collected elementsR - the result returned by mapperRR - the reduction result collectormapper - a transformation to be performed in parallelcollector - the Collector describing the reductionexecutor - the Executor to use for asynchronous executionparallelism - the max parallelism levelCollector which collects all processed elements into a user-provided mutable Collection in parallelpublic static <T,R> java.util.stream.Collector<T,?,java.util.concurrent.CompletableFuture<java.util.stream.Stream<R>>> parallel(java.util.function.Function<T,R> mapper,
java.util.concurrent.Executor executor,
int parallelism)
Collector used for executing parallel computations on a custom Executor
and returning them as CompletableFuture containing a Stream of these elements.
Runtime.availableProcessors() - 1
Stream. Instances should not be reused.
CompletableFuture<Stream<String>> result = Stream.of(1, 2, 3)
.collect(parallel(i -> foo(), executor, 2));
T - the type of the collected elementsR - the result returned by mappermapper - a transformation to be performed in parallelexecutor - the Executor to use for asynchronous executionparallelism - the max parallelism levelCollector which collects all processed elements into a Stream in parallelpublic static <T,R> java.util.stream.Collector<T,?,java.util.stream.Stream<R>> parallelToStream(java.util.function.Function<T,R> mapper,
java.util.concurrent.Executor executor,
int parallelism)
Collector used for executing parallel computations on a custom Executor
and returning a Stream instance returning results as they arrive.
For the parallelism of 1, the stream is executed by the calling thread.
Example:
Stream.of(1, 2, 3)
.collect(parallelToStream(i -> foo(), executor, 2))
.forEach(System.out::println);
T - the type of the collected elementsR - the result returned by mappermapper - a transformation to be performed in parallelexecutor - the Executor to use for asynchronous executionparallelism - the max parallelism levelCollector which collects all processed elements into a Stream in parallelpublic static <T,R> java.util.stream.Collector<T,?,java.util.stream.Stream<R>> parallelToOrderedStream(java.util.function.Function<T,R> mapper,
java.util.concurrent.Executor executor,
int parallelism)
Collector used for executing parallel computations on a custom Executor
and returning a Stream instance returning results as they arrive while maintaining the initial order.
For the parallelism of 1, the stream is executed by the calling thread.
Example:
Stream.of(1, 2, 3)
.collect(parallelToOrderedStream(i -> foo(), executor, 2))
.forEach(System.out::println);
T - the type of the collected elementsR - the result returned by mappermapper - a transformation to be performed in parallelexecutor - the Executor to use for asynchronous executionparallelism - the max parallelism levelCollector which collects all processed elements into a Stream in parallelCopyright © 2020. All Rights Reserved.