mirror of https://github.com/apache/lucene.git
LUCENE-5722: Speed up MMapDirectory.seek() - first small patch for multi-mmap case
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1599218 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e83229fd20
commit
0d89f3f6cf
|
@ -46,7 +46,7 @@ abstract class ByteBufferIndexInput extends IndexInput {
|
|||
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 extends IndexInput {
|
|||
// 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 extends IndexInput {
|
|||
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) {
|
||||
|
|
Loading…
Reference in New Issue