You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2023/10/31 08:55:00 UTC

[jira] [Updated] (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 ]

ASF GitHub Bot updated SPARK-45737:
-----------------------------------
    Labels: pull-request-available  (was: )

> 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
>            Priority: Major
>              Labels: pull-request-available
>
> {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