org.apache.lucene.store.bytebuffer
Class CachingByteBufferAllocator
java.lang.Object
org.apache.lucene.store.bytebuffer.PlainByteBufferAllocator
org.apache.lucene.store.bytebuffer.CachingByteBufferAllocator
- All Implemented Interfaces:
- ByteBufferAllocator
public class CachingByteBufferAllocator
- extends PlainByteBufferAllocator
The caching byte buffer allocator allows to define a global size for both the small and large buffers
allocated. Those will be reused when possible.
|
Constructor Summary |
CachingByteBufferAllocator(boolean direct,
int smallBufferSizeInBytes,
int largeBufferSizeInBytes,
int smallCacheSizeInBytes,
int largeCacheSizeInBytes)
|
|
Method Summary |
java.nio.ByteBuffer |
allocate(ByteBufferAllocator.Type type)
Allocate a byte buffer for the specific type. |
void |
close()
Close the allocator, releasing any cached buffers for example. |
void |
release(java.nio.ByteBuffer buffer)
Release the buffer. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CachingByteBufferAllocator
public CachingByteBufferAllocator(boolean direct,
int smallBufferSizeInBytes,
int largeBufferSizeInBytes,
int smallCacheSizeInBytes,
int largeCacheSizeInBytes)
- Parameters:
direct - If set to true, will allocate direct buffers (off heap).smallBufferSizeInBytes - The size (in bytes) of the small buffer allocation.largeBufferSizeInBytes - The size (in bytes) of the large buffer allocation.smallCacheSizeInBytes - The size of the small cache buffer in bytes.largeCacheSizeInBytes - The size of the large cache buffer in bytes.
allocate
public java.nio.ByteBuffer allocate(ByteBufferAllocator.Type type)
throws java.io.IOException
- Description copied from interface:
ByteBufferAllocator
- Allocate a byte buffer for the specific type.
- Specified by:
allocate in interface ByteBufferAllocator- Overrides:
allocate in class PlainByteBufferAllocator
- Throws:
java.io.IOException
release
public void release(java.nio.ByteBuffer buffer)
- Description copied from interface:
ByteBufferAllocator
- Release the buffer.
- Specified by:
release in interface ByteBufferAllocator- Overrides:
release in class PlainByteBufferAllocator
close
public void close()
- Description copied from interface:
ByteBufferAllocator
- Close the allocator, releasing any cached buffers for example.
- Specified by:
close in interface ByteBufferAllocator- Overrides:
close in class PlainByteBufferAllocator