mirror of https://github.com/apache/lucene.git
LUCENE-430: Delay allocation of the buffer after a clone of BufferedIndexInput.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@541402 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
45f760ea24
commit
393b4525db
|
@ -180,6 +180,10 @@ Optimizations
|
||||||
|
|
||||||
4. LUCENE-882: Spellchecker doesn't store the ngrams anymore but only indexes
|
4. LUCENE-882: Spellchecker doesn't store the ngrams anymore but only indexes
|
||||||
them to keep the spell index small. (Daniel Naber)
|
them to keep the spell index small. (Daniel Naber)
|
||||||
|
|
||||||
|
5. LUCENE-430: Delay allocation of the buffer after a clone of BufferedIndexInput.
|
||||||
|
Together with LUCENE-888 this will allow to adjust the buffer size
|
||||||
|
dynamically. (Paul Elschot, Michael Busch)
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
|
|
||||||
|
|
|
@ -88,8 +88,10 @@ public abstract class BufferedIndexInput extends IndexInput {
|
||||||
if (bufferLength <= 0)
|
if (bufferLength <= 0)
|
||||||
throw new IOException("read past EOF");
|
throw new IOException("read past EOF");
|
||||||
|
|
||||||
if (buffer == null)
|
if (buffer == null) {
|
||||||
buffer = new byte[BUFFER_SIZE]; // allocate buffer lazily
|
buffer = new byte[BUFFER_SIZE]; // allocate buffer lazily
|
||||||
|
seekInternal(bufferStart);
|
||||||
|
}
|
||||||
readInternal(buffer, 0, bufferLength);
|
readInternal(buffer, 0, bufferLength);
|
||||||
|
|
||||||
bufferStart = start;
|
bufferStart = start;
|
||||||
|
@ -127,10 +129,10 @@ public abstract class BufferedIndexInput extends IndexInput {
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
BufferedIndexInput clone = (BufferedIndexInput)super.clone();
|
BufferedIndexInput clone = (BufferedIndexInput)super.clone();
|
||||||
|
|
||||||
if (buffer != null) {
|
clone.buffer = null;
|
||||||
clone.buffer = new byte[BUFFER_SIZE];
|
clone.bufferLength = 0;
|
||||||
System.arraycopy(buffer, 0, clone.buffer, 0, bufferLength);
|
clone.bufferPosition = 0;
|
||||||
}
|
clone.bufferStart = getFilePointer();
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue