Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,18 @@ private[spark] class BlockManagerInfo(
blockStatus = BlockStatus(storageLevel, memSize = memSize, diskSize = 0)
_blocks.put(blockId, blockStatus)
_remainingMem -= memSize
logInfo("Added %s in memory on %s (size: %s, free: %s)".format(
blockId, blockManagerId.hostPort, Utils.bytesToString(memSize),
val originalMemSize = if (_blocks.containsKey(blockId)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, it's not a Scala Map or else this could be .getOrElse(..., 0). Now I understand why you pulled out the variable earlier. I actually dont' think this works now because it happens after the new status has been put in the Map. OK, you could go back to what you had.

_blocks.get(blockId).memSize
} else {
0
}
val (addedOrRemoved, size) = if (memSize >= originalMemSize) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference doesn't need to be conditional. You can use math.abs

("Added", memSize - originalMemSize)
} else {
("Removed", originalMemSize - memSize)
}
logInfo("%s %s in memory on %s (size: %s, free: %s)".format(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still doesn't use interpolation

addedOrRemoved, blockId, blockManagerId.hostPort, Utils.bytesToString(size),
Utils.bytesToString(_remainingMem)))
}
if (storageLevel.useDisk) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the disk case need a similar treatment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I have modified the disk case, and add a "update" style log info, any other suggestions? thank you

Expand Down