public final class ParallelCollectors
extends java.lang.Object
Collectors| Modifier and Type | Class and Description |
|---|---|
static class |
ParallelCollectors.Batching
A subset of collectors which perform operations in batches and not separately (one object in a thread pool's worker queue represents a batch of operations to be performed by a single thread)
|
| 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)
Deprecated.
|
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)
Deprecated.
|
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)
Deprecated.
|
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)
Deprecated.
|
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. |
static <T> java.util.stream.Collector<java.util.concurrent.CompletableFuture<T>,?,java.util.concurrent.CompletableFuture<java.util.List<T>>> |
toFuture()
A convenience
Collector for collecting a Stream<CompletableFuture<T>> into a CompletableFuture<List<T>> |
static <T,R> java.util.stream.Collector<java.util.concurrent.CompletableFuture<T>,?,java.util.concurrent.CompletableFuture<R>> |
toFuture(java.util.stream.Collector<T,?,R> collector)
A convenience
Collector for collecting a Stream<CompletableFuture<T>>
into a CompletableFuture<R> using a provided Collector<T, ?, R> |
@Deprecated
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)
parallel(Function, Collector, Executor, int)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.
Runtime.availableProcessors() - 1
CompletableFuture<List<String>> result = Stream.of(1, 2, 3)
.collect(parallel(i -> foo(i), toList(), executor));
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 executionCollector which collects all processed elements into a user-provided mutable Collection in parallelpublic 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 parallel@Deprecated
public 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)
parallel(Function, Executor, int)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));
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 executionCollector which collects all processed elements into a Stream 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 parallel@Deprecated
public 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)
parallelToStream(Function, Executor, int)Collector used for executing parallel computations on a custom Executor
and returning a Stream instance returning results in completion order
For the parallelism of 1, the stream is executed by the calling thread.
The max parallelism level defaults to Runtime.availableProcessors() - 1
Instances should not be reused.
Example:
List<String> result = Stream.of(1, 2, 3)
.collect(parallelToStream(i -> foo(), executor))
.collect(toList());
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 executionCollector 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 parallel@Deprecated
public 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)
parallelToOrderedStream(Function, Executor, int)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.
The max parallelism level defaults to Runtime.availableProcessors() - 1
Instances should not be reused.
Example:
Stream.of(1, 2, 3)
.collect(parallelToOrderedStream(i -> foo(), executor))
.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 executionCollector 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 parallelpublic static <T,R> java.util.stream.Collector<java.util.concurrent.CompletableFuture<T>,?,java.util.concurrent.CompletableFuture<R>> toFuture(java.util.stream.Collector<T,?,R> collector)
Collector for collecting a Stream<CompletableFuture<T>>
into a CompletableFuture<R> using a provided Collector<T, ?, R>T - the type of the collected elementsR - the result of the transformationcollector - the Collector describing the reductionCollector which collects all futures and combines them into a single future
using the provided downstream Collectorpublic static <T> java.util.stream.Collector<java.util.concurrent.CompletableFuture<T>,?,java.util.concurrent.CompletableFuture<java.util.List<T>>> toFuture()
Collector for collecting a Stream<CompletableFuture<T>> into a CompletableFuture<List<T>>T - the type of the collected elementsCollector which collects all futures and combines them into a single future
returning a list of resultsCopyright © 2020. All Rights Reserved.