[
https://issues.apache.org/jira/browse/FLINK-6242?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15972905#comment-15972905
]
ASF GitHub Bot commented on FLINK-6242:
---------------------------------------
Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/3735#discussion_r111983678
--- 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()
+ var i = 0
// accumulate
- i = 0
- while (i < aggregates.length) {
- aggregates(i).accumulate(accumulators(i),
record.getField(aggInFields(i)(0)))
- i += 1
- }
+ function.accumulate(accumulators, record)
// check if this record is the last record
if (!iterator.hasNext) {
--- End diff --
Couldn't we use `function.setForwardFields()` to forward the grouping keys
to the output?
> codeGen DataSet Goupingwindow Aggregates
> ----------------------------------------
>
> Key: FLINK-6242
> URL: https://issues.apache.org/jira/browse/FLINK-6242
> Project: Flink
> Issue Type: Sub-task
> Components: Table API & SQL
> Reporter: Shaoxuan Wang
> Assignee: Shaoxuan Wang
>
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)