Class BufferRecycler

java.lang.Object
org.iq80.snappy.BufferRecycler

class BufferRecycler extends Object
Simple helper class to encapsulate details of basic buffer recycling scheme, which helps a lot (as per profiling) for smaller encoding cases.
  • 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

      protected static final ThreadLocal<SoftReference<BufferRecycler>> recyclerRef
      This ThreadLocal contains a SoftReference to a BufferRecycler 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
  • Constructor Details

    • BufferRecycler

      BufferRecycler()
  • Method Details

    • 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)