Github user andrewor14 commented on a diff in the pull request: https://github.com/apache/spark/pull/5178#discussion_r27159008 --- Diff: core/src/main/scala/org/apache/spark/storage/DiskBlockManager.scala --- @@ -81,7 +89,38 @@ private[spark] class DiskBlockManager(blockManager: BlockManager, conf: SparkCon new File(subDir, filename) } - def getFile(blockId: BlockId): File = getFile(blockId.name) + /** Looks up a file by blockManagerId */ + // This method should be kept in sync with + // org.apache.spark.network.shuffle.StandaloneShuffleBlockManager#getFile(). + def getFile(filename: String, blockManagerId: BlockManagerId): File = { + // Figure out which local directory it hashes to, and which subdirectory in that + val hash = Utils.nonNegativeHash(filename) + + var localDirsPath = localDirsByBlkMgr.get(blockManagerId) + if(!localDirsPath.isDefined) { + localDirsPath = localDirsByBlkMgr.synchronized { + val old = localDirsByBlkMgr.get(blockManagerId) + if(old.isDefined) { + old + } else { + localDirsByBlkMgr ++= blockManager.master.getLocalDirsPath(blockManager.blockManagerId) + localDirsByBlkMgr.get(blockManagerId) + } + } + } + + val dirId = hash % localDirsPath.get.length + val subDirId = (hash / localDirsPath.get.length) % subDirsPerLocalDir + + new File(localDirsPath.get(dirId) + "/" + "%02x".format(subDirId), filename) + } + + def getFile(blockId: BlockId, blockManagerId: BlockManagerId = blockManager.blockManagerId): File = { + if(blockManagerId == blockManager.blockManagerId) + getFile(blockId.name) + else + getFile(blockId.name, blockManagerId) --- End diff -- style: ``` if (...) { getFile(...) } else { getFile(...) } ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org