He-Pin commented on code in PR #329: URL: https://github.com/apache/incubator-pekko-connectors/pull/329#discussion_r1468380235
########## google-common/src/main/scala/org/apache/pekko/stream/connectors/google/ResumableUpload.scala: ########## @@ -61,14 +61,9 @@ private[connectors] object ResumableUpload { val in = Flow[ByteString] .via(chunker(uploadChunkSize)) - .statefulMapConcat { () => - var cumulativeLength = 0L - bytes => { - val chunk = Chunk(bytes, cumulativeLength) - cumulativeLength += bytes.length - chunk :: Nil - } - } + .statefulMap(() => 0L)((cumulativeLength, bytes) => + (cumulativeLength + bytes.length, Chunk(bytes, cumulativeLength)), + _ => None) Review Comment: These three flow can be optimized with a single statefulmap I think ,but leave that for another pr. ########## google-common/src/main/scala/org/apache/pekko/stream/connectors/google/ResumableUpload.scala: ########## @@ -61,14 +61,9 @@ private[connectors] object ResumableUpload { val in = Flow[ByteString] .via(chunker(uploadChunkSize)) - .statefulMapConcat { () => - var cumulativeLength = 0L - bytes => { - val chunk = Chunk(bytes, cumulativeLength) - cumulativeLength += bytes.length - chunk :: Nil - } - } + .statefulMap(() => 0L)((cumulativeLength, bytes) => + (cumulativeLength + bytes.length, Chunk(bytes, cumulativeLength)), + _ => None) Review Comment: These three flows can be optimized with a single statefulmap I think , but leave that for another pr. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org For additional commands, e-mail: notifications-h...@pekko.apache.org