Skip to content

Commit

Permalink
revert previous commit and add more comment
Browse files Browse the repository at this point in the history
  • Loading branch information
LantaoJin committed Aug 10, 2020
1 parent 612a6f1 commit 0e9c004
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ private[spark] class DiskBlockManager(conf: SparkConf, deleteFilesOnStop: Boolea

private val shutdownHook = addShutdownHook()

// This method should be kept in sync with
// org.apache.spark.network.shuffle.ExecutorDiskUtils#getFile().
private def getFile(localDirs: Array[File], subDirs: Array[Array[File]],
subDirsPerLocalDir: Int, filename: String): File = {
// Figure out which local directory it hashes to, and which subdirectory in that
Expand All @@ -96,12 +98,14 @@ private[spark] class DiskBlockManager(conf: SparkConf, deleteFilesOnStop: Boolea
new File(subDir, filename)
}

/** Looks up a file by hashing it into one of our local/container subdirectories. */
// This method should be kept in sync with
// org.apache.spark.network.shuffle.ExecutorDiskUtils#getFile().
def getFile(filename: String): File =
/**
* Used only for testing.
* We should invoke getFile(blockId: BlockId) in production code.
*/
private[spark] def getFile(filename: String): File =
getFile(localDirs, subDirs, subDirsPerLocalDir, filename)

/** Looks up a file by hashing it into one of our local/container subdirectories. */
def getFile(blockId: BlockId): File = {
if (containerDirEnabled && blockId.isTemp) {
getFile(containerDirs, subContainerDirs, subDirsPerLocalDir, blockId.name)
Expand All @@ -112,7 +116,7 @@ private[spark] class DiskBlockManager(conf: SparkConf, deleteFilesOnStop: Boolea

/** Check if disk block manager has a block. */
def containsBlock(blockId: BlockId): Boolean = {
getFile(blockId.name).exists()
getFile(blockId).exists()
}

/** List all the files currently stored on disk by the disk manager. */
Expand Down

0 comments on commit 0e9c004

Please sign in to comment.