1 | package com.pivovarit.collectors; | |
2 | ||
3 | import java.util.List; | |
4 | import java.util.concurrent.CompletableFuture; | |
5 | import java.util.concurrent.Executor; | |
6 | import java.util.function.Function; | |
7 | import java.util.stream.Collector; | |
8 | import java.util.stream.Stream; | |
9 | ||
10 | /** | |
11 | * An umbrella class exposing static factory methods for instantiating parallel {@link Collector}s | |
12 | * | |
13 | * @author Grzegorz Piwowarek | |
14 | */ | |
15 | public final class ParallelCollectors { | |
16 | ||
17 | private ParallelCollectors() { | |
18 | } | |
19 | ||
20 | /** | |
21 | * A convenience {@link Collector} used for executing parallel computations using Virtual Threads | |
22 | * and returning them as a {@link CompletableFuture} containing a result of the application of the user-provided {@link Collector}. | |
23 | * | |
24 | * <br> | |
25 | * Example: | |
26 | * <pre>{@code | |
27 | * CompletableFuture<List<String>> result = Stream.of(1, 2, 3) | |
28 | * .collect(parallel(i -> foo(i), toList())); | |
29 | * }</pre> | |
30 | * | |
31 | * @param mapper a transformation to be performed in parallel | |
32 | * @param collector the {@code Collector} describing the reduction | |
33 | * @param <T> the type of the collected elements | |
34 | * @param <R> the result returned by {@code mapper} | |
35 | * @param <RR> the reduction result {@code collector} | |
36 | * | |
37 | * @return a {@code Collector} which collects all processed elements into a user-provided mutable {@code Collection} in parallel | |
38 | * | |
39 | * @since 3.0.0 | |
40 | */ | |
41 | public static <T, R, RR> Collector<T, ?, CompletableFuture<RR>> parallel(Function<T, R> mapper, Collector<R, ?, RR> collector) { | |
42 |
1
1. parallel : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallel → KILLED |
return AsyncParallelCollector.collectingWithCollector(collector, mapper); |
43 | } | |
44 | ||
45 | /** | |
46 | * A convenience {@link Collector} used for executing parallel computations using Virtual Threads | |
47 | * and returning them as a {@link CompletableFuture} containing a result of the application of the user-provided {@link Collector}. | |
48 | * | |
49 | * <br> | |
50 | * Example: | |
51 | * <pre>{@code | |
52 | * CompletableFuture<List<String>> result = Stream.of(1, 2, 3) | |
53 | * .collect(parallel(i -> foo(i), toList(), executor, 2)); | |
54 | * }</pre> | |
55 | * | |
56 | * @param mapper a transformation to be performed in parallel | |
57 | * @param collector the {@code Collector} describing the reduction | |
58 | * @param <T> the type of the collected elements | |
59 | * @param <R> the result returned by {@code mapper} | |
60 | * @param <RR> the reduction result {@code collector} | |
61 | * @param parallelism the max parallelism level | |
62 | * | |
63 | * @return a {@code Collector} which collects all processed elements into a user-provided mutable {@code Collection} in parallel | |
64 | * | |
65 | * @since 3.2.0 | |
66 | */ | |
67 | public static <T, R, RR> Collector<T, ?, CompletableFuture<RR>> parallel(Function<T, R> mapper, Collector<R, ?, RR> collector, int parallelism) { | |
68 |
1
1. parallel : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallel → KILLED |
return AsyncParallelCollector.collectingWithCollector(collector, mapper, parallelism); |
69 | } | |
70 | ||
71 | /** | |
72 | * A convenience {@link Collector} used for executing parallel computations on a custom {@link Executor} | |
73 | * and returning them as a {@link CompletableFuture} containing a result of the application of the user-provided {@link Collector}. | |
74 | * | |
75 | * <br> | |
76 | * Example: | |
77 | * <pre>{@code | |
78 | * CompletableFuture<List<String>> result = Stream.of(1, 2, 3) | |
79 | * .collect(parallel(i -> foo(i), toList(), executor, 2)); | |
80 | * }</pre> | |
81 | * | |
82 | * @param mapper a transformation to be performed in parallel | |
83 | * @param collector the {@code Collector} describing the reduction | |
84 | * @param executor the {@code Executor} to use for asynchronous execution | |
85 | * @param <T> the type of the collected elements | |
86 | * @param <R> the result returned by {@code mapper} | |
87 | * @param <RR> the reduction result {@code collector} | |
88 | * @param parallelism the max parallelism level | |
89 | * | |
90 | * @return a {@code Collector} which collects all processed elements into a user-provided mutable {@code Collection} in parallel | |
91 | * | |
92 | * @since 2.0.0 | |
93 | */ | |
94 | public static <T, R, RR> Collector<T, ?, CompletableFuture<RR>> parallel(Function<T, R> mapper, Collector<R, ?, RR> collector, Executor executor, int parallelism) { | |
95 |
1
1. parallel : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallel → KILLED |
return AsyncParallelCollector.collectingWithCollector(collector, mapper, executor, parallelism); |
96 | } | |
97 | ||
98 | /** | |
99 | * A convenience {@link Collector} used for executing parallel computations using Virtual Threads | |
100 | * and returning them as {@link CompletableFuture} containing a {@link Stream} of these elements. | |
101 | * | |
102 | * <br><br> | |
103 | * The collector maintains the order of processed {@link Stream}. Instances should not be reused. | |
104 | * | |
105 | * <br> | |
106 | * Example: | |
107 | * <pre>{@code | |
108 | * CompletableFuture<Stream<String>> result = Stream.of(1, 2, 3) | |
109 | * .collect(parallel(i -> foo())); | |
110 | * }</pre> | |
111 | * | |
112 | * @param mapper a transformation to be performed in parallel | |
113 | * @param <T> the type of the collected elements | |
114 | * @param <R> the result returned by {@code mapper} | |
115 | * | |
116 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
117 | * | |
118 | * @since 3.0.0 | |
119 | */ | |
120 | public static <T, R> Collector<T, ?, CompletableFuture<Stream<R>>> parallel(Function<T, R> mapper) { | |
121 |
1
1. parallel : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallel → KILLED |
return AsyncParallelCollector.collectingToStream(mapper); |
122 | } | |
123 | ||
124 | /** | |
125 | * A convenience {@link Collector} used for executing parallel computations using Virtual Threads | |
126 | * and returning them as {@link CompletableFuture} containing a {@link Stream} of these elements. | |
127 | * | |
128 | * <br><br> | |
129 | * The collector maintains the order of processed {@link Stream}. Instances should not be reused. | |
130 | * | |
131 | * <br> | |
132 | * Example: | |
133 | * <pre>{@code | |
134 | * CompletableFuture<Stream<String>> result = Stream.of(1, 2, 3) | |
135 | * .collect(parallel(i -> foo())); | |
136 | * }</pre> | |
137 | * | |
138 | * @param mapper a transformation to be performed in parallel | |
139 | * @param <T> the type of the collected elements | |
140 | * @param <R> the result returned by {@code mapper} | |
141 | * | |
142 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
143 | * | |
144 | * @since 3.2.0 | |
145 | */ | |
146 | public static <T, R> Collector<T, ?, CompletableFuture<Stream<R>>> parallel(Function<T, R> mapper, int parallelism) { | |
147 |
1
1. parallel : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallel → KILLED |
return AsyncParallelCollector.collectingToStream(mapper, parallelism); |
148 | } | |
149 | ||
150 | /** | |
151 | * A convenience {@link Collector} used for executing parallel computations on a custom {@link Executor} | |
152 | * and returning them as {@link CompletableFuture} containing a {@link Stream} of these elements. | |
153 | * | |
154 | * <br><br> | |
155 | * The collector maintains the order of processed {@link Stream}. Instances should not be reused. | |
156 | * | |
157 | * <br> | |
158 | * Example: | |
159 | * <pre>{@code | |
160 | * CompletableFuture<Stream<String>> result = Stream.of(1, 2, 3) | |
161 | * .collect(parallel(i -> foo(), executor, 2)); | |
162 | * }</pre> | |
163 | * | |
164 | * @param mapper a transformation to be performed in parallel | |
165 | * @param executor the {@code Executor} to use for asynchronous execution | |
166 | * @param parallelism the max parallelism level | |
167 | * @param <T> the type of the collected elements | |
168 | * @param <R> the result returned by {@code mapper} | |
169 | * | |
170 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
171 | * | |
172 | * @since 2.0.0 | |
173 | */ | |
174 | public static <T, R> Collector<T, ?, CompletableFuture<Stream<R>>> parallel(Function<T, R> mapper, Executor executor, int parallelism) { | |
175 |
1
1. parallel : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallel → KILLED |
return AsyncParallelCollector.collectingToStream(mapper, executor, parallelism); |
176 | } | |
177 | ||
178 | /** | |
179 | * A convenience {@link Collector} used for executing parallel computations using Virtual Threads | |
180 | * and returning a {@link Stream} instance returning results as they arrive. | |
181 | * <p> | |
182 | * For the parallelism of 1, the stream is executed by the calling thread. | |
183 | * | |
184 | * <br> | |
185 | * Example: | |
186 | * <pre>{@code | |
187 | * Stream.of(1, 2, 3) | |
188 | * .collect(parallelToStream(i -> foo())) | |
189 | * .forEach(System.out::println); | |
190 | * }</pre> | |
191 | * | |
192 | * @param mapper a transformation to be performed in parallel | |
193 | * @param <T> the type of the collected elements | |
194 | * @param <R> the result returned by {@code mapper} | |
195 | * | |
196 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
197 | * | |
198 | * @since 3.0.0 | |
199 | */ | |
200 | public static <T, R> Collector<T, ?, Stream<R>> parallelToStream(Function<T, R> mapper) { | |
201 |
1
1. parallelToStream : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallelToStream → KILLED |
return ParallelStreamCollector.streaming(mapper); |
202 | } | |
203 | ||
204 | /** | |
205 | * A convenience {@link Collector} used for executing parallel computations using Virtual Threads | |
206 | * and returning a {@link Stream} instance returning results as they arrive. | |
207 | * <p> | |
208 | * For the parallelism of 1, the stream is executed by the calling thread. | |
209 | * | |
210 | * <br> | |
211 | * Example: | |
212 | * <pre>{@code | |
213 | * Stream.of(1, 2, 3) | |
214 | * .collect(parallelToStream(i -> foo(), executor, 2)) | |
215 | * .forEach(System.out::println); | |
216 | * }</pre> | |
217 | * | |
218 | * @param mapper a transformation to be performed in parallel | |
219 | * @param parallelism the max parallelism level | |
220 | * @param <T> the type of the collected elements | |
221 | * @param <R> the result returned by {@code mapper} | |
222 | * | |
223 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
224 | * | |
225 | * @since 3.2.0 | |
226 | */ | |
227 | public static <T, R> Collector<T, ?, Stream<R>> parallelToStream(Function<T, R> mapper, int parallelism) { | |
228 |
1
1. parallelToStream : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallelToStream → KILLED |
return ParallelStreamCollector.streaming(mapper, parallelism); |
229 | } | |
230 | ||
231 | /** | |
232 | * A convenience {@link Collector} used for executing parallel computations on a custom {@link Executor} | |
233 | * and returning a {@link Stream} instance returning results as they arrive. | |
234 | * <p> | |
235 | * For the parallelism of 1, the stream is executed by the calling thread. | |
236 | * | |
237 | * <br> | |
238 | * Example: | |
239 | * <pre>{@code | |
240 | * Stream.of(1, 2, 3) | |
241 | * .collect(parallelToStream(i -> foo(), executor, 2)) | |
242 | * .forEach(System.out::println); | |
243 | * }</pre> | |
244 | * | |
245 | * @param mapper a transformation to be performed in parallel | |
246 | * @param executor the {@code Executor} to use for asynchronous execution | |
247 | * @param parallelism the max parallelism level | |
248 | * @param <T> the type of the collected elements | |
249 | * @param <R> the result returned by {@code mapper} | |
250 | * | |
251 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
252 | * | |
253 | * @since 2.0.0 | |
254 | */ | |
255 | public static <T, R> Collector<T, ?, Stream<R>> parallelToStream(Function<T, R> mapper, Executor executor, int parallelism) { | |
256 |
1
1. parallelToStream : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallelToStream → KILLED |
return ParallelStreamCollector.streaming(mapper, executor, parallelism); |
257 | } | |
258 | ||
259 | /** | |
260 | * A convenience {@link Collector} used for executing parallel computations using Virtual Threads | |
261 | * and returning a {@link Stream} instance returning results as they arrive while maintaining the initial order. | |
262 | * <p> | |
263 | * For the parallelism of 1, the stream is executed by the calling thread. | |
264 | * | |
265 | * <br> | |
266 | * Example: | |
267 | * <pre>{@code | |
268 | * Stream.of(1, 2, 3) | |
269 | * .collect(parallelToOrderedStream(i -> foo())) | |
270 | * .forEach(System.out::println); | |
271 | * }</pre> | |
272 | * | |
273 | * @param mapper a transformation to be performed in parallel | |
274 | * @param <T> the type of the collected elements | |
275 | * @param <R> the result returned by {@code mapper} | |
276 | * | |
277 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
278 | * | |
279 | * @since 3.0.0 | |
280 | */ | |
281 | public static <T, R> Collector<T, ?, Stream<R>> parallelToOrderedStream(Function<T, R> mapper) { | |
282 |
1
1. parallelToOrderedStream : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallelToOrderedStream → KILLED |
return ParallelStreamCollector.streamingOrdered(mapper); |
283 | } | |
284 | ||
285 | /** | |
286 | * A convenience {@link Collector} used for executing parallel computations using Virtual Threads | |
287 | * and returning a {@link Stream} instance returning results as they arrive while maintaining the initial order. | |
288 | * <p> | |
289 | * For the parallelism of 1, the stream is executed by the calling thread. | |
290 | * | |
291 | * <br> | |
292 | * Example: | |
293 | * <pre>{@code | |
294 | * Stream.of(1, 2, 3) | |
295 | * .collect(parallelToOrderedStream(i -> foo(), executor, 2)) | |
296 | * .forEach(System.out::println); | |
297 | * }</pre> | |
298 | * | |
299 | * @param mapper a transformation to be performed in parallel | |
300 | * @param parallelism the max parallelism level | |
301 | * @param <T> the type of the collected elements | |
302 | * @param <R> the result returned by {@code mapper} | |
303 | * | |
304 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
305 | * | |
306 | * @since 3.2.0 | |
307 | */ | |
308 | public static <T, R> Collector<T, ?, Stream<R>> parallelToOrderedStream(Function<T, R> mapper, int parallelism) { | |
309 |
1
1. parallelToOrderedStream : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallelToOrderedStream → KILLED |
return ParallelStreamCollector.streamingOrdered(mapper, parallelism); |
310 | } | |
311 | ||
312 | /** | |
313 | * A convenience {@link Collector} used for executing parallel computations on a custom {@link Executor} | |
314 | * and returning a {@link Stream} instance returning results as they arrive while maintaining the initial order. | |
315 | * <p> | |
316 | * For the parallelism of 1, the stream is executed by the calling thread. | |
317 | * | |
318 | * <br> | |
319 | * Example: | |
320 | * <pre>{@code | |
321 | * Stream.of(1, 2, 3) | |
322 | * .collect(parallelToOrderedStream(i -> foo(), executor, 2)) | |
323 | * .forEach(System.out::println); | |
324 | * }</pre> | |
325 | * | |
326 | * @param mapper a transformation to be performed in parallel | |
327 | * @param executor the {@code Executor} to use for asynchronous execution | |
328 | * @param parallelism the max parallelism level | |
329 | * @param <T> the type of the collected elements | |
330 | * @param <R> the result returned by {@code mapper} | |
331 | * | |
332 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
333 | * | |
334 | * @since 2.0.0 | |
335 | */ | |
336 | public static <T, R> Collector<T, ?, Stream<R>> parallelToOrderedStream(Function<T, R> mapper, Executor executor, int parallelism) { | |
337 |
1
1. parallelToOrderedStream : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::parallelToOrderedStream → KILLED |
return ParallelStreamCollector.streamingOrdered(mapper, executor, parallelism); |
338 | } | |
339 | ||
340 | /** | |
341 | * A convenience {@code Collector} for collecting a {@code Stream<CompletableFuture<T>>} | |
342 | * into a {@code CompletableFuture<R>} using a provided {@code Collector<T, ?, R>} | |
343 | * | |
344 | * @param collector the {@code Collector} describing the reduction | |
345 | * @param <T> the type of the collected elements | |
346 | * @param <R> the result of the transformation | |
347 | * | |
348 | * @return a {@code Collector} which collects all futures and combines them into a single future | |
349 | * using the provided downstream {@code Collector} | |
350 | * | |
351 | * @since 2.3.0 | |
352 | */ | |
353 | public static <T, R> Collector<CompletableFuture<T>, ?, CompletableFuture<R>> toFuture(Collector<T, ?, R> collector) { | |
354 |
1
1. toFuture : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::toFuture → KILLED |
return FutureCollectors.toFuture(collector); |
355 | } | |
356 | ||
357 | /** | |
358 | * A convenience {@code Collector} for collecting a {@code Stream<CompletableFuture<T>>} into a {@code CompletableFuture<List<T>>} | |
359 | * | |
360 | * @param <T> the type of the collected elements | |
361 | * | |
362 | * @return a {@code Collector} which collects all futures and combines them into a single future | |
363 | * returning a list of results | |
364 | * | |
365 | * @since 2.3.0 | |
366 | */ | |
367 | public static <T> Collector<CompletableFuture<T>, ?, CompletableFuture<List<T>>> toFuture() { | |
368 |
1
1. toFuture : replaced return value with null for com/pivovarit/collectors/ParallelCollectors::toFuture → KILLED |
return FutureCollectors.toFuture(); |
369 | } | |
370 | ||
371 | /** | |
372 | * 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) | |
373 | */ | |
374 | public static final class Batching { | |
375 | ||
376 | private Batching() { | |
377 | } | |
378 | ||
379 | /** | |
380 | * A convenience {@link Collector} used for executing parallel computations on a custom {@link Executor} | |
381 | * and returning them as a {@link CompletableFuture} containing a result of the application of the user-provided {@link Collector}. | |
382 | * | |
383 | * <br> | |
384 | * Example: | |
385 | * <pre>{@code | |
386 | * CompletableFuture<List<String>> result = Stream.of(1, 2, 3) | |
387 | * .collect(parallel(i -> foo(i), toList(), executor, 2)); | |
388 | * }</pre> | |
389 | * | |
390 | * @param mapper a transformation to be performed in parallel | |
391 | * @param collector the {@code Collector} describing the reduction | |
392 | * @param executor the {@code Executor} to use for asynchronous execution | |
393 | * @param parallelism the max parallelism level | |
394 | * @param <T> the type of the collected elements | |
395 | * @param <R> the result returned by {@code mapper} | |
396 | * @param <RR> the reduction result {@code collector} | |
397 | * | |
398 | * @return a {@code Collector} which collects all processed elements into a user-provided mutable {@code Collection} in parallel | |
399 | * | |
400 | * @since 2.1.0 | |
401 | */ | |
402 | public static <T, R, RR> Collector<T, ?, CompletableFuture<RR>> parallel(Function<T, R> mapper, Collector<R, ?, RR> collector, Executor executor, int parallelism) { | |
403 |
1
1. parallel : replaced return value with null for com/pivovarit/collectors/ParallelCollectors$Batching::parallel → KILLED |
return AsyncParallelCollector.BatchingCollectors |
404 | .collectingWithCollector(collector, mapper, executor, parallelism); | |
405 | } | |
406 | ||
407 | /** | |
408 | * A convenience {@link Collector} used for executing parallel computations on a custom {@link Executor} | |
409 | * and returning them as {@link CompletableFuture} containing a {@link Stream} of these elements. | |
410 | * | |
411 | * <br><br> | |
412 | * The collector maintains the order of processed {@link Stream}. Instances should not be reused. | |
413 | * | |
414 | * <br> | |
415 | * Example: | |
416 | * <pre>{@code | |
417 | * CompletableFuture<Stream<String>> result = Stream.of(1, 2, 3) | |
418 | * .collect(parallel(i -> foo(), executor, 2)); | |
419 | * }</pre> | |
420 | * | |
421 | * @param mapper a transformation to be performed in parallel | |
422 | * @param executor the {@code Executor} to use for asynchronous execution | |
423 | * @param parallelism the max parallelism level | |
424 | * @param <T> the type of the collected elements | |
425 | * @param <R> the result returned by {@code mapper} | |
426 | * | |
427 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
428 | * | |
429 | * @since 2.1.0 | |
430 | */ | |
431 | public static <T, R> Collector<T, ?, CompletableFuture<Stream<R>>> parallel(Function<T, R> mapper, Executor executor, int parallelism) { | |
432 |
1
1. parallel : replaced return value with null for com/pivovarit/collectors/ParallelCollectors$Batching::parallel → KILLED |
return AsyncParallelCollector.BatchingCollectors.collectingToStream(mapper, executor, parallelism); |
433 | } | |
434 | ||
435 | /** | |
436 | * A convenience {@link Collector} used for executing parallel computations on a custom {@link Executor} | |
437 | * and returning a {@link Stream} instance returning results as they arrive. | |
438 | * <p> | |
439 | * For the parallelism of 1, the stream is executed by the calling thread. | |
440 | * | |
441 | * <br> | |
442 | * Example: | |
443 | * <pre>{@code | |
444 | * Stream.of(1, 2, 3) | |
445 | * .collect(parallelToStream(i -> foo(), executor, 2)) | |
446 | * .forEach(System.out::println); | |
447 | * }</pre> | |
448 | * | |
449 | * @param mapper a transformation to be performed in parallel | |
450 | * @param executor the {@code Executor} to use for asynchronous execution | |
451 | * @param parallelism the max parallelism level | |
452 | * @param <T> the type of the collected elements | |
453 | * @param <R> the result returned by {@code mapper} | |
454 | * | |
455 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
456 | * | |
457 | * @since 2.1.0 | |
458 | */ | |
459 | public static <T, R> Collector<T, ?, Stream<R>> parallelToStream(Function<T, R> mapper, Executor executor, int parallelism) { | |
460 |
1
1. parallelToStream : replaced return value with null for com/pivovarit/collectors/ParallelCollectors$Batching::parallelToStream → KILLED |
return ParallelStreamCollector.BatchingCollectors.streaming(mapper, executor, parallelism); |
461 | } | |
462 | ||
463 | /** | |
464 | * A convenience {@link Collector} used for executing parallel computations on a custom {@link Executor} | |
465 | * and returning a {@link Stream} instance returning results as they arrive while maintaining the initial order. | |
466 | * <p> | |
467 | * For the parallelism of 1, the stream is executed by the calling thread. | |
468 | * | |
469 | * <br> | |
470 | * Example: | |
471 | * <pre>{@code | |
472 | * Stream.of(1, 2, 3) | |
473 | * .collect(parallelToOrderedStream(i -> foo(), executor, 2)) | |
474 | * .forEach(System.out::println); | |
475 | * }</pre> | |
476 | * | |
477 | * @param mapper a transformation to be performed in parallel | |
478 | * @param executor the {@code Executor} to use for asynchronous execution | |
479 | * @param parallelism the max parallelism level | |
480 | * @param <T> the type of the collected elements | |
481 | * @param <R> the result returned by {@code mapper} | |
482 | * | |
483 | * @return a {@code Collector} which collects all processed elements into a {@code Stream} in parallel | |
484 | * | |
485 | * @since 2.1.0 | |
486 | */ | |
487 | public static <T, R> Collector<T, ?, Stream<R>> parallelToOrderedStream(Function<T, R> mapper, Executor executor, int parallelism) { | |
488 |
1
1. parallelToOrderedStream : replaced return value with null for com/pivovarit/collectors/ParallelCollectors$Batching::parallelToOrderedStream → KILLED |
return ParallelStreamCollector.BatchingCollectors.streamingOrdered(mapper, executor, parallelism); |
489 | } | |
490 | } | |
491 | } | |
Mutations | ||
42 |
1.1 |
|
68 |
1.1 |
|
95 |
1.1 |
|
121 |
1.1 |
|
147 |
1.1 |
|
175 |
1.1 |
|
201 |
1.1 |
|
228 |
1.1 |
|
256 |
1.1 |
|
282 |
1.1 |
|
309 |
1.1 |
|
337 |
1.1 |
|
354 |
1.1 |
|
368 |
1.1 |
|
403 |
1.1 |
|
432 |
1.1 |
|
460 |
1.1 |
|
488 |
1.1 |