فهرست منبع

HDFS-17053. Optimize method BlockInfoStriped#findSlot to reduce time complexity. (#5757). Contributed by farmmamba.

Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
hfutatzhanghb 1 سال پیش
والد
کامیت
e14c52c25f

+ 2 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfoStriped.java

@@ -105,7 +105,8 @@ public class BlockInfoStriped extends BlockInfo {
 
 
   private int findSlot() {
   private int findSlot() {
     int i = getTotalBlockNum();
     int i = getTotalBlockNum();
-    for (; i < getCapacity(); i++) {
+    int capacity = getCapacity();
+    for (; i < capacity; i++) {
       if (getStorageInfo(i) == null) {
       if (getStorageInfo(i) == null) {
         return i;
         return i;
       }
       }