wankunde commented on code in PR #45661:
URL: https://github.com/apache/spark/pull/45661#discussion_r1535864859


##########
core/src/main/java/org/apache/spark/shuffle/sort/UnsafeShuffleWriter.java:
##########
@@ -219,7 +221,15 @@ void closeAndWriteOutput() throws IOException {
     updatePeakMemoryUsed();
     serBuffer = null;
     serOutputStream = null;
-    final SpillInfo[] spills = sorter.closeAndGetSpills();
+    Optional<File> finalDataFileDir;
+    if (shuffleExecutorComponents instanceof 
LocalDiskShuffleExecutorComponents) {
+      File dataFile =
+        new IndexShuffleBlockResolver(sparkConf, 
blockManager).getDataFile(shuffleId, mapId);

Review Comment:
   Yes



##########
core/src/main/scala/org/apache/spark/storage/DiskBlockManager.scala:
##########
@@ -226,6 +226,24 @@ private[spark] class DiskBlockManager(
     (blockId, getFile(blockId))
   }
 
+  /** Produces a unique block id and File suitable for storing shuffled 
intermediate results
+   * in the input directory. */
+  def createTempShuffleBlockInDir(fileDir: File): (TempShuffleBlockId, File) = 
{
+    var blockId = TempShuffleBlockId(UUID.randomUUID())
+    var tmpFile = new File(fileDir, blockId.name)
+    while (tmpFile.exists()) {
+      blockId = TempShuffleBlockId(UUID.randomUUID())
+      tmpFile = new File(fileDir, blockId.name)

Review Comment:
   Added UT, if `fileDir` is invalid, tmpFile will not exists, exit this loop.
   Generate new block only when the `fileDir` is valid and the first 
`TempShuffleBlockId` file already created by some other task.



##########
core/src/main/scala/org/apache/spark/storage/DiskBlockManager.scala:
##########
@@ -226,6 +226,24 @@ private[spark] class DiskBlockManager(
     (blockId, getFile(blockId))
   }
 
+  /** Produces a unique block id and File suitable for storing shuffled 
intermediate results
+   * in the input directory. */

Review Comment:
   Fixed



##########
core/src/main/java/org/apache/spark/shuffle/sort/UnsafeShuffleWriter.java:
##########
@@ -219,7 +221,15 @@ void closeAndWriteOutput() throws IOException {
     updatePeakMemoryUsed();
     serBuffer = null;
     serOutputStream = null;
-    final SpillInfo[] spills = sorter.closeAndGetSpills();
+    Optional<File> finalDataFileDir;
+    if (shuffleExecutorComponents instanceof 
LocalDiskShuffleExecutorComponents) {

Review Comment:
   Sorry, I'm not familiar with the block storage in 
KubernetesLocalDiskShuffleExecutorComponents, so only handle 
LocalDiskShuffleExecutorComponents here.
   
   Or should I add a new method `getDataFile()` in trait 
`ShuffleExecutorComponents` ?



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

To unsubscribe, e-mail: [email protected]

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