[ https://issues.apache.org/jira/browse/FLINK-7206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16134783#comment-16134783 ]
ASF GitHub Bot commented on FLINK-7206: --------------------------------------- Github user wuchong commented on a diff in the pull request: https://github.com/apache/flink/pull/4355#discussion_r134135181 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/AggregationCodeGenerator.scala --- @@ -162,13 +172,66 @@ class AggregationCodeGenerator( } } + def genDataViewFieldSetter(accTerm: String, specs: Seq[DataViewSpec[_]]): String = { + if (accConfig.isDefined && accConfig.get.isStateBackedDataViews) { + val setters = for (spec <- specs) yield { + val field = spec.field + val dataViewTerm = s"${accTerm}_${field.getName}_dataview" + val fieldSetter = if (Modifier.isPublic(field.getModifiers)) { + s"$accTerm.${field.getName} = $dataViewTerm;" + } else { + val fieldTerm = addReusablePrivateFieldAccess(field.getDeclaringClass, field.getName) + s"${reflectiveFieldWriteAccess(fieldTerm, field, accTerm, dataViewTerm)};" + } + + s""" + | $fieldSetter + """.stripMargin + } + setters.mkString("\n") + } else { + "" + } + } + + def genCleanUpDataView: String = { + if (accConfig.isDefined && accConfig.get.isStateBackedDataViews) { + val cleanUpDataViews = new StringBuilder + for (i <- aggs.indices) yield { + val setters = for (spec <- accConfig.get.accSpecs(i)) yield { + val dataViewTerm = s"acc${i}_${spec.field.getName}_dataview" + val cleanUp = + s""" + | $dataViewTerm.clear(); + """.stripMargin + cleanUpDataViews.append(cleanUp) + } + } + + cleanUpDataViews.toString() + } else { + "" + } + } + + def genInitialize: String = { + + j""" + | public final void initialize( --- End diff -- I would like to rename the method name to `open(ctx)`. So that we can use the `reusableOpenStatements` and `reuseOpenCode()` of `CodeGenerator` to generate the content of `open`. Currently, the `genInitialize` is somewhat ambiguous to `reuseInitCode()`. > Implementation of DataView to support state access for UDAGG > ------------------------------------------------------------ > > Key: FLINK-7206 > URL: https://issues.apache.org/jira/browse/FLINK-7206 > Project: Flink > Issue Type: Sub-task > Components: Table API & SQL > Reporter: Kaibo Zhou > Assignee: Kaibo Zhou > > Implementation of MapView and ListView to support state access for UDAGG. -- This message was sent by Atlassian JIRA (v6.4.14#64029)