Class CachingBufferPool

java.lang.Object
org.xerial.snappy.pool.CachingBufferPool
All Implemented Interfaces:
BufferPool

public final class CachingBufferPool extends Object implements BufferPool
A BufferPool implementation which caches values at fixed sizes.

Pooled instances are held as SoftReference to allow GC if necessary.

The current fixed sizes are calculated as follows:

  • Values invalid input: '<' 4KB return 4KB
  • 4KB - 32KB to 2KB
  • 32KB - 512KB to 16KB
  • 512KB - 2MB to 128KB
  • 2MB - 16MB to 512KB
  • 16MB - 128MB to 4MB
  • 128MB - 512MB to 16MB
  • 512MB - 1.5 GB to 128MB
  • Values > 1.5GB return Integer.MAX_VALUE