Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/3735#discussion_r111986866 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala --- @@ -263,33 +263,56 @@ class CodeGenerator( aggFields: Array[Array[Int]], aggMapping: Array[Int], fwdMapping: Array[(Int, Int)], - outputArity: Int) + outputArity: Int, + groupingKeys: Array[Int]) : GeneratedAggregationsFunction = { def genSetAggregationResults( accTypes: Array[String], aggs: Array[String], aggMapping: Array[Int]): String = { - val sig: String = + val sigHelper: String = j""" - | public void setAggregationResults( - | org.apache.flink.types.Row accs, - | org.apache.flink.types.Row output)""".stripMargin + | private final void setAggregationResultsHelper( + | org.apache.flink.types.Row accs, + | org.apache.flink.types.Row output, + | java.lang.Integer offset)""".stripMargin - val setAggs: String = { + val setAggsHelper: String = { for (i <- aggs.indices) yield j""" | org.apache.flink.table.functions.AggregateFunction baseClass$i = | (org.apache.flink.table.functions.AggregateFunction) ${aggs(i)}; | | output.setField( - | ${aggMapping(i)}, + | ${aggMapping(i)} + offset, | baseClass$i.getValue((${accTypes(i)}) accs.getField($i)));""".stripMargin }.mkString("\n") - j"""$sig { - |$setAggs + val setAggregationResults: String = + j""" + | public void setAggregationResults( + | org.apache.flink.types.Row accs, + | org.apache.flink.types.Row output) { + | setAggregationResultsHelper(accs, output, 0); --- End diff -- Code generated methods should be as "flat" as possible. Calling other helper methods adds overhead compared to inlining the code.
--- 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. ---