[
https://issues.apache.org/jira/browse/FLINK-5984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15899712#comment-15899712
]
Fabian Hueske commented on FLINK-5984:
--------------------------------------
Yes, I think that would be a good idea. Many function objects can make the
accumulators member variables and hold them across invocations. Instead of
creating a new in each function invocation, the member variables can be reused.
For the SumAggFunction it would look like this:
{code}
override def createAccumulator(reuse: Accumulator): Accumulator = {
val acc = if (reuse == null) {
new SumAccumulator[T]()
} else {
reuse
}
acc.f0 = numeric.zero //sum
acc.f1 = false
acc
}
{code}
> Allow reusing of accumulators in AggregateFunction
> --------------------------------------------------
>
> Key: FLINK-5984
> URL: https://issues.apache.org/jira/browse/FLINK-5984
> Project: Flink
> Issue Type: Improvement
> Components: Table API & SQL
> Reporter: Timo Walther
>
> Right now we have to create a new accumulator object if we just want to reset
> it. We should allow passing the old one as a {{reuse}} object to
> {{AggregateFunction#createAccumulator}}. The aggregate function then can
> decide if it wants to create a new object or reset the old one.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)