Skip to content

Commit 664dfb8

Browse files
committed
Modify the blockExists to val and resuse it below
1 parent 60ca9e0 commit 664dfb8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

core/src/main/scala/org/apache/spark/storage/BlockManagerMasterEndpoint.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,18 +497,17 @@ private[spark] class BlockManagerInfo(
497497

498498
updateLastSeenMs()
499499

500-
var blockExists = false
500+
val blockExists = _blocks.containsKey(blockId)
501501
var originalMemSize: Long = 0
502502
var originalDiskSize: Long = 0
503503
var originalLevel: StorageLevel = StorageLevel.NONE
504504

505-
if (_blocks.containsKey(blockId)) {
505+
if (blockExists) {
506506
// The block exists on the slave already.
507507
val blockStatus: BlockStatus = _blocks.get(blockId)
508508
originalLevel = blockStatus.storageLevel
509509
originalMemSize = blockStatus.memSize
510510
originalDiskSize = blockStatus.diskSize
511-
blockExists = true
512511

513512
if (originalLevel.useMemory) {
514513
_remainingMem += originalMemSize
@@ -534,7 +533,8 @@ private[spark] class BlockManagerInfo(
534533
s" free: ${Utils.bytesToString(_remainingMem)})")
535534
} else {
536535
logInfo(s"Added $blockId in memory on ${blockManagerId.hostPort}" +
537-
s" (size: ${Utils.bytesToString(memSize)}, free: ${Utils.bytesToString(_remainingMem)})")
536+
s" (size: ${Utils.bytesToString(memSize)}," +
537+
s" free: ${Utils.bytesToString(_remainingMem)})")
538538
}
539539
}
540540
if (storageLevel.useDisk) {
@@ -558,7 +558,8 @@ private[spark] class BlockManagerInfo(
558558
_cachedBlocks -= blockId
559559
if (originalLevel.useMemory) {
560560
logInfo(s"Removed $blockId on ${blockManagerId.hostPort} in memory" +
561-
s" (size: ${Utils.bytesToString(originalMemSize)}, free: ${Utils.bytesToString(_remainingMem)})")
561+
s" (size: ${Utils.bytesToString(originalMemSize)}," +
562+
s" free: ${Utils.bytesToString(_remainingMem)})")
562563
}
563564
if (originalLevel.useDisk) {
564565
logInfo(s"Removed $blockId on ${blockManagerId.hostPort} on disk" +

0 commit comments

Comments
 (0)