Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3470#discussion_r104392189
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/aggfunctions/MinAggFunctionWithRetract.scala
 ---
    @@ -72,37 +72,34 @@ abstract class MinWithRetractAggFunction[T](implicit 
ord: Ordering[T]) extends A
     
           a.f1 -= 1L
     
    -      if (!a.f2.containsKey(v)) {
    -        throw TableException("unexpected retract message")
    -      } else {
    -        var count = a.f2.get(v)
    -        count -= 1L
    -        if (count == 0) {
    -          //remove the key v from the map if the number of appearance of 
the value v is 0
    -          a.f2.remove(v)
    -          //if the total count is 0, we could just simply set the f0(min) 
to the initial value
    -          if (a.f1 == 0) {
    -            a.f0 = getInitValue
    -            return
    -          }
    -          //if v is the current min value, we have to iterate the map to 
find the 2nd smallest
    -          // value to replace v as the min value
    -          if (v == a.f0) {
    -            val iterator = a.f2.keySet().iterator()
    -            var key = iterator.next()
    -            a.f0 = key
    -            while (iterator.hasNext()) {
    -              key = iterator.next()
    -              if (ord.compare(a.f0, key) > 0) {
    -                a.f0 = key
    -              }
    +      var count = a.f2.get(v)
    +      count -= 1L
    +      if (count == 0) {
    +        //remove the key v from the map if the number of appearance of the 
value v is 0
    +        a.f2.remove(v)
    +        //if the total count is 0, we could just simply set the f0(min) to 
the initial value
    +        if (a.f1 == 0) {
    --- End diff --
    
    remove `a.f1` from accumulator?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to