yaooqinn commented on a change in pull request #33063:
URL: https://github.com/apache/spark/pull/33063#discussion_r658570541



##########
File path: 
core/src/main/scala/org/apache/spark/storage/ShuffleBlockFetcherIterator.scala
##########
@@ -433,28 +436,25 @@ final class ShuffleBlockFetcherIterator(
       address: BlockManagerId,
       blockInfos: Seq[(BlockId, Long, Int)],
       collectedRemoteRequests: ArrayBuffer[FetchRequest]): Unit = {
-    val iterator = blockInfos.iterator
     var curRequestSize = 0L
-    var curBlocks = Seq.empty[FetchBlockInfo]
+    val curBlocks = new ArrayBuffer[FetchBlockInfo]()
 
-    while (iterator.hasNext) {
-      val (blockId, size, mapIndex) = iterator.next()
+    for ((blockId, size, mapIndex) <- blockInfos) {
       assertPositiveBlockSize(blockId, size)
-      curBlocks = curBlocks ++ Seq(FetchBlockInfo(blockId, size, mapIndex))
+      curBlocks += FetchBlockInfo(blockId, size, mapIndex)
       curRequestSize += size
       // For batch fetch, the actual block in flight should count for merged 
block.
       val mayExceedsMaxBlocks = !doBatchFetch && curBlocks.size >= 
maxBlocksInFlightPerAddress
       if (curRequestSize >= targetRemoteRequestSize || mayExceedsMaxBlocks) {
-        curBlocks = createFetchRequests(curBlocks, address, isLast = false,
-          collectedRemoteRequests)
+        val rest = createFetchRequests(curBlocks, address, isLast = false, 
collectedRemoteRequests)
+        curBlocks.clear()
+        curBlocks ++= rest

Review comment:
       If you insist, I can revert the last commit 
https://github.com/apache/spark/pull/33063/commits/f8942209f2a00ef32940cd2805474c117fd89d5e.
 I do not have a strong opinion on it.




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