Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1822#discussion_r16196737
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/Aggregate.scala ---
    @@ -123,34 +124,73 @@ case class Aggregate(
         }
       }
     
    -  override def execute() = attachTree(this, "execute") {
    -    if (groupingExpressions.isEmpty) {
    -      child.execute().mapPartitions { iter =>
    -        val buffer = newAggregateBuffer()
    -        var currentRow: Row = null
    -        while (iter.hasNext) {
    -          currentRow = iter.next()
    -          var i = 0
    -          while (i < buffer.length) {
    -            buffer(i).update(currentRow)
    -            i += 1
    -          }
    -        }
    -        val resultProjection = new 
InterpretedProjection(resultExpressions, computedSchema)
    -        val aggregateResults = new 
GenericMutableRow(computedAggregates.length)
    -
    +  def aggregateNoGrouping() = {
    +    child.execute().mapPartitions { iter =>
    +      val buffer = newAggregateBuffer()
    +      var currentRow: Row = null
    +      while (iter.hasNext) {
    +        currentRow = iter.next()
             var i = 0
             while (i < buffer.length) {
    -          aggregateResults(i) = buffer(i).eval(EmptyRow)
    +          buffer(i).update(currentRow)
               i += 1
             }
    +      }
    +      val resultProjection = new InterpretedProjection(resultExpressions, 
computedSchema)
    +      val aggregateResults = new 
GenericMutableRow(computedAggregates.length)
     
    -        Iterator(resultProjection(aggregateResults))
    +      var i = 0
    +      while (i < buffer.length) {
    +        aggregateResults(i) = buffer(i).eval(EmptyRow)
    +        i += 1
           }
    +
    +      Iterator(resultProjection(aggregateResults))
    +    }
    +  }
    +
    +  def resultRow(iter: Iterator[(Row,Array[AggregateFunction])]) = {
    --- End diff --
    
    Can you add some scala doc to explain whats going on here?


---
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]

Reply via email to