HDFS-9350. Avoid creating temprorary strings in Block.toString() and getBlockName() (Staffan Friberg via cmccabe)

(cherry picked from commit e63388fdf2)
This commit is contained in:
Colin Patrick Mccabe 2015-12-18 09:40:39 -08:00
parent 71fb205735
commit 31d2fb91fc
2 changed files with 8 additions and 2 deletions

View File

@ -132,7 +132,8 @@ public class Block implements Writable, Comparable<Block> {
/** /**
*/ */
public String getBlockName() { public String getBlockName() {
return BLOCK_FILE_PREFIX + String.valueOf(blockId); return new StringBuilder().append(BLOCK_FILE_PREFIX)
.append(blockId).toString();
} }
/** /**
@ -160,7 +161,9 @@ public class Block implements Writable, Comparable<Block> {
* @return the string representation of the block * @return the string representation of the block
*/ */
public static String toString(final Block b) { public static String toString(final Block b) {
return b.getBlockName() + "_" + b.getGenerationStamp(); StringBuilder sb = new StringBuilder();
b.appendStringTo(sb);
return sb.toString();
} }
/** /**

View File

@ -34,6 +34,9 @@ Release 2.9.0 - UNRELEASED
HDFS-8477. describe dfs.ha.zkfc.port in hdfs-default.xml. HDFS-8477. describe dfs.ha.zkfc.port in hdfs-default.xml.
(Kanaka Kumar Avvaru via wang) (Kanaka Kumar Avvaru via wang)
HDFS-9350. Avoid creating temprorary strings in Block.toString() and
getBlockName() (Staffan Friberg via cmccabe)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES