pan3793 commented on code in PR #45155:
URL: https://github.com/apache/spark/pull/45155#discussion_r1499117650


##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkExecuteStatementOperation.scala:
##########
@@ -116,7 +116,7 @@ private[hive] class SparkExecuteStatementOperation(
     val offset = iter.getPosition
     val rows = iter.take(maxRows).toList

Review Comment:
   the real matter is `toList` returns a `linked list` that
   
   > Performance
   > Time: List has O(1) prepend and head/tail access. Most other operations 
are O(n) on the number of elements in the list. This includes the index-based 
lookup of elements, length, append and reverse.
   
   The most simplified approach to address the performance issue is 
   ```patch
   -    val rows = iter.take(maxRows).toList
   +    val rows = iter.take(maxRows).IndexedSeq
   ```
   which reduces the time cost of `rows(i)` from O(n) to O(1)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to