better caching of LZF streamns

This commit is contained in:
kimchy 2011-04-20 13:37:30 +03:00
parent f5dbcb2fa4
commit 9c606c7b1d
1 changed files with 9 additions and 5 deletions

View File

@ -58,12 +58,16 @@ public class LZFStreamInput extends StreamInput {
private int bufferLength = 0;
// ES: added to support never closing just resetting
private final boolean neverClose;
private final boolean cached;
public LZFStreamInput(StreamInput in, boolean neverClose) {
public LZFStreamInput(StreamInput in, boolean cached) {
super();
this.neverClose = neverClose;
_recycler = BufferRecycler.instance();
this.cached = cached;
if (cached) {
_recycler = new BufferRecycler();
} else {
_recycler = BufferRecycler.instance();
}
inputStream = in;
_inputBuffer = _recycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN);
@ -146,7 +150,7 @@ public class LZFStreamInput extends StreamInput {
}
@Override public void close() throws IOException {
if (neverClose) {
if (cached) {
reset();
return;
}