From 9d5bc0aaf4f8fbe5146fbd2fb46fd648b292c8e8 Mon Sep 17 00:00:00 2001 From: "terence.yoo" Date: Tue, 19 Nov 2024 13:29:32 +0900 Subject: [PATCH] remove unused codes --- .../hadoop/io/ElasticByteBufferPool.java | 46 ------------------- 1 file changed, 46 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ElasticByteBufferPool.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ElasticByteBufferPool.java index 7f7c614205373..6addcd9f62642 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ElasticByteBufferPool.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ElasticByteBufferPool.java @@ -20,10 +20,6 @@ import org.apache.hadoop.thirdparty.com.google.common.collect.ComparisonChain; import org.apache.commons.lang3.builder.HashCodeBuilder; -import java.nio.ByteBuffer; -import java.util.Map; -import java.util.TreeMap; - import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; @@ -76,48 +72,6 @@ public int hashCode() { } } - private final TreeMap buffers = - new TreeMap(); - - private final TreeMap directBuffers = - new TreeMap(); - - private final TreeMap getBufferTree(boolean direct) { - return direct ? directBuffers : buffers; - } - - @Override - public synchronized ByteBuffer getBuffer(boolean direct, int length) { - TreeMap tree = getBufferTree(direct); - Map.Entry entry = - tree.ceilingEntry(new Key(length, 0)); - if (entry == null) { - return direct ? ByteBuffer.allocateDirect(length) : - ByteBuffer.allocate(length); - } - tree.remove(entry.getKey()); - entry.getValue().clear(); - return entry.getValue(); - } - - @Override - public synchronized void putBuffer(ByteBuffer buffer) { - buffer.clear(); - TreeMap tree = getBufferTree(buffer.isDirect()); - while (true) { - Key key = new Key(buffer.capacity(), System.nanoTime()); - if (!tree.containsKey(key)) { - tree.put(key, buffer); - return; - } - // Buffers are indexed by (capacity, time). - // If our key is not unique on the first try, we try again, since the - // time will be different. Since we use nanoseconds, it's pretty - // unlikely that we'll loop even once, unless the system clock has a - // poor granularity. - } - } - /** * Get the size of the buffer pool, for the specified buffer type. *