-
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-45742][CORE][CONNECT][MLLIB][PYTHON] Introduce an implicit function for Scala Array to wrap into immutable.ArraySeq
.
#43607
Conversation
immutable.ArraySeq
.immutable.ArraySeq
.
immutable.ArraySeq
.immutable.ArraySeq
.
* Wraps an Array[T] as an immutable.ArraySeq[T] without copying. | ||
*/ | ||
def toImmutableArraySeq: immutable.ArraySeq[T] = | ||
if (xs eq null) null |
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.
Welcome to Scala 2.13.12 (OpenJDK 64-Bit Server VM, Java 17.0.8).
Type in expressions for evaluation. Or try :help.
scala> val a: Array[Int] = null
val a: Array[Int] = null
scala> scala.collection.immutable.ArraySeq.unsafeWrapArray(a)
val res0: scala.collection.immutable.ArraySeq[Int] = null
import org.apache.spark.SparkFunSuite | ||
import org.apache.spark.util.ArrayImplicits._ | ||
|
||
class ArrayImplicitsSuite extends SparkFunSuite { |
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.
Although this pr has modified the utils
module, looking at the test parameters -Phadoop-3 repl/test avro/test examples/test
, it did not execute the tests of the utils module, so it seems that the test of the utils module has not been actually verified on GA, put ArrayImplicitsSuite
in the core module for now.
The issue with the utils module test will be followed up separately.
Could you help review this pr if you have time. @dongjoon-hyun Thanks ~ |
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.
+1, LGTM. Thank you, @LuciferYang .
Merged to master. |
Thanks @dongjoon-hyun ~ |
What changes were proposed in this pull request?
Currently, we need to use
immutable.ArraySeq.unsafeWrapArray(array)
to wrap an Array into animmutable.ArraySeq
, which makes the code look bloated.So this PR introduces an implicit function
toImmutableArraySeq
to make it easier for Scala Array to be wrapped intoimmutable.ArraySeq
.After this pr, we can use the following way to wrap an array into an
immutable.ArraySeq
:At the same time, this pr replaces the existing use of
immutable.ArraySeq.unsafeWrapArray(array)
with the new method.On the other hand, this implicit function will be conducive to the progress of work SPARK-45686 and SPARK-45687.
Why are the changes needed?
Makes the code for wrapping a Scala Array into an
immutable.ArraySeq
look less bloated.Does this PR introduce any user-facing change?
No
How was this patch tested?
Pass GitHub Actions
Was this patch authored or co-authored using generative AI tooling?
No