You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Josh Rosen (Jira)" <ji...@apache.org> on 2020/01/03 07:23:00 UTC
[jira] [Created] (SPARK-30413) Avoid unnecessary WrappedArray
roundtrip in GenericArrayData constructor
Josh Rosen created SPARK-30413:
----------------------------------
Summary: Avoid unnecessary WrappedArray roundtrip in GenericArrayData constructor
Key: SPARK-30413
URL: https://issues.apache.org/jira/browse/SPARK-30413
Project: Spark
Issue Type: Improvement
Components: SQL
Affects Versions: 3.0.0
Reporter: Josh Rosen
Assignee: Josh Rosen
GenericArrayData has a constructor which accepts a {{seqOrArray: Any}} parameter. This constructor was originally added for use in situations where we don't know the actual type at compile-time (e.g. when converting UDF outputs). It's also called (perhaps unintentionally) in code paths where we could plausibly and statically know that the type is {{Array[Any]}} (in which case we could simply call the primary constructor).
In the current version of this code there's an unnecessary performance penalty for going through this path when {{seqOrArray}} is an {{Array[Any]}}: we end up converting the array into a WrappedArray, then call a method to unwrap it back into an array: this results in a bunch of unnecessary method calls. See https://scastie.scala-lang.org/7jOHydbNTaGSU677FWA8nA for an example of situations where this can crop up.
Via a small modification to this constructor's implementation, I think we can effectively remove this penalty.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org