org.apache.lucene.store.bytebuffer
Class PlainByteBufferAllocator

java.lang.Object
  extended by org.apache.lucene.store.bytebuffer.PlainByteBufferAllocator
All Implemented Interfaces:
ByteBufferAllocator
Direct Known Subclasses:
CachingByteBufferAllocator

public class PlainByteBufferAllocator
extends Object
implements ByteBufferAllocator

A simple byte buffer allocator that does not caching. The direct flag allows to control if the byte buffer will be allocated off heap or not.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.lucene.store.bytebuffer.ByteBufferAllocator
ByteBufferAllocator.Cleaner, ByteBufferAllocator.Type
 
Field Summary
protected  boolean direct
           
protected  int largeBufferSizeInBytes
           
protected  int smallBufferSizeInBytes
           
 
Constructor Summary
PlainByteBufferAllocator(boolean direct, int smallBufferSizeInBytes, int largeBufferSizeInBytes)
          Constructs a new plain byte buffer allocator that does no caching.
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

direct

protected final boolean direct

smallBufferSizeInBytes

protected final int smallBufferSizeInBytes

largeBufferSizeInBytes

protected final int largeBufferSizeInBytes
Constructor Detail

PlainByteBufferAllocator

public PlainByteBufferAllocator(boolean direct,
                                int smallBufferSizeInBytes,
                                int largeBufferSizeInBytes)
Constructs a new plain byte buffer allocator that does no caching.

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.
Method Detail

sizeInBytes

public int sizeInBytes(ByteBufferAllocator.Type type)
Description copied from interface: ByteBufferAllocator
The size (in bytes) that is allocated for the provided type.

Specified by:
sizeInBytes in interface ByteBufferAllocator

allocate

public ByteBuffer allocate(ByteBufferAllocator.Type type)
                    throws IOException
Description copied from interface: ByteBufferAllocator
Allocate a byte buffer for the specific type.

Specified by:
allocate in interface ByteBufferAllocator
Throws:
IOException

release

public void release(ByteBuffer buffer)
Description copied from interface: ByteBufferAllocator
Release the buffer.

Specified by:
release in interface ByteBufferAllocator

close

public void close()
Description copied from interface: ByteBufferAllocator
Close the allocator, releasing any cached buffers for example.

Specified by:
close in interface ByteBufferAllocator


Copyright © 2009-2012. All Rights Reserved.