-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
[SPARK-46124][CORE][SQL][SS][CONNECT][DSTREAM][MLLIB][ML][PYTHON][R][AVRO][K8S][YARN][UI] Replace explicit ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
#44041
Conversation
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
ArrayOps#toSeq
with s.c.immutable.ArraySeq.unsafeWrapArray
cc @srowen, could you help to review this pr if you have time. Thanks Similar to #43666, the purpose of this pr is also to save a collection copy by using |
Seems reasonable to me, continuing the same refactoring. Is it ready? |
Yes, it's ready |
@srowen this PR Is ready, should we push it forward? |
Merged to master |
Thanks @srowen |
What changes were proposed in this pull request?
There is a behavioral difference between Scala 2.13 and 2.12 for explicit
ArrayOps.toSeq
calls, similar to the implicit conversion fromArray
toSeq
.In Scala 2.12,
ArrayOps.toSeq
will returnthisCollection
, and use implicit conversion rules to wrap theArray
asmutable.WrappedArray
, this process does not involve any collection copy:However, in Scala 2.13, it returns an
immutable.ArraySeq
that with collection copy.Since we have always used the non-collection copy behavior for this explicit conversion in the era of Scala 2.12, it is safe to assume that no collection copy is needed for Scala 2.13.
Therefore, this pr replaces explicit
ArrayOps.toSeq
in the Spark code withs.c.immutable.ArraySeq.unsafeWrapArray
to avoid a collection copy, and this pr only involves changes to the production code, and does not involve changes to the test code.Why are the changes needed?
Replace
ArrayOps#toSeq
withs.c.immutable.ArraySeq.unsafeWrapArray
to save a collection copy, which has potential benefits for performance."Does this PR introduce any user-facing change?
No
How was this patch tested?
Pass GitHub Action
Was this patch authored or co-authored using generative AI tooling?
No