public class DirectBufferAllocator extends BufferAllocator
BufferAllocator for direct ByteBuffers
using Java NIO API.| Modifier and Type | Field and Description |
|---|---|
static int |
DIRECT_OBJECT_OVERHEAD
Overhead of allocation on off-heap memory is kept fixed at 8 even though
actual overhead will be dependent on the malloc implementation.
|
static String |
DIRECT_STORE_DATA_FRAME_OUTPUT |
static String |
DIRECT_STORE_OBJECT_OWNER
The owner of direct buffers that are stored in Regions and tracked in UMM.
|
STORE_DATA_FRAME_OUTPUT| Modifier | Constructor and Description |
|---|---|
protected |
DirectBufferAllocator() |
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
allocate(int size,
String owner)
Allocate a new ByteBuffer of given size.
|
ByteBuffer |
allocateForStorage(int size)
Allocate a new ByteBuffer of given size for storage in a Region.
|
Object |
baseObject(ByteBuffer buffer)
Get the base object of the ByteBuffer for raw reads/writes by Unsafe API.
|
long |
baseOffset(ByteBuffer buffer)
Get the base offset of the ByteBuffer for raw reads/writes by Unsafe API.
|
void |
changeOwnerToStorage(ByteBuffer buffer,
int capacity,
java.util.function.Consumer<String> changeOwner) |
void |
clearPostAllocate(ByteBuffer buffer)
Clears the memory to be zeros immediately after allocation.
|
void |
close()
Any cleanup required at system close.
|
ByteBuffer |
expand(ByteBuffer buffer,
int required,
String owner)
Expand given ByteBuffer to new capacity.
|
ByteBuffer |
fromBytesToStorage(byte[] bytes,
int offset,
int length)
Return a ByteBuffer either copying from, or sharing the given heap bytes.
|
DirectBufferAllocator |
initialize() |
static DirectBufferAllocator |
instance() |
boolean |
isDirect()
Indicates if this allocator will produce direct ByteBuffers.
|
RuntimeException |
lowMemoryException(String op,
int required) |
void |
release(ByteBuffer buffer)
For direct ByteBuffers the release method is preferred to eagerly release
the memory instead of depending on heap GC which can be delayed.
|
static void |
resetInstance() |
static void |
setInstance(DirectBufferAllocator allocator) |
ByteBuffer |
transfer(ByteBuffer buffer,
String owner)
Return a ByteBuffer either sharing data of given ByteBuffer
if its type matches, or else copying from the given ByteBuffer.
|
clearBuffer, expandedSize, toBytespublic static final int DIRECT_OBJECT_OVERHEAD
public static final String DIRECT_STORE_OBJECT_OWNER
public static final String DIRECT_STORE_DATA_FRAME_OUTPUT
public static DirectBufferAllocator instance()
public DirectBufferAllocator initialize()
public static void setInstance(DirectBufferAllocator allocator)
public static void resetInstance()
public RuntimeException lowMemoryException(String op, int required)
public void changeOwnerToStorage(ByteBuffer buffer, int capacity, java.util.function.Consumer<String> changeOwner)
public ByteBuffer allocate(int size, String owner)
BufferAllocatorallocate in class BufferAllocatorpublic ByteBuffer allocateForStorage(int size)
BufferAllocatorallocateForStorage in class BufferAllocatorpublic void clearPostAllocate(ByteBuffer buffer)
BufferAllocatorclearPostAllocate in class BufferAllocatorpublic Object baseObject(ByteBuffer buffer)
BufferAllocatorbaseObject in class BufferAllocatorpublic long baseOffset(ByteBuffer buffer)
BufferAllocatorbaseOffset in class BufferAllocatorpublic ByteBuffer expand(ByteBuffer buffer, int required, String owner)
BufferAllocatorexpand in class BufferAllocatorpublic ByteBuffer fromBytesToStorage(byte[] bytes, int offset, int length)
BufferAllocatorfromBytesToStorage in class BufferAllocatorpublic ByteBuffer transfer(ByteBuffer buffer, String owner)
BufferAllocatortransfer in class BufferAllocatorpublic void release(ByteBuffer buffer)
BufferAllocatorrelease in class BufferAllocatorpublic boolean isDirect()
BufferAllocatorisDirect in class BufferAllocatorpublic void close()
BufferAllocatorclose in interface Closeableclose in interface AutoCloseableclose in class BufferAllocatorCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.