You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ra...@apache.org on 2008/05/16 22:23:08 UTC
svn commit: r657193 -
/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/hash/HashIndex.java
Author: rajdavies
Date: Fri May 16 13:23:08 2008
New Revision: 657193
URL: http://svn.apache.org/viewvc?rev=657193&view=rev
Log:
Fix for https://issues.apache.org/activemq/browse/AMQ-1736
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=657193&r1=657192&r2=657193&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 Fri May 16 13:23:08 2008
@@ -55,9 +55,6 @@
private int keySize = DEFAULT_KEY_SIZE;
private int numberOfBins = DEFAULT_BIN_SIZE;
private int keysPerPage = this.pageSize /this.keySize;
- private DataByteArrayInputStream dataIn;
- private DataByteArrayOutputStream dataOut;
- private byte[] readBuffer;
private HashBin[] bins;
private Marshaller keyMarshaller;
private long length;
@@ -242,9 +239,6 @@
this.bins = new HashBin[capacity];
threshold = calculateThreashold();
keysPerPage = pageSize / keySize;
- dataIn = new DataByteArrayInputStream();
- dataOut = new DataByteArrayOutputStream(pageSize);
- readBuffer = new byte[pageSize];
try {
openIndexFile();
if (indexFile.length() > 0) {
@@ -375,6 +369,7 @@
}
void writeFullPage(HashPage page) throws IOException {
+ DataByteArrayOutputStream dataOut = new DataByteArrayOutputStream(pageSize);
dataOut.reset();
page.write(keyMarshaller, dataOut);
if (dataOut.size() > pageSize) {
@@ -385,6 +380,7 @@
}
void writePageHeader(HashPage page) throws IOException {
+ DataByteArrayOutputStream dataOut = new DataByteArrayOutputStream(pageSize);
dataOut.reset();
page.writeHeader(dataOut);
indexFile.seek(page.getId());
@@ -392,6 +388,9 @@
}
HashPage getFullPage(long id) throws IOException {
+ byte[] readBuffer = new byte[pageSize];
+ DataByteArrayInputStream dataIn = new DataByteArrayInputStream();
+ readBuffer = new byte[pageSize];
indexFile.seek(id);
indexFile.readFully(readBuffer, 0, pageSize);
dataIn.restart(readBuffer);
@@ -402,6 +401,8 @@
}
HashPage getPageHeader(long id) throws IOException {
+ byte[] readBuffer = new byte[pageSize];
+ DataByteArrayInputStream dataIn = new DataByteArrayInputStream();
indexFile.seek(id);
indexFile.readFully(readBuffer, 0, HashPage.PAGE_HEADER_SIZE);
dataIn.restart(readBuffer);
@@ -468,6 +469,8 @@
}
private void doLoad() throws IOException {
+ byte[] readBuffer = new byte[pageSize];
+ DataByteArrayInputStream dataIn = new DataByteArrayInputStream();
long offset = 0;
if (loaded.compareAndSet(false, true)) {
while ((offset + pageSize) <= indexFile.length()) {