JingsongLi commented on a change in pull request #8001: 
[FLINK-11949][table-planner-blink] Introduce DeclarativeAggregateFunction and 
AggsHandlerCodeGenerator to blink planner
URL: https://github.com/apache/flink/pull/8001#discussion_r267166984
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/codegen/agg/ImperativeAggCodeGen.scala
 ##########
 @@ -0,0 +1,502 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.flink.table.codegen.agg
+
+import org.apache.flink.api.common.typeinfo.TypeInformation
+import org.apache.flink.runtime.util.SingleElementIterator
+import 
org.apache.flink.table.`type`.TypeConverters.createInternalTypeFromTypeInfo
+import org.apache.flink.table.`type`.{InternalType, RowType, TypeUtils}
+import org.apache.flink.table.codegen.CodeGenUtils._
+import org.apache.flink.table.codegen.GenerateUtils.generateFieldAccess
+import 
org.apache.flink.table.codegen.agg.AggsHandlerCodeGenerator.{CONTEXT_TERM, 
CURRENT_KEY, DISTINCT_KEY_TERM, NAMESPACE_TERM, addReusableStateDataViews, 
createDataViewBackupTerm, createDataViewTerm}
+import org.apache.flink.table.codegen.{CodeGenException, CodeGeneratorContext, 
ExprCodeGenerator, GeneratedExpression}
+import org.apache.flink.table.dataformat.{GenericRow, UpdatableRow}
+import org.apache.flink.table.dataview.DataViewSpec
+import org.apache.flink.table.expressions.{Expression, 
ResolvedAggInputReference, ResolvedDistinctKeyReference, 
RexNodeGenExpressionVisitor}
+import org.apache.flink.table.functions.AggregateFunction
+import 
org.apache.flink.table.functions.utils.UserDefinedFunctionUtils.{getAggFunctionUDIMethod,
 getAggUserDefinedInputTypes, getUserDefinedMethod, internalTypesToClasses, 
signatureToString}
+import org.apache.flink.table.plan.util.AggregateInfo
+import org.apache.flink.table.typeutils.BaseRowTypeInfo
+
+import org.apache.calcite.tools.RelBuilder
+
+import java.lang.reflect.ParameterizedType
+import java.lang.{Iterable => JIterable}
+
+import scala.collection.mutable.ArrayBuffer
+
+/**
+  * It is for code generate aggregation functions that are specified in terms 
of
+  * accumulate(), retract() and merge() functions. The aggregate accumulator is
+  * embedded inside of a larger shared aggregation buffer.
+  *
+  * @param ctx the code gen context
+  * @param aggInfo  the aggregate information
+  * @param filterExpression filter argument access expression, none if no 
filter
+  * @param mergedAccOffset the mergedAcc may come from local aggregate,
+  *                        this is the first buffer offset in the row
+  * @param aggBufferOffset  the offset in the buffers of this aggregate
+  * @param aggBufferSize  the total size of aggregate buffers
+  * @param inputTypes   the input field type infos
+  * @param constantExprs  the constant expressions
+  * @param relBuilder  the rel builder to translate expressions to calcite rex 
nodes
+  * @param hasNamespace  whether the accumulators state has namespace
+  * @param inputFieldCopy    copy input field element if true (only mutable 
type will be copied)
+  */
+class ImperativeAggCodeGen(
+    ctx: CodeGeneratorContext,
+    aggInfo: AggregateInfo,
+    filterExpression: Option[Expression],
+    mergedAccOffset: Int,
+    aggBufferOffset: Int,
+    aggBufferSize: Int,
+    inputTypes: Seq[InternalType],
+    constantExprs: Seq[GeneratedExpression],
+    relBuilder: RelBuilder,
+    hasNamespace: Boolean,
+    mergedAccOnHeap: Boolean,
+    mergedAccExternalType: TypeInformation[_],
+    inputFieldCopy: Boolean)
+  extends AggCodeGen {
+
+  private val SINGLE_ITERABLE = className[SingleElementIterator[_]]
 
 Review comment:
   First table-blink has own `SingleElementIterator ` too.
   created JIRA to fix it: https://issues.apache.org/jira/browse/FLINK-11968

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to