You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2014/06/02 15:35:42 UTC
svn commit: r1599218 -
/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java
Author: uschindler
Date: Mon Jun 2 13:35:42 2014
New Revision: 1599218
URL: http://svn.apache.org/r1599218
Log:
LUCENE-5722: Speed up MMapDirectory.seek() - first small patch for multi-mmap case
Modified:
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java?rev=1599218&r1=1599217&r2=1599218&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java Mon Jun 2 13:35:42 2014
@@ -46,7 +46,7 @@ abstract class ByteBufferIndexInput exte
private long length;
private String sliceDescription;
- private int curBufIndex;
+ private int curBufIndex = -1;
private ByteBuffer curBuf; // redundant for speed: buffers[curBufIndex]
@@ -163,11 +163,15 @@ abstract class ByteBufferIndexInput exte
// in case pos + offset overflows.
final int bi = (int) (pos >> chunkSizePower);
try {
- final ByteBuffer b = buffers[bi];
- b.position((int) (pos & chunkSizeMask));
- // write values, on exception all is unchanged
- this.curBufIndex = bi;
- this.curBuf = b;
+ if (bi == curBufIndex) {
+ curBuf.position((int) (pos & chunkSizeMask));
+ } else {
+ final ByteBuffer b = buffers[bi];
+ b.position((int) (pos & chunkSizeMask));
+ // write values, on exception all is unchanged
+ this.curBufIndex = bi;
+ this.curBuf = b;
+ }
} catch (ArrayIndexOutOfBoundsException aioobe) {
throw new EOFException("seek past EOF: " + this);
} catch (IllegalArgumentException iae) {
@@ -228,6 +232,7 @@ abstract class ByteBufferIndexInput exte
clone.buffers = buildSlice(buffers, offset, length);
clone.offset = (int) (offset & chunkSizeMask);
clone.length = length;
+ clone.curBufIndex = -1;
// register the new clone in our clone list to clean it up on closing:
if (clones != null) {