Apache Lucene open-source search software
LUCENE-430: Delay allocation of the buffer after a clone of BufferedIndexInput.
Michael Busch393b4525dbfd
diff --git a/CHANGES.txt b/CHANGES.txtindex fe90a72c860..e6365292ed2 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -180,6 +180,10 @@ Optimizations4. LUCENE-882: Spellchecker doesn't store the ngrams anymore but only indexesthem 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)Documentationdiff --git a/src/java/org/apache/lucene/store/BufferedIndexInput.java b/src/java/org/apache/lucene/store/BufferedIndexInput.javaindex 9ea130bd427..fb151ab3c7b 100644--- a/src/java/org/apache/lucene/store/BufferedIndexInput.java+++ b/src/java/org/apache/lucene/store/BufferedIndexInput.java@@ -88,8 +88,10 @@ public abstract class BufferedIndexInput extends IndexInput {if (bufferLength <= 0)throw new IOException("read past EOF");- if (buffer == null)+ if (buffer == null) {buffer = new byte[BUFFER_SIZE]; // allocate buffer lazily+ seekInternal(bufferStart);+ }readInternal(buffer, 0, bufferLength);bufferStart = start;@@ -127,10 +129,10 @@ public abstract class BufferedIndexInput extends IndexInput {public Object clone() {BufferedIndexInput clone = (BufferedIndexInput)super.clone();- if (buffer != null) {- clone.buffer = new byte[BUFFER_SIZE];- System.arraycopy(buffer, 0, clone.buffer, 0, bufferLength);- }+ clone.buffer = null;+ clone.bufferLength = 0;+ clone.bufferPosition = 0;+ clone.bufferStart = getFilePointer();return clone;}