From e14c52c25f2d79051020622442f14f2615a0141b Mon Sep 17 00:00:00 2001 From: hfutatzhanghb Date: Mon, 19 Jun 2023 17:19:23 +0800 Subject: [PATCH] HDFS-17053. Optimize method BlockInfoStriped#findSlot to reduce time complexity. (#5757). Contributed by farmmamba. Signed-off-by: Ayush Saxena --- .../hadoop/hdfs/server/blockmanagement/BlockInfoStriped.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfoStriped.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfoStriped.java index 4b8d092935..e9c5324e79 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfoStriped.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfoStriped.java @@ -105,7 +105,8 @@ private void initIndices() { private int findSlot() { int i = getTotalBlockNum(); - for (; i < getCapacity(); i++) { + int capacity = getCapacity(); + for (; i < capacity; i++) { if (getStorageInfo(i) == null) { return i; }