Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/3694#discussion_r111814395
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
---
@@ -396,13 +396,68 @@ class CodeGenerator(
| }""".stripMargin
}
- def generateCreateOutputRow(outputArity: Int): String = {
+ def genCreateOutputRow(outputArity: Int): String = {
j"""
| public org.apache.flink.types.Row createOutputRow() {
| return new org.apache.flink.types.Row($outputArity);
| }""".stripMargin
}
+ def genMergeAccumulatorsPair(
+ accTypes: Array[String],
+ aggs: Array[String]): String = {
+
+ val sig: String =
+ j"""
+ | public org.apache.flink.types.Row mergeAccumulatorsPair(
+ | org.apache.flink.types.Row a,
+ | org.apache.flink.types.Row b)
+ """.stripMargin
+ val merge: String = {
+ for (i <- aggs.indices) yield
+ j"""
+ | ${accTypes(i)} aAcc$i = (${accTypes(i)}) a.getField($i);
+ | ${accTypes(i)} bAcc$i = (${accTypes(i)}) b.getField($i);
+ | accList$i.set(0, aAcc$i);
+ | accList$i.set(1, bAcc$i);
+ | a.setField(
+ | $i,
+ | ${aggs(i)}.merge(accList$i));
+ """.stripMargin
+ }.mkString("\n")
+ val ret: String =
+ j"""
+ | return a;
+ """.stripMargin
+
+ j"""$sig {
+ |$merge
+ |$ret
+ | }""".stripMargin
+ }
+
+ def genMergeList(accTypes: Array[String]): String = {
+ {
+ for (i <- accTypes.indices) yield
+ j"""
+ | java.util.ArrayList<${accTypes(i)}> accList$i;
+ """.stripMargin
+ }.mkString("\n")
+ }
+
+ def initMergeList(
+ accTypes: Array[String],
+ aggs: Array[String]): String = {
+ {
+ for (i <- accTypes.indices) yield
+ j"""
+ | accList$i = new java.util.ArrayList<${accTypes(i)}>();
--- End diff --
create with initial capacity 2 `new
java.util.ArrayList<${accTypes(i)}>(2);`?
---
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.
---