recycle hash pages

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@631537 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2008-02-27 10:21:27 +00:00
parent 5075fb9dea
commit 00893abe27
4 changed files with 16 additions and 7 deletions

View File

@ -23,6 +23,8 @@ import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import sun.security.action.GetBooleanAction;
/** /**
* Bin in a HashIndex * Bin in a HashIndex
* *
@ -219,6 +221,11 @@ class HashBin {
HashPageInfo page = getRetrievePage(index); HashPageInfo page = getRetrievePage(index);
int offset = getRetrieveOffset(index); int offset = getRetrieveOffset(index);
HashEntry result = page.removeHashEntry(offset); HashEntry result = page.removeHashEntry(offset);
if (page.isEmpty()) {
hashPages.remove(page);
hashIndex.releasePage(page.getPage());
}
doUnderFlow(index); doUnderFlow(index);
return result; return result;
} }
@ -295,9 +302,7 @@ class HashBin {
} }
} }
private void doUnderFlow(@SuppressWarnings("unused") private void doUnderFlow(int index) {
int index) {
// does little
} }
private void end() throws IOException { private void end() throws IOException {

View File

@ -462,8 +462,8 @@ public class HashIndex implements Index, HashIndexMBean {
} }
static { static {
DEFAULT_PAGE_SIZE = Integer.parseInt(System.getProperty("defaultPageSize", "16384")); DEFAULT_PAGE_SIZE = Integer.parseInt(System.getProperty("defaultPageSize", "8000"));
DEFAULT_KEY_SIZE = Integer.parseInt(System.getProperty("defaultKeySize", "96")); DEFAULT_KEY_SIZE = Integer.parseInt(System.getProperty("defaultKeySize", "80"));
DEFAULT_BIN_SIZE= Integer.parseInt(System.getProperty("defaultBinSize", "1024")); DEFAULT_BIN_SIZE= Integer.parseInt(System.getProperty("defaultBinSize", "128"));
} }
} }

View File

@ -56,6 +56,10 @@ class HashPageInfo {
return this.size; return this.size;
} }
boolean isEmpty() {
return size <= 0;
}
/** /**
* @param size the size to set * @param size the size to set
*/ */

View File

@ -59,7 +59,7 @@ public class KahaReferenceStoreAdapter extends KahaPersistenceAdapter implements
private static final Log LOG = LogFactory.getLog(KahaReferenceStoreAdapter.class); private static final Log LOG = LogFactory.getLog(KahaReferenceStoreAdapter.class);
private static final String STORE_STATE = "store-state"; private static final String STORE_STATE = "store-state";
private static final String INDEX_VERSION_NAME = "INDEX_VERSION"; private static final String INDEX_VERSION_NAME = "INDEX_VERSION";
private static final Integer INDEX_VERSION = new Integer(4); private static final Integer INDEX_VERSION = new Integer(5);
private static final String RECORD_REFERENCES = "record-references"; private static final String RECORD_REFERENCES = "record-references";
private static final String TRANSACTIONS = "transactions-state"; private static final String TRANSACTIONS = "transactions-state";
private MapContainer stateMap; private MapContainer stateMap;