activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r632651 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashBin.java
Date Sat, 01 Mar 2008 19:59:50 GMT
Author: rajdavies
Date: Sat Mar  1 11:59:49 2008
New Revision: 632651

URL: http://svn.apache.org/viewvc?rev=632651&view=rev
Log:
fix for inaccurate page calculation in bin overflow

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashBin.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashBin.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashBin.java?rev=632651&r1=632650&r2=632651&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashBin.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashBin.java
Sat Mar  1 11:59:49 2008
@@ -183,10 +183,12 @@
     private void addHashEntry(int index, HashEntry entry) throws IOException {
         HashPageInfo pageToUse = null;
         int offset = 0;
-        if (index >= maximumBinSize()) {
-            HashPage hp = hashIndex.createPage(id);
-            pageToUse = addHashPageInfo(hp.getId(), 0);
-            pageToUse.setPage(hp);
+        if (index >= getMaximumBinSize()) {
+            while(index >= getMaximumBinSize()) {
+                HashPage hp = hashIndex.createPage(id);
+                pageToUse = addHashPageInfo(hp.getId(), 0);
+                pageToUse.setPage(hp);
+            }
             offset = 0;
         } else {
             int count = 0;
@@ -239,7 +241,7 @@
     }
     
 
-    private int maximumBinSize() {
+    private int getMaximumBinSize() {
         return maximumEntries * hashPages.size();
     }
 
@@ -264,7 +266,6 @@
         int count = 0;
         for (HashPageInfo page : hashPages) {
             if ((index + 1) <= (count + page.size())) {
-                // count=count==0?count:count+1;
                 result = index - count;
                 break;
             }
@@ -274,13 +275,12 @@
     }
 
     private void doOverFlow(int index) throws IOException {
-        int pageNo = index / maximumEntries;
-        HashPageInfo info = hashPages.get(pageNo);
+        HashPageInfo info = getRetrievePage(index);
         if (info.size() > maximumEntries) {
             // overflowed
             info.begin();
             HashEntry entry = info.removeHashEntry(info.size() - 1);
-            doOverFlow(pageNo + 1, entry);
+            doOverFlow(hashPages.indexOf(info) + 1, entry);
         }
     }
 



Mime
View raw message