org.apache.lucene.store.bytebuffer
Interface ByteBufferAllocator

All Known Implementing Classes:
ByteBufferCache, CachingByteBufferAllocator, PlainByteBufferAllocator

public interface ByteBufferAllocator

A byte buffer allocator simple allocates byte buffers, and handles releasing them. Implementation can include special direct buffer cleaning when releasing a buffer, as well as caching of byte buffers.

There are two types of buffers that can be allocated, small and big. This comes in handy when knowing in advance (more or less) the size of the buffers needed (large files or small), as well as in caching implementations.


Nested Class Summary
static class ByteBufferAllocator.Cleaner
          Helper class to allocator implementations allowing to clean direct buffers.
static class ByteBufferAllocator.Type
           
 
Method Summary
 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(ByteBuffer buffer)
          Release the buffer.
 int sizeInBytes(ByteBufferAllocator.Type type)
          The size (in bytes) that is allocated for the provided type.
 

Method Detail

sizeInBytes

int sizeInBytes(ByteBufferAllocator.Type type)
The size (in bytes) that is allocated for the provided type.


allocate

ByteBuffer allocate(ByteBufferAllocator.Type type)
                    throws IOException
Allocate a byte buffer for the specific type.

Throws:
IOException

release

void release(ByteBuffer buffer)
Release the buffer.


close

void close()
Close the allocator, releasing any cached buffers for example.



Copyright © 2009-2012. All Rights Reserved.