Top Description Fields Constructors Methods
org.xerial.snappy.buffer

public Class CachedBufferAllocator

extends Object
implements BufferAllocator
Class Inheritance
All Implemented Interfaces
org.xerial.snappy.buffer.BufferAllocator
Imports
java.lang.ref.SoftReference, java.util.*

Cached buffer

Field Summary

Modifier and TypeField and Description
private final Deque<byte[]>
private final int
private static BufferAllocatorFactory
private static final Map<Integer, SoftReference<CachedBufferAllocator>>
queueTable

Use SoftReference so that having this queueTable does not prevent the GC of CachedBufferAllocator instances

Constructor Summary

AccessConstructor and Description
public
CachedBufferAllocator(int bufferSize)

Method Summary

Modifier and TypeMethod and Description
public byte[]
public static synchronized CachedBufferAllocator
getAllocator(int bufferSize)

public static BufferAllocatorFactory
public void
public static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferQueueback to summary
private final Deque<byte[]> bufferQueue
bufferSizeback to summary
private final int bufferSize
factoryback to summary
private static BufferAllocatorFactory factory
queueTableback to summary
private static final Map<Integer, SoftReference<CachedBufferAllocator>> queueTable

Use SoftReference so that having this queueTable does not prevent the GC of CachedBufferAllocator instances

Constructor Detail

CachedBufferAllocatorback to summary
public CachedBufferAllocator(int bufferSize)

Method Detail

allocateback to summary
public byte[] allocate(int size)

Implements org.xerial.snappy.buffer.BufferAllocator.allocate.

Annotations
@Override
getAllocatorback to summary
public static synchronized CachedBufferAllocator getAllocator(int bufferSize)
getBufferAllocatorFactoryback to summary
public static BufferAllocatorFactory getBufferAllocatorFactory()
releaseback to summary
public void release(byte[] buffer)

Implements org.xerial.snappy.buffer.BufferAllocator.release.

Annotations
@Override
setBufferAllocatorFactoryback to summary
public static void setBufferAllocatorFactory(BufferAllocatorFactory factory)