HDFS-9221. HdfsServerConstants#ReplicaState#getState should avoid calling values() since it creates a temporary array. (Staffan Friberg via yliu)
This commit is contained in:
parent
28edc7b129
commit
5e2a44a7fe
|
@ -682,6 +682,9 @@ Release 2.8.0 - UNRELEASED
|
|||
HDFS-9110. Use Files.walkFileTree in NNUpgradeUtil#doPreUpgrade for
|
||||
better efficiency. (Charlie Helin via wang)
|
||||
|
||||
HDFS-9221. HdfsServerConstants#ReplicaState#getState should avoid calling
|
||||
values() since it creates a temporary array. (Staffan Friberg via yliu)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
||||
|
|
|
@ -292,6 +292,8 @@ public interface HdfsServerConstants {
|
|||
/** Temporary replica: created for replication and relocation only. */
|
||||
TEMPORARY(4);
|
||||
|
||||
private static final ReplicaState[] cachedValues = ReplicaState.values();
|
||||
|
||||
private final int value;
|
||||
|
||||
ReplicaState(int v) {
|
||||
|
@ -303,12 +305,12 @@ public interface HdfsServerConstants {
|
|||
}
|
||||
|
||||
public static ReplicaState getState(int v) {
|
||||
return ReplicaState.values()[v];
|
||||
return cachedValues[v];
|
||||
}
|
||||
|
||||
/** Read from in */
|
||||
public static ReplicaState read(DataInput in) throws IOException {
|
||||
return values()[in.readByte()];
|
||||
return cachedValues[in.readByte()];
|
||||
}
|
||||
|
||||
/** Write to out */
|
||||
|
|
Loading…
Reference in New Issue