Github user shaoxuan-wang commented on a diff in the pull request:
https://github.com/apache/flink/pull/3470#discussion_r104413666
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/aggfunctions/MaxAggFunctionWithRetract.scala
---
@@ -115,12 +112,28 @@ abstract class MaxWithRetractAggFunction[T](implicit
ord: Ordering[T]) extends A
}
override def merge(accumulators: JList[Accumulator]): Accumulator = {
- val ret = accumulators.get(0)
+ val ret =
accumulators.get(0).asInstanceOf[MaxWithRetractAccumulator[T]]
var i: Int = 1
while (i < accumulators.size()) {
val a =
accumulators.get(i).asInstanceOf[MaxWithRetractAccumulator[T]]
if (a.f1 != 0) {
- accumulate(ret.asInstanceOf[MaxWithRetractAccumulator[T]], a.f0)
+ val iterator = a.f2.keySet().iterator()
+ while (iterator.hasNext()) {
+ val key = iterator.next()
+ //updating the resulting max value if needed
+ if (ord.compare(ret.f0, key) < 0) {
--- End diff --
Yes, it is not necessary to compare the max for all hash keys.
---
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.
---