You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Dongjoon Hyun (Jira)" <ji...@apache.org> on 2023/10/31 15:57:00 UTC
[jira] [Resolved] (SPARK-45737) Remove unnecessary `.toArray[InternalRow]` in `SparkPlan#executeTake` function.
[ https://issues.apache.org/jira/browse/SPARK-45737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dongjoon Hyun resolved SPARK-45737.
-----------------------------------
Fix Version/s: 4.0.0
Resolution: Fixed
Issue resolved by pull request 43599
[https://github.com/apache/spark/pull/43599]
> Remove unnecessary `.toArray[InternalRow]` in `SparkPlan#executeTake` function.
> -------------------------------------------------------------------------------
>
> Key: SPARK-45737
> URL: https://issues.apache.org/jira/browse/SPARK-45737
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 4.0.0
> Reporter: Yang Jie
> Assignee: Yang Jie
> Priority: Major
> Labels: pull-request-available
> Fix For: 4.0.0
>
>
> {code:java}
> if (takeFromEnd) {
> while (buf.length < n && i < res.length) {
> val rows = decodeUnsafeRows(res(i)._2)
> if (n - buf.length >= res(i)._1) {
> buf.prependAll(rows.toArray[InternalRow])
> } else {
> val dropUntil = res(i)._1 - (n - buf.length)
> // Same as Iterator.drop but this only takes a long.
> var j: Long = 0L
> while (j < dropUntil) { rows.next(); j += 1L}
> buf.prependAll(rows.toArray[InternalRow])
> }
> i += 1
> }
> } else {
> while (buf.length < n && i < res.length) {
> val rows = decodeUnsafeRows(res(i)._2)
> if (n - buf.length >= res(i)._1) {
> buf ++= rows.toArray[InternalRow]
> } else {
> buf ++= rows.take(n - buf.length).toArray[InternalRow]
> }
> i += 1
> }
> } {code}
> In the above code, the input parameters of `mutable.Buffer#prependAll` and `mutable.Growable#++=` functions are `IterableOnce`, and the type of rows is `Iterator[InternalRow]`, which inherits from `IterableOnce`, so there is no need to cast to an array of InternalRow anymore.
>
>
>
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org