LUCENE-4995: Don't hold references on large decompression buffers in CompressingStoredFieldsReader.

CompressingStoredFieldsReader now only reuses an internal buffer when there is
no more than 32kb to decompress. For large blocks, a dedicated decompression
buffer will be created on demand.


git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1491374 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrien Grand 2013-06-10 08:39:50 +00:00
parent d35702de9a
commit e78908ad8c
1 changed files with 4 additions and 0 deletions

View File

@ -60,6 +60,9 @@ import org.apache.lucene.util.packed.PackedInts;
*/ */
public final class CompressingStoredFieldsReader extends StoredFieldsReader { public final class CompressingStoredFieldsReader extends StoredFieldsReader {
// Do not reuse the decompression buffer when there is more than 32kb to decompress
private static final int BUFFER_REUSE_THRESHOLD = 1 << 15;
private final FieldInfos fieldInfos; private final FieldInfos fieldInfos;
private final CompressingStoredFieldsIndexReader indexReader; private final CompressingStoredFieldsIndexReader indexReader;
private final IndexInput fieldsStream; private final IndexInput fieldsStream;
@ -255,6 +258,7 @@ public final class CompressingStoredFieldsReader extends StoredFieldsReader {
return; return;
} }
final BytesRef bytes = totalLength <= BUFFER_REUSE_THRESHOLD ? this.bytes : new BytesRef();
decompressor.decompress(fieldsStream, totalLength, offset, length, bytes); decompressor.decompress(fieldsStream, totalLength, offset, length, bytes);
assert bytes.length == length; assert bytes.length == length;