[ 
https://issues.apache.org/jira/browse/SPARK-45737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot reassigned SPARK-45737:
--------------------------------------

    Assignee:     (was: Apache Spark)

> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to