Package org.iq80.snappy
Class BufferRecycler
java.lang.Object
org.iq80.snappy.BufferRecycler
Simple helper class to encapsulate details of basic buffer
recycling scheme, which helps a lot (as per profiling) for
smaller encoding cases.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]private byte[]private short[]private byte[]private static final intprivate static final intprivate byte[]protected static final ThreadLocal<SoftReference<BufferRecycler>> ThisThreadLocalcontains aSoftReferenceto aBufferRecyclerused to provide a low-cost buffer recycling for buffers we need for encoding, decoding. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]allocDecodeBuffer(int size) byte[]allocEncodingBuffer(int minSize) short[]allocEncodingHash(int suggestedSize) byte[]allocInputBuffer(int minSize) byte[]allocOutputBuffer(int minSize) voidclear()static BufferRecyclerinstance()Accessor to get thread-local recycler instancevoidreleaseDecodeBuffer(byte[] buffer) voidreleaseEncodeBuffer(byte[] buffer) voidreleaseEncodingHash(short[] buffer) voidreleaseInputBuffer(byte[] buffer) voidreleaseOutputBuffer(byte[] buffer)
-
Field Details
-
MIN_ENCODING_BUFFER
private static final int MIN_ENCODING_BUFFER- See Also:
-
MIN_OUTPUT_BUFFER
private static final int MIN_OUTPUT_BUFFER- See Also:
-
recyclerRef
ThisThreadLocalcontains aSoftReferenceto aBufferRecyclerused 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
-
-
Constructor Details
-
BufferRecycler
BufferRecycler()
-
-
Method Details
-
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)
-