-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: avoid boxing in zipWithIndex and fix type signature in SubSource#zipWithIndex #1669
Conversation
@@ -2246,8 +2247,9 @@ class SubSource[Out, Mat]( | |||
* | |||
* '''Cancels when''' downstream cancels | |||
*/ | |||
def zipWithIndex: javadsl.SubSource[pekko.japi.Pair[Out @uncheckedVariance, Long], Mat] = | |||
new SubSource(delegate.zipWithIndex.map { case (elem, index) => pekko.japi.Pair(elem, index) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too much boxing for Java users, that's unfair.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stream/src/main/scala/org/apache/pekko/stream/impl/fusing/Ops.scala
Outdated
Show resolved
Hide resolved
stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala
Outdated
Show resolved
Hide resolved
46042b8
to
de96089
Compare
948c53b
to
d197bf7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, would be great if @raboof could also review it (hopefully can avoid making a regression this time).
@mdedetrich Yes, with additional test added and actually find a bug in the |
#1526 added a test so we shold be able to avoid the same break as before - but we could still hit issues in other untested scenarios |
...ima-filters/1.0.x.backwards.excludes/pr-1669-avoid-boxing-in-zipWithIndex.backwards.excludes
Outdated
Show resolved
Hide resolved
stream/src/main/scala/org/apache/pekko/stream/impl/JavaStreamSource.scala
Outdated
Show resolved
Hide resolved
stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala
Outdated
Show resolved
Hide resolved
stream/src/main/scala/org/apache/pekko/stream/scaladsl/FlowWithContext.scala
Outdated
Show resolved
Hide resolved
d197bf7
to
4e9ad90
Compare
removed 'bug' label - this is a performance improvement according to the description |
@pjfanning it's a bug too, the signature on |
Can you fix the description then to mention this? |
4e9ad90
to
90a91d7
Compare
@pjfanning @mdedetrich @raboof Would you like to give this another look , the confit have been fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Motivation:
instead of chore: Implement zipWithIndex with statefulMap #1657
Pair <T, Object>
instead ofPair<T, java.lang.Long>
, which is a bugModification:
Reimplemented it in a dedicated graph stage.
Result:
Better performance and fix
SubSource#zipWithIndex