activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r680465 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java
Date Mon, 28 Jul 2008 19:51:06 GMT
Author: rajdavies
Date: Mon Jul 28 12:51:06 2008
New Revision: 680465

URL: http://svn.apache.org/viewvc?rev=680465&view=rev
Log:
Fix for https://issues.apache.org/activemq/browse/AMQ-1872

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

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java?rev=680465&r1=680464&r2=680465&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java
Mon Jul 28 12:51:06 2008
@@ -81,7 +81,6 @@
      * @param directory
      * @param name
      * @param indexManager
-     * @param numberOfBins
      * @throws IOException
      */
     public HashIndex(File directory, String name, IndexManager indexManager) throws IOException
{
@@ -242,6 +241,7 @@
                 capacity <<= 1;
             }
             this.bins = new HashBin[capacity];
+            this.numberOfBins=capacity;
             threshold = calculateThreashold();
             keysPerPage = pageSize / keySize;
             dataIn = new DataByteArrayInputStream();
@@ -426,10 +426,8 @@
 
     void addToBin(HashPage page) throws IOException {
         int index = page.getBinId();
-        if (index >= numberOfBins) {
-            HashBin[] newBins = new HashBin[index+1];
-            System.arraycopy(this.bins, 0, newBins, 0, this.bins.length);
-            this.bins=newBins;
+        if (index >= this.bins.length) {
+            resize(index+1);
         }
         HashBin bin = getBin(index);
         bin.addHashPageInfo(page.getId(), page.getPersistedSize());
@@ -545,7 +543,6 @@
                 newCapacity=capacity;
                 if (newCapacity != numberOfBins) {
                     LOG.info("Resize hash bins " + this.name + " from " + numberOfBins +
" to " + newCapacity);
-                    
                     String backFileName = name + "-REISZE";
                     HashIndex backIndex = new HashIndex(directory,backFileName,indexManager);
                     backIndex.setKeyMarshaller(keyMarshaller);



Mime
View raw message