Github user seyfe commented on a diff in the pull request:
https://github.com/apache/spark/pull/15032#discussion_r78266659
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/AggregationIterator.scala
---
@@ -181,11 +182,7 @@ abstract class AggregationIterator(
// Process all expression-based aggregate functions.
updateProjection.target(currentBuffer)(joinedRow(currentBuffer,
row))
// Process all imperative aggregate functions.
- var i = 0
- while (i < updateFunctions.length) {
- updateFunctions(i)(currentBuffer, row)
- i += 1
- }
+ updateFunctions.foreach(updateFunction =>
updateFunction(currentBuffer, row))
--- End diff --
Thanks for your input @HyukjinKwon! I avoided the zipWithIndex because of
that reason and kept the while loops unchanged. Just cached the length due to
specified reason.
However for the parts that we don't need the index, we can use foreach
method. It's not same as what is posted in [2].
The problem in [2] is `for (i <- Range) ` will be converted to
`Range.foreach`. However in this particular case, we don't create the Range
object and I don't think there is any virtual function calls. Please correct me
if I am wrong.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]