Package org.iq80.snappy
Class BufferRecycler
- java.lang.Object
-
- org.iq80.snappy.BufferRecycler
-
class BufferRecycler extends java.lang.Object
Simple helper class to encapsulate details of basic buffer recycling scheme, which helps a lot (as per profiling) for smaller encoding cases.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
decodingBuffer
private byte[]
encodingBuffer
private short[]
encodingHash
private byte[]
inputBuffer
private static int
MIN_ENCODING_BUFFER
private static int
MIN_OUTPUT_BUFFER
private byte[]
outputBuffer
protected static java.lang.ThreadLocal<java.lang.ref.SoftReference<BufferRecycler>>
recyclerRef
ThisThreadLocal
contains aSoftReference
to aBufferRecycler
used to provide a low-cost buffer recycling for buffers we need for encoding, decoding.
-
Constructor Summary
Constructors Constructor Description BufferRecycler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
allocDecodeBuffer(int size)
byte[]
allocEncodingBuffer(int minSize)
short[]
allocEncodingHash(int suggestedSize)
byte[]
allocInputBuffer(int minSize)
byte[]
allocOutputBuffer(int minSize)
void
clear()
static BufferRecycler
instance()
Accessor to get thread-local recycler instancevoid
releaseDecodeBuffer(byte[] buffer)
void
releaseEncodeBuffer(byte[] buffer)
void
releaseEncodingHash(short[] buffer)
void
releaseInputBuffer(byte[] buffer)
void
releaseOutputBuffer(byte[] buffer)
-
-
-
Field Detail
-
MIN_ENCODING_BUFFER
private static final int MIN_ENCODING_BUFFER
- See Also:
- Constant Field Values
-
MIN_OUTPUT_BUFFER
private static final int MIN_OUTPUT_BUFFER
- See Also:
- Constant Field Values
-
recyclerRef
protected static final java.lang.ThreadLocal<java.lang.ref.SoftReference<BufferRecycler>> recyclerRef
ThisThreadLocal
contains aSoftReference
to aBufferRecycler
used to provide a low-cost buffer recycling for buffers we need for encoding, decoding.
-
inputBuffer
private byte[] inputBuffer
-
outputBuffer
private byte[] outputBuffer
-
decodingBuffer
private byte[] decodingBuffer
-
encodingBuffer
private byte[] encodingBuffer
-
encodingHash
private short[] encodingHash
-
-
Method Detail
-
instance
public static BufferRecycler instance()
Accessor to get thread-local recycler instance
-
clear
public void clear()
-
allocEncodingBuffer
public byte[] allocEncodingBuffer(int minSize)
-
releaseEncodeBuffer
public void releaseEncodeBuffer(byte[] buffer)
-
allocOutputBuffer
public byte[] allocOutputBuffer(int minSize)
-
releaseOutputBuffer
public void releaseOutputBuffer(byte[] buffer)
-
allocEncodingHash
public short[] allocEncodingHash(int suggestedSize)
-
releaseEncodingHash
public void releaseEncodingHash(short[] buffer)
-
allocInputBuffer
public byte[] allocInputBuffer(int minSize)
-
releaseInputBuffer
public void releaseInputBuffer(byte[] buffer)
-
allocDecodeBuffer
public byte[] allocDecodeBuffer(int size)
-
releaseDecodeBuffer
public void releaseDecodeBuffer(byte[] buffer)
-
-