[infinispan-commits] Infinispan SVN: r1934 - branches/4.1.x/lucene-directory/src/main/java/org/infinispan/lucene.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Mon Jun 28 18:20:00 EDT 2010
Author: sannegrinovero
Date: 2010-06-28 18:20:00 -0400 (Mon, 28 Jun 2010)
New Revision: 1934
Modified:
branches/4.1.x/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexInput.java
Log:
[ISPN-512] (Avoid throwing an IOException on a buffer switch caused by Lucene's seek()) - branch 4.1.x
Modified: branches/4.1.x/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexInput.java
===================================================================
--- branches/4.1.x/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexInput.java 2010-06-25 00:19:52 UTC (rev 1933)
+++ branches/4.1.x/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexInput.java 2010-06-28 22:20:00 UTC (rev 1934)
@@ -117,7 +117,7 @@
int targetChunk = (int) (pos / chunkSize);
if (targetChunk != currentLoadedChunk) {
currentLoadedChunk = targetChunk;
- setBufferToCurrentChunk();
+ setBufferToCurrentChunkIfPossible();
}
}
@@ -134,6 +134,20 @@
}
currentBufferSize = buffer.length;
}
+
+ // Lucene might try seek(pos) using an illegal pos value
+ // RAMDirectory teaches to position the cursor to the end of previous chunk in this case
+ private void setBufferToCurrentChunkIfPossible() throws IOException {
+ CacheKey key = new ChunkCacheKey(fileKey.getIndexName(), fileKey.getFileName(), currentLoadedChunk);
+ buffer = (byte[]) cache.get(key);
+ if (buffer == null) {
+ currentLoadedChunk--;
+ bufferPosition = chunkSize;
+ }
+ else {
+ currentBufferSize = buffer.length;
+ }
+ }
@Override
public long length() {
More information about the infinispan-commits
mailing list