hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anoopsamj...@apache.org
Subject svn commit: r1570671 - /hbase/branches/0.98/hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/LRUDictionary.java
Date Fri, 21 Feb 2014 19:12:27 GMT
Author: anoopsamjohn
Date: Fri Feb 21 19:12:27 2014
New Revision: 1570671

URL: http://svn.apache.org/r1570671
Log:
HBASE-10585 Avoid early creation of Node objects in LRUDictionary.BidirectionalLRUMap.(Anoop)

Modified:
    hbase/branches/0.98/hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/LRUDictionary.java

Modified: hbase/branches/0.98/hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/LRUDictionary.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/LRUDictionary.java?rev=1570671&r1=1570670&r2=1570671&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/LRUDictionary.java
(original)
+++ hbase/branches/0.98/hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/LRUDictionary.java
Fri Feb 21 19:12:27 2014
@@ -87,9 +87,6 @@ public class LRUDictionary implements Di
     public BidirectionalLRUMap(int initialSize) {
       initSize = initialSize;
       indexToNode = new Node[initialSize];
-      for (int i = 0; i < initialSize; i++) {
-        indexToNode[i] = new Node();
-      }
     }
 
     private short put(byte[] array, int offset, int length) {
@@ -100,6 +97,9 @@ public class LRUDictionary implements Di
 
       if (currSize < initSize) {
         // There is space to add without evicting.
+        if (indexToNode[currSize] == null) {
+          indexToNode[currSize] = new Node();
+        }
         indexToNode[currSize].setContents(stored, 0, stored.length);
         setHead(indexToNode[currSize]);
         short ret = (short) currSize++;
@@ -172,19 +172,15 @@ public class LRUDictionary implements Di
     }
 
     private void clear() {
+      for (int i = 0; i < currSize; i++) {
+        indexToNode[i].next = null;
+        indexToNode[i].prev = null;
+        indexToNode[i].container = null;
+      }
       currSize = 0;
       nodeToIndex.clear();
       tail = null;
       head = null;
-
-      for (Node n : indexToNode) {
-        n.container = null;
-      }
-
-      for (int i = 0; i < initSize; i++) {
-        indexToNode[i].next = null;
-        indexToNode[i].prev = null;
-      }
     }
 
     private static class Node {



Mime
View raw message