Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/15703#discussion_r88311961
--- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala
---
@@ -365,4 +380,66 @@ private[hive] case class HiveUDAFFunction(
val distinct = if (isDistinct) "DISTINCT " else " "
s"$name($distinct${children.map(_.sql).mkString(", ")})"
}
+
+ override def createAggregationBuffer(): AggregationBuffer =
+ partial1ModeEvaluator.getNewAggregationBuffer
+
+ @transient
+ private lazy val inputProjection = new InterpretedProjection(children)
+
+ override def update(buffer: AggregationBuffer, input: InternalRow): Unit
= {
+ partial1ModeEvaluator.iterate(
+ buffer, wrap(inputProjection(input), inputWrappers, cached,
inputDataTypes))
+ }
+
+ override def merge(buffer: AggregationBuffer, input: AggregationBuffer):
Unit = {
+ partial2ModeEvaluator.merge(buffer,
partial1ModeEvaluator.terminatePartial(input))
+ }
+
+ override def eval(buffer: AggregationBuffer): Any = {
+ resultUnwrapper(finalModeEvaluator.terminate(buffer))
+ }
+
+ override def serialize(buffer: AggregationBuffer): Array[Byte] = {
+ aggBufferSerDe.serialize(buffer)
+ }
+
+ override def deserialize(bytes: Array[Byte]): AggregationBuffer = {
+ aggBufferSerDe.deserialize(bytes)
+ }
+
+ // Helper class used to de/serialize Hive UDAF `AggregationBuffer`
objects
+ private class AggregationBufferSerDe {
--- End diff --
We can, but it doesn't seem to be necessary. Make it a nested class also
simplifies implementation since it has access to fields of the outer class.
---
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.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]