Add GroupedWeighted FlowOp and Make Grouped use GroupedWeighted #29066
This commit is contained in:
parent
dffd7099fd
commit
4d9b25579d
18 changed files with 351 additions and 30 deletions
|
|
@ -46,6 +46,7 @@ import akka.stream.Attributes;
|
|||
// #log
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.function.IntSupplier;
|
||||
|
|
@ -340,6 +341,22 @@ class SourceOrFlow {
|
|||
// #grouped
|
||||
}
|
||||
|
||||
void groupedWeightedExample() {
|
||||
// #groupedWeighted
|
||||
Source.from(Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4), Arrays.asList(5, 6)))
|
||||
.groupedWeighted(4, x -> (long) x.size())
|
||||
.runForeach(System.out::println, system);
|
||||
// [[1, 2], [3, 4]]
|
||||
// [[5, 6]]
|
||||
|
||||
Source.from(Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4), Arrays.asList(5, 6)))
|
||||
.groupedWeighted(3, x -> (long) x.size())
|
||||
.runForeach(System.out::println, system);
|
||||
// [[1, 2], [3, 4]]
|
||||
// [[5, 6]]
|
||||
// #groupedWeighted
|
||||
}
|
||||
|
||||
static
|
||||
// #fold // #foldAsync
|
||||
class Histogram {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue