-
Notifications
You must be signed in to change notification settings - Fork 154
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
feat: Add TraversalBuilder.getValuePresentedSource method for further optimization #1701
base: main
Are you sure you want to change the base?
Conversation
@@ -23,7 +23,7 @@ import java.util.function.Consumer | |||
|
|||
/** INTERNAL API */ | |||
@InternalApi private[stream] final class JavaStreamSource[T, S <: java.util.stream.BaseStream[T, S]]( | |||
open: () => java.util.stream.BaseStream[T, S]) | |||
val open: () => java.util.stream.BaseStream[T, S]) |
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.
needed for optimization.
@@ -22,7 +22,7 @@ import pekko.stream.stage.{ GraphStage, GraphStageLogic, OutHandler } | |||
/** | |||
* INTERNAL API | |||
*/ | |||
@InternalApi private[pekko] final class FailedSource[T](failure: Throwable) extends GraphStage[SourceShape[T]] { | |||
@InternalApi private[pekko] final class FailedSource[T](val failure: Throwable) extends GraphStage[SourceShape[T]] { |
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.
needed for optimization.
684155c
to
0735893
Compare
/** | ||
* Test if a Graph is an empty Source. | ||
*/ | ||
def isEmptySource(graph: Graph[SourceShape[_], _]): Boolean = graph match { | ||
case source: scaladsl.Source[_, _] if source eq scaladsl.Source.empty => true | ||
case source: javadsl.Source[_, _] if source eq javadsl.Source.empty() => true | ||
case EmptySource => true |
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.
this doesn't look related to this change - is this a bug that needs to be fixed in its own PR?
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.
It's not a bug, just a missing optimization case.
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.
I thought that the cases were evaluated in order so this would not change performance in that case and it would actually lead to a different result if EmptySource was matched but that neither of the first 2 cases matched.
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.
these methods are internal methods acutually.
} | ||
|
||
"find Source.empty via TraversalBuilder with getValuePresentedSource" in { | ||
val emptySource = EmptySource |
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.
@pjfanning the tests coverage is here for the EmptySource
0735893
to
5ee21b8
Compare
After this pr get merged, we can do some optimization for |
Motivation:
Add helper method to extract the value presented graph which will enable future optimization.
which is needed in #1672
Modification:
Add TraversalBuilder.getValuePresentedSource method
Result:
TraversalBuilder.getValuePresentedSource internal method added