flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fhueske <...@git.apache.org>
Subject [GitHub] flink pull request #3733: [FLINK-6091] [table] Implement and turn on retract...
Date Tue, 18 Apr 2017 22:50:10 GMT
Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3733#discussion_r112079294
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/aggregate/GroupAggProcessFunction.scala
---
    @@ -84,16 +109,38 @@ class GroupAggProcessFunction(
         }
     
         // Set aggregate result to the final output
    -    i = 0
    -    while (i < aggregates.length) {
    -      val index = groupings.length + i
    -      val accumulator = accumulators.getField(i).asInstanceOf[Accumulator]
    -      aggregates(i).accumulate(accumulator, input.getField(aggFields(i)(0)))
    -      output.setField(index, aggregates(i).getValue(accumulator))
    -      i += 1
    +    if (input.command == Command.Delete) {
    +      i = 0
    +      while (i < aggregates.length) {
    +        val index = groupings.length + i
    +        val accumulator = accumulators.getField(i).asInstanceOf[Accumulator]
    +        aggregates(i).retract(accumulator, input.getField(aggFields(i)(0)))
    +        output.setField(index, aggregates(i).getValue(accumulator))
    +        i += 1
    +      }
    +    } else {
    +      i = 0
    +      while (i < aggregates.length) {
    +        val index = groupings.length + i
    +        val accumulator = accumulators.getField(i).asInstanceOf[Accumulator]
    +        aggregates(i).accumulate(accumulator, input.getField(aggFields(i)(0)))
    +        output.setField(index, aggregates(i).getValue(accumulator))
    +        i += 1
    +      }
         }
    -    state.update(accumulators)
     
    +    // if previous is not null, do retraction process
    +    if (null != previous) {
    --- End diff --
    
    check against `generateRetraction`. The check can be optimized because `generateRetraction`is
a `val` and hence `final`.


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

Mime
View raw message