@@ -1149,7 +1149,8 @@ trait FlowOps[+Out, +Mat] {
1149
1149
* @param onComplete a function that transforms the ongoing state into an optional output element
1150
1150
*/
1151
1151
def statefulMap [S , T ](create : () => S )(f : (S , Out ) => (S , T ), onComplete : S => Option [T ]): Repr [T ] =
1152
- via(new StatefulMap [S , Out , T ](create, f, onComplete).withAttributes(DefaultAttributes .statefulMap))
1152
+ via(new StatefulMap [S , Out , T ](create, f, onComplete)
1153
+ .withAttributes(DefaultAttributes .statefulMap and SourceLocation .forLambda(f)))
1153
1154
1154
1155
/**
1155
1156
* Transform each stream element with the help of a resource.
@@ -1358,12 +1359,12 @@ trait FlowOps[+Out, +Mat] {
1358
1359
def mapAsyncPartitioned [T , P ](parallelism : Int )(
1359
1360
partitioner : Out => P )(
1360
1361
f : (Out , P ) => Future [T ]): Repr [T ] = {
1361
- ( if (parallelism == 1 ) {
1362
- via( MapAsyncUnordered (1 , elem => f(elem, partitioner(elem) )))
1363
- } else {
1364
- via( new MapAsyncPartitioned (parallelism, orderedOutput = true , partitioner, f) )
1365
- })
1366
- .withAttributes(DefaultAttributes .mapAsyncPartition and SourceLocation .forLambda(f))
1362
+ val graph : Graph [ FlowShape [ Out , T ], _] = if (parallelism == 1 ) {
1363
+ MapAsyncUnordered (1 , elem => f(elem, partitioner(elem)))
1364
+ } else {
1365
+ new MapAsyncPartitioned (parallelism, orderedOutput = true , partitioner, f)
1366
+ }
1367
+ via(graph .withAttributes(DefaultAttributes .mapAsyncPartition and SourceLocation .forLambda(f) ))
1367
1368
}
1368
1369
1369
1370
/**
@@ -1396,11 +1397,12 @@ trait FlowOps[+Out, +Mat] {
1396
1397
def mapAsyncPartitionedUnordered [T , P ](parallelism : Int )(
1397
1398
partitioner : Out => P )(
1398
1399
f : (Out , P ) => Future [T ]): Repr [T ] = {
1399
- (if (parallelism == 1 ) {
1400
- via(MapAsyncUnordered (1 , elem => f(elem, partitioner(elem))))
1401
- } else {
1402
- via(new MapAsyncPartitioned (parallelism, orderedOutput = false , partitioner, f))
1403
- }).withAttributes(DefaultAttributes .mapAsyncPartitionUnordered and SourceLocation .forLambda(f))
1400
+ val graph : Graph [FlowShape [Out , T ], _] = if (parallelism == 1 ) {
1401
+ MapAsyncUnordered (1 , elem => f(elem, partitioner(elem)))
1402
+ } else {
1403
+ new MapAsyncPartitioned (parallelism, orderedOutput = false , partitioner, f)
1404
+ }
1405
+ via(graph.withAttributes(DefaultAttributes .mapAsyncPartition and SourceLocation .forLambda(f)))
1404
1406
}
1405
1407
1406
1408
/**
0 commit comments