Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/3735#discussion_r111995370
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/aggregate/DataSetAggFunction.scala
---
@@ -68,23 +72,16 @@ class DataSetAggFunction(
override def reduce(records: Iterable[Row], out: Collector[Row]): Unit =
{
// create accumulators
- var i = 0
- while (i < aggregates.length) {
- accumulators(i) = aggregates(i).createAccumulator()
- i += 1
- }
+ accumulators = function.createAccumulators()
val iterator = records.iterator()
while (iterator.hasNext) {
val record = iterator.next()
--- End diff --
we can make `record` a `var` and move its definition outside of the loop.
Then we can get rid of the `if (!iterator.hasNext)` check in the body of
the while loop and set the `output` fields after the loop has terminated.
---
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.
---