+str Add concatAllLazy stream operator (#31299)
This commit is contained in:
parent
d09d69198e
commit
078ddfa88c
12 changed files with 325 additions and 6 deletions
|
|
@ -22,6 +22,7 @@ import akka.japi.function.Function2;
|
|||
// #prependLazy
|
||||
// #concat
|
||||
// #concatLazy
|
||||
// #concatAllLazy
|
||||
// #interleave
|
||||
// #interleaveAll
|
||||
// #merge
|
||||
|
|
@ -38,6 +39,7 @@ import java.util.*;
|
|||
// #interleaveAll
|
||||
// #concat
|
||||
// #concatLazy
|
||||
// #concatAllLazy
|
||||
// #prepend
|
||||
// #prependLazy
|
||||
// #or-else
|
||||
|
|
@ -54,6 +56,7 @@ import akka.stream.Attributes;
|
|||
import java.time.Duration;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class SourceOrFlow {
|
||||
private static ActorSystem system = null;
|
||||
|
|
@ -149,13 +152,25 @@ class SourceOrFlow {
|
|||
}
|
||||
|
||||
void concatLazyExample() {
|
||||
// #concat
|
||||
// #concatLazy
|
||||
Source<Integer, NotUsed> sourceA = Source.from(Arrays.asList(1, 2, 3, 4));
|
||||
Source<Integer, NotUsed> sourceB = Source.from(Arrays.asList(10, 20, 30, 40));
|
||||
sourceA.concatLazy(sourceB).runForeach(System.out::println, system);
|
||||
// prints 1, 2, 3, 4, 10, 20, 30, 40
|
||||
|
||||
// #concat
|
||||
// #concatLazy
|
||||
}
|
||||
|
||||
void concatAllLazyExample() {
|
||||
// #concatAllLazy
|
||||
Source<Integer, NotUsed> sourceA = Source.from(Arrays.asList(1, 2, 3));
|
||||
Source<Integer, NotUsed> sourceB = Source.from(Arrays.asList(4, 5, 6));
|
||||
Source<Integer, NotUsed> sourceC = Source.from(Arrays.asList(7, 8 , 9));
|
||||
sourceA.concatAllLazy(sourceB, sourceC)
|
||||
.fold(new StringJoiner(","), (joiner, input) -> joiner.add(String.valueOf(input)))
|
||||
.runForeach(System.out::println, system);
|
||||
//prints 1,2,3,4,5,6,7,8,9
|
||||
// #concatAllLazy
|
||||
}
|
||||
|
||||
void interleaveExample() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue