Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/3423#discussion_r103474797
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/aggregate/DataSetSessionWindowAggregateCombineGroupFunction.scala
---
@@ -79,44 +85,60 @@ class DataSetSessionWindowAggregateCombineGroupFunction(
// calculate the current window and open a new window.
if (windowEnd != null) {
// emit the current window's merged data
- doCollect(out, windowStart, windowEnd)
+ doCollect(out, accumulatorList, windowStart, windowEnd)
+
+ // clear the accumulator list for all aggregate
+ for (i <- aggregates.indices) {
+ accumulatorList(i).clear()
+ }
} else {
// set group keys to aggregateBuffer.
for (i <- groupingKeys.indices) {
aggregateBuffer.setField(i, record.getField(i))
}
}
- // initiate intermediate aggregate value.
- aggregates.foreach(_.initiate(aggregateBuffer))
windowStart = record.getField(rowTimeFieldPos).asInstanceOf[Long]
}
- // merge intermediate aggregate value to the buffered value.
- aggregates.foreach(_.merge(record, aggregateBuffer))
+ // collect the accumulators for each aggregate
+ for (i <- aggregates.indices) {
--- End diff --
We cannot collect all accumulator and need to merge pairwise.
I think it would be good to remove the preparation mapper and use
`accumulate()` here but, this would result in even more significant code
changes.
---
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.
---