[infinispan-commits] Infinispan SVN: r1935 - trunk/lucene-directory/src/main/java/org/infinispan/lucene.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Mon Jun 28 18:23:40 EDT 2010
Author: sannegrinovero
Date: 2010-06-28 18:23:40 -0400 (Mon, 28 Jun 2010)
New Revision: 1935
Modified:
trunk/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()) - trunk
Modified: trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexInput.java
===================================================================
--- trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexInput.java 2010-06-28 22:20:00 UTC (rev 1934)
+++ trunk/lucene-directory/src/main/java/org/infinispan/lucene/InfinispanIndexInput.java 2010-06-28 22:23:40 UTC (rev 1935)
@@ -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