Add GroupedWeighted FlowOp and Make Grouped use GroupedWeighted #29066

This commit is contained in:
Michael Marshall 2021-01-27 10:03:30 -07:00 committed by GitHub
parent dffd7099fd
commit 4d9b25579d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 351 additions and 30 deletions

View file

@ -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 {