You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2025/12/08 03:32:34 UTC
[PR] chore: Matching on seq [pekko]
He-Pin opened a new pull request, #2561:
URL: https://github.com/apache/pekko/pull/2561
The pr against Scala is rejected, so I need to handle it here.
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] chore: Matching on seq [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2561:
URL: https://github.com/apache/pekko/pull/2561#discussion_r2599528863
##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala:
##########
@@ -402,13 +402,15 @@ object Source {
* stream will see an individual flow of elements (always starting from the
* beginning) regardless of when they subscribed.
*/
- def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = {
- (iterable.knownSize: @switch) match {
- case 0 => empty
- case 1 => single(iterable.head)
- case _ =>
- fromGraph(new IterableSource[T](iterable)).withAttributes(DefaultAttributes.iterableSource)
- }
+ def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = iterable match {
+ case immutable.Seq() => empty[T]
Review Comment:
It's very the materilization
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] chore: Matching on seq [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #2561:
URL: https://github.com/apache/pekko/pull/2561#issuecomment-3636294980
https://github.com/apache/pekko/pull/2562 is merged
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] chore: Matching on seq [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2561:
URL: https://github.com/apache/pekko/pull/2561#discussion_r2599526580
##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala:
##########
@@ -402,13 +402,15 @@ object Source {
* stream will see an individual flow of elements (always starting from the
* beginning) regardless of when they subscribed.
*/
- def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = {
- (iterable.knownSize: @switch) match {
- case 0 => empty
- case 1 => single(iterable.head)
- case _ =>
- fromGraph(new IterableSource[T](iterable)).withAttributes(DefaultAttributes.iterableSource)
- }
+ def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = iterable match {
+ case immutable.Seq() => empty[T]
+ case immutable.Seq(elem: T @unchecked) => single(elem)
+ case other => (other.knownSize: @switch) match {
Review Comment:
It's not unknown size,just the size can or not been cheaply cimputed
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] chore: Matching on seq [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #2561:
URL: https://github.com/apache/pekko/pull/2561#discussion_r2599184733
##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala:
##########
@@ -402,13 +402,15 @@ object Source {
* stream will see an individual flow of elements (always starting from the
* beginning) regardless of when they subscribed.
*/
- def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = {
- (iterable.knownSize: @switch) match {
- case 0 => empty
- case 1 => single(iterable.head)
- case _ =>
- fromGraph(new IterableSource[T](iterable)).withAttributes(DefaultAttributes.iterableSource)
- }
+ def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = iterable match {
+ case immutable.Seq() => empty[T]
+ case immutable.Seq(elem: T @unchecked) => single(elem)
+ case other => (other.knownSize: @switch) match {
Review Comment:
Can you add a comment saying that if the Iterable has unknown size, that knownSize returns -1?
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] chore: Matching on seq [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #2561:
URL: https://github.com/apache/pekko/pull/2561#discussion_r2599528863
##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala:
##########
@@ -402,13 +402,15 @@ object Source {
* stream will see an individual flow of elements (always starting from the
* beginning) regardless of when they subscribed.
*/
- def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = {
- (iterable.knownSize: @switch) match {
- case 0 => empty
- case 1 => single(iterable.head)
- case _ =>
- fromGraph(new IterableSource[T](iterable)).withAttributes(DefaultAttributes.iterableSource)
- }
+ def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = iterable match {
+ case immutable.Seq() => empty[T]
Review Comment:
It's vs the materialization
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] chore: Matching on seq [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #2561:
URL: https://github.com/apache/pekko/pull/2561#issuecomment-3636476424
@pjfanning Cool~
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] chore: Matching on seq [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #2561:
URL: https://github.com/apache/pekko/pull/2561#discussion_r2599091229
##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala:
##########
@@ -402,13 +402,15 @@ object Source {
* stream will see an individual flow of elements (always starting from the
* beginning) regardless of when they subscribed.
*/
- def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = {
- (iterable.knownSize: @switch) match {
- case 0 => empty
- case 1 => single(iterable.head)
- case _ =>
- fromGraph(new IterableSource[T](iterable)).withAttributes(DefaultAttributes.iterableSource)
- }
+ def apply[T](iterable: immutable.Iterable[T]): Source[T, NotUsed] = iterable match {
+ case immutable.Seq() => empty[T]
Review Comment:
I don't see how adding extra checks, including instanceof checks, improves performance. Is there any way that we could keep a variant of the old code from the recent other PR that introduced changes?
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] chore: Matching on seq [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin closed pull request #2561: chore: Matching on seq
URL: https://github.com/apache/pekko/pull/2561
--
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-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org