Class CodecPool

java.lang.Object
org.apache.hadoop.hbase.io.compress.CodecPool

@Private public class CodecPool extends Object
A global compressor/decompressor pool used to save and reuse (possibly native) compression/decompression codecs. Copied from the class of the same name in hadoop-common and augmented to improve borrow/return performance.
  • Field Details

  • Constructor Details

  • Method Details

    • createCache

      private static <T> com.github.benmanes.caffeine.cache.LoadingCache<Class<T>,AtomicInteger> createCache()
    • initLeaseCounting

      static void initLeaseCounting()
      Call if you want lease counting to be enabled. Only used in unit tests.
    • borrow

      private static <T> T borrow(ConcurrentMap<Class<T>,NavigableSet<T>> pool, Class<? extends T> codecClass)
    • payback

      private static <T> boolean payback(ConcurrentMap<Class<T>,NavigableSet<T>> pool, T codec)
    • getLeaseCount

      private static <T> int getLeaseCount(com.github.benmanes.caffeine.cache.LoadingCache<Class<T>,AtomicInteger> usageCounts, Class<? extends T> codecClass)
      Copied from hadoop-common without significant modification.
    • updateLeaseCount

      private static <T> void updateLeaseCount(com.github.benmanes.caffeine.cache.LoadingCache<Class<T>,AtomicInteger> usageCounts, T codec, int delta)
      Copied from hadoop-common without significant modification.
    • getCompressor

      public static org.apache.hadoop.io.compress.Compressor getCompressor(org.apache.hadoop.io.compress.CompressionCodec codec, org.apache.hadoop.conf.Configuration conf)
      Get a Compressor for the given CompressionCodec from the pool, or get a new one if the pool is empty. Copied from hadoop-common without significant modification.
    • getCompressor

      public static org.apache.hadoop.io.compress.Compressor getCompressor(org.apache.hadoop.io.compress.CompressionCodec codec)
    • getDecompressor

      public static org.apache.hadoop.io.compress.Decompressor getDecompressor(org.apache.hadoop.io.compress.CompressionCodec codec)
      Get a Decompressor for the given CompressionCodec from the pool, or get a new one if the pool is empty. Copied from hadoop-common without significant modification.
    • getByteBuffDecompressor

    • returnCompressor

      public static void returnCompressor(org.apache.hadoop.io.compress.Compressor compressor)
      Return the Compressor to the pool. Copied from hadoop-common without significant modification.
    • returnDecompressor

      public static void returnDecompressor(org.apache.hadoop.io.compress.Decompressor decompressor)
      Return the Decompressor to the pool. Copied from hadoop-common without significant modification.
    • returnByteBuffDecompressor

      public static void returnByteBuffDecompressor(ByteBuffDecompressor decompressor)
    • getLeasedCompressorsCount

      static int getLeasedCompressorsCount(@Nullable org.apache.hadoop.io.compress.CompressionCodec codec)
      Returns the number of leased Compressors for this CompressionCodec. Copied from hadoop-common without significant modification.
    • getLeasedDecompressorsCount

      static int getLeasedDecompressorsCount(@Nullable org.apache.hadoop.io.compress.CompressionCodec codec)
      Returns the number of leased Decompressors for this CompressionCodec. Copied from hadoop-common without significant modification.