Github user lamuguo commented on a diff in the pull request:
https://github.com/apache/spark/pull/867#discussion_r13217802
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/Aggregate.scala ---
@@ -155,48 +155,60 @@ case class Aggregate(
}
} else {
child.execute().mapPartitions { iter =>
- val hashTable = new HashMap[Row, Array[AggregateFunction]]
- val groupingProjection = new
MutableProjection(groupingExpressions, childOutput)
-
- var currentRow: Row = null
- while (iter.hasNext) {
- currentRow = iter.next()
- val currentGroup = groupingProjection(currentRow)
- var currentBuffer = hashTable.get(currentGroup)
- if (currentBuffer == null) {
- currentBuffer = newAggregateBuffer()
- hashTable.put(currentGroup.copy(), currentBuffer)
+ val groupingProjection = new
+ MutableProjection(groupingExpressions, childOutput)
+ // TODO: Can't use "Array[AggregateFunction]" directly, due to
lack of
+ // "concat(AggregateFunction, AggregateFunction)". Should add
+ // AggregateFunction.update(agg: AggregateFunction) in the future.
+ def createCombiner(row: Row) = mergeValue(newAggregateBuffer(),
row)
+ def mergeValue(buffer: Array[AggregateFunction], row: Row) = {
+ for (i <- 0 to buffer.length - 1) {
--- End diff --
Done
---
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.
---