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

    https://github.com/apache/spark/pull/8038#discussion_r36562104
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/TungstenAggregate.scala
 ---
    @@ -61,32 +62,54 @@ case class TungstenAggregate(
       }
     
       protected override def doExecute(): RDD[InternalRow] = attachTree(this, 
"execute") {
    -    child.execute().mapPartitions { iter =>
    -      val hasInput = iter.hasNext
    -      if (!hasInput && groupingExpressions.nonEmpty) {
    -        // This is a grouped aggregate and the input iterator is empty,
    -        // so return an empty iterator.
    -        Iterator.empty.asInstanceOf[Iterator[UnsafeRow]]
    -      } else {
    -        val aggregationIterator =
    -          new TungstenAggregationIterator(
    -            groupingExpressions,
    -            nonCompleteAggregateExpressions,
    -            completeAggregateExpressions,
    -            initialInputBufferOffset,
    -            resultExpressions,
    -            newMutableProjection,
    -            child.output,
    -            iter.asInstanceOf[Iterator[UnsafeRow]],
    -            testFallbackStartsAt)
     
    -        if (!hasInput && groupingExpressions.isEmpty) {
    +    /**
    +     * Set up the underlying unsafe data structures used before computing 
the parent partition.
    +     * This makes sure our iterator is not starved by other operators in 
the same task.
    +     */
    +    def preparePartition(): TungstenAggregationIterator = {
    +      new TungstenAggregationIterator(
    +        groupingExpressions,
    +        nonCompleteAggregateExpressions,
    +        completeAggregateExpressions,
    +        initialInputBufferOffset,
    +        resultExpressions,
    +        newMutableProjection,
    +        child.output,
    +        testFallbackStartsAt)
    --- End diff --
    
    What will happen if there is no memory space left to reserve?


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