vanzin commented on a change in pull request #25299: [SPARK-27651][Core] Avoid 
the network when shuffle blocks are fetched from the same host
URL: https://github.com/apache/spark/pull/25299#discussion_r308934633
 
 

 ##########
 File path: 
core/src/main/scala/org/apache/spark/shuffle/IndexShuffleBlockResolver.scala
 ##########
 @@ -51,12 +52,43 @@ private[spark] class IndexShuffleBlockResolver(
 
   private val transportConf = SparkTransportConf.fromSparkConf(conf, "shuffle")
 
-  def getDataFile(shuffleId: Int, mapId: Int): File = {
-    blockManager.diskBlockManager.getFile(ShuffleDataBlockId(shuffleId, mapId, 
NOOP_REDUCE_ID))
+
+  def getDataFile(shuffleId: Int, mapId: Int): File = getDataFile(shuffleId, 
mapId, None)
+
+  /**
+   * Get the shuffle data file.
+   *
+   * When the dirs param is None then the disk manager's local directories are 
used and this way
+   * local data files are read otherwise via the specified directories 
host-local blocks can be read
+   * (but this can be used only for reading as non-existing parent directory 
storing the data
+   * file won't be created this way).
+   */
+   def getDataFile(
+      shuffleId: Int,
+      mapId: Int,
+      dirs: Option[Array[String]]): File = {
+    val blockId = ShuffleDataBlockId(shuffleId, mapId, NOOP_REDUCE_ID)
+    dirs
+      .map(ExecutorDiskUtils.getFile(_, blockManager.subDirsPerLocalDir, 
blockId.name))
+      .getOrElse(blockManager.diskBlockManager.getFile(blockId))
   }
 
-  private def getIndexFile(shuffleId: Int, mapId: Int): File = {
-    blockManager.diskBlockManager.getFile(ShuffleIndexBlockId(shuffleId, 
mapId, NOOP_REDUCE_ID))
+  /**
+   * Get the shuffle index file.
+   *
+   * When the dirs param is None then the disk manager's local directories are 
used and this way
 
 Review comment:
   Same.

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


With regards,
Apache Git Services

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

Reply via email to