spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] ChenjunZou commented on a change in pull request #23083: [SPARK-26114][CORE] ExternalSorter's readingIterator field leak
Date Sun, 11 Aug 2019 04:40:13 GMT
ChenjunZou commented on a change in pull request #23083: [SPARK-26114][CORE] ExternalSorter's
readingIterator field leak
URL: https://github.com/apache/spark/pull/23083#discussion_r312722564
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/util/CompletionIterator.scala
 ##########
 @@ -25,11 +25,14 @@ private[spark]
 abstract class CompletionIterator[ +A, +I <: Iterator[A]](sub: I) extends Iterator[A]
{
 
   private[this] var completed = false
-  def next(): A = sub.next()
+  private[this] var iter = sub
+  def next(): A = iter.next()
   def hasNext: Boolean = {
-    val r = sub.hasNext
+    val r = iter.hasNext
     if (!r && !completed) {
       completed = true
+      // reassign to release resources of highly resource consuming iterators early
+      iter = Iterator.empty.asInstanceOf[I]
 
 Review comment:
   @szhem 
   hi,
   In your comment:
    " reassign the reference of its sub-iterator to the empty iterator ..."
   
   I don't understand why reassigning iter would take effect on original sub-iterator
   can you explain it more?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message