!str #19005 make groupBy et al return a SubFlow
A SubFlow (or SubSource) is not a Graph, it is an unfinished builder that accepts transformations. This allows us to capture the substreams’ transformations before materializing the flow, which will be very helpful in fully fusing all operators. Another change is that groupBy now requires a maxSubstreams parameter in order to bound its resource usage. In exchange the matching merge can be unbounded. This trades silent deadlock for explicit stream failure. This commit also changes all uses of Predef.identity to use `conforms` and removes the HTTP impl.util.identityFunc.
This commit is contained in:
parent
654fa41443
commit
1500d1f36d
56 changed files with 3484 additions and 720 deletions
|
|
@ -116,6 +116,21 @@ class MigrationsScala extends AkkaSpec {
|
|||
Flow[Source[Int, Any]].flatMapConcat(identity)
|
||||
//#flatMapConcat
|
||||
|
||||
//#group-flatten
|
||||
Flow[Int]
|
||||
.groupBy(2, _ % 2) // the first parameter sets max number of substreams
|
||||
.map(_ + 3)
|
||||
.concatSubstreams
|
||||
//#group-flatten
|
||||
|
||||
val MaxDistinctWords = 1000
|
||||
//#group-fold
|
||||
Flow[String]
|
||||
.groupBy(MaxDistinctWords, identity)
|
||||
.fold(("", 0))((pair, word) => (word, pair._2 + 1))
|
||||
.mergeSubstreams
|
||||
//#group-fold
|
||||
|
||||
//#port-async
|
||||
class MapAsyncOne[In, Out](f: In ⇒ Future[Out])(implicit ec: ExecutionContext)
|
||||
extends GraphStage[FlowShape[In, Out]] {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue