Package org.xerial.snappy.buffer
Class CachedBufferAllocator
- java.lang.Object
-
- org.xerial.snappy.buffer.CachedBufferAllocator
-
- All Implemented Interfaces:
BufferAllocator
public class CachedBufferAllocator extends java.lang.Object implements BufferAllocator
Cached buffer
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Deque<byte[]>
bufferQueue
private int
bufferSize
private static BufferAllocatorFactory
factory
private static java.util.Map<java.lang.Integer,java.lang.ref.SoftReference<CachedBufferAllocator>>
queueTable
Use SoftReference so that having this queueTable does not prevent the GC of CachedBufferAllocator instances
-
Constructor Summary
Constructors Constructor Description CachedBufferAllocator(int bufferSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
allocate(int size)
static CachedBufferAllocator
getAllocator(int bufferSize)
static BufferAllocatorFactory
getBufferAllocatorFactory()
void
release(byte[] buffer)
static void
setBufferAllocatorFactory(BufferAllocatorFactory factory)
-
-
-
Field Detail
-
factory
private static BufferAllocatorFactory factory
-
queueTable
private static final java.util.Map<java.lang.Integer,java.lang.ref.SoftReference<CachedBufferAllocator>> queueTable
Use SoftReference so that having this queueTable does not prevent the GC of CachedBufferAllocator instances
-
bufferSize
private final int bufferSize
-
bufferQueue
private final java.util.Deque<byte[]> bufferQueue
-
-
Method Detail
-
setBufferAllocatorFactory
public static void setBufferAllocatorFactory(BufferAllocatorFactory factory)
-
getBufferAllocatorFactory
public static BufferAllocatorFactory getBufferAllocatorFactory()
-
getAllocator
public static CachedBufferAllocator getAllocator(int bufferSize)
-
allocate
public byte[] allocate(int size)
- Specified by:
allocate
in interfaceBufferAllocator
-
release
public void release(byte[] buffer)
- Specified by:
release
in interfaceBufferAllocator
-
-