zhengruifeng commented on a change in pull request #31480:
URL: https://github.com/apache/spark/pull/31480#discussion_r594806172



##########
File path: 
core/src/main/scala/org/apache/spark/util/collection/ExternalSorter.scala
##########
@@ -672,6 +672,22 @@ private[spark] class ExternalSorter[K, V, C](
     partitionedIterator.flatMap(pair => pair._2)
   }
 
+  /**
+   * Return an iterator over all the data written to this object, aggregated 
by our aggregator.
+   * On task completion (success, failure, or cancellation), it updates 
related task metrics,
+   * and releases resources by calling `stop()`.
+   */
+  def completionIterator: Iterator[Product2[K, C]] = {
+    context.taskMetrics().incMemoryBytesSpilled(memoryBytesSpilled)
+    context.taskMetrics().incDiskBytesSpilled(diskBytesSpilled)
+    context.taskMetrics().incPeakExecutionMemory(peakMemoryUsedBytes)

Review comment:
       I am ok to add `records` here, but perfer another method name 
'insertAllAndUpdateMetrics'




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to