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 java.lang.String |
DIRECT_STORE_DATA_FRAME_OUTPUT |
static java.lang.String |
DIRECT_STORE_OBJECT_OWNER
The owner of direct buffers that are stored in Regions and tracked in UMM.
|
EXECUTION, STORE_DATA_FRAME_OUTPUT| Modifier | Constructor and Description |
|---|---|
protected |
DirectBufferAllocator() |
| Modifier and Type | Method and Description |
|---|---|
java.nio.ByteBuffer |
allocate(int size,
java.lang.String owner)
Allocate a new ByteBuffer of given size.
|
java.nio.ByteBuffer |
allocateForStorage(int size)
Allocate a new ByteBuffer of given size for storage in a Region.
|
java.nio.ByteBuffer |
allocateWithFallback(int size,
java.lang.String owner)
Allocate using the default allocator and fallback to base JDK one in case
allocation fails due to some reason (e.g.
|
java.lang.Object |
baseObject(java.nio.ByteBuffer buffer)
Get the base object of the ByteBuffer for raw reads/writes by Unsafe API.
|
long |
baseOffset(java.nio.ByteBuffer buffer)
Get the base offset of the ByteBuffer for raw reads/writes by Unsafe API.
|
void |
changeOwnerToStorage(java.nio.ByteBuffer buffer,
int capacity,
java.util.function.BiConsumer<java.lang.String,java.lang.Object> changeOwner) |
void |
clearPostAllocate(java.nio.ByteBuffer buffer,
int position)
Clears the memory to be zeros immediately after allocation
from given position to end.
|
void |
close()
Any cleanup required at system close.
|
java.nio.ByteBuffer |
expand(java.nio.ByteBuffer buffer,
int required,
java.lang.String owner)
Expand given ByteBuffer to new capacity.
|
java.nio.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.
|
java.lang.RuntimeException |
lowMemoryException(java.lang.String op,
int required) |
static void |
resetInstance() |
static void |
setInstance(DirectBufferAllocator allocator) |
java.nio.ByteBuffer |
transfer(java.nio.ByteBuffer buffer,
java.lang.String owner)
Return a ByteBuffer either sharing data of given ByteBuffer
if its type matches, or else copying from the given ByteBuffer.
|
allocateCustom, expandedSize, fill, fill, isManagedDirect, release, releaseBuffer, toBytespublic static final int DIRECT_OBJECT_OVERHEAD
public static final java.lang.String DIRECT_STORE_OBJECT_OWNER
public static final java.lang.String DIRECT_STORE_DATA_FRAME_OUTPUT
public static DirectBufferAllocator instance()
public DirectBufferAllocator initialize()
public static void setInstance(DirectBufferAllocator allocator)
public static void resetInstance()
public java.lang.RuntimeException lowMemoryException(java.lang.String op,
int required)
public void changeOwnerToStorage(java.nio.ByteBuffer buffer,
int capacity,
java.util.function.BiConsumer<java.lang.String,java.lang.Object> changeOwner)
public java.nio.ByteBuffer allocate(int size,
java.lang.String owner)
BufferAllocatorallocate in class BufferAllocatorpublic java.nio.ByteBuffer allocateWithFallback(int size,
java.lang.String owner)
BufferAllocatorallocateWithFallback in class BufferAllocatorpublic java.nio.ByteBuffer allocateForStorage(int size)
BufferAllocatorallocateForStorage in class BufferAllocatorpublic void clearPostAllocate(java.nio.ByteBuffer buffer,
int position)
BufferAllocatorclearPostAllocate in class BufferAllocatorpublic java.lang.Object baseObject(java.nio.ByteBuffer buffer)
BufferAllocatorbaseObject in class BufferAllocatorpublic long baseOffset(java.nio.ByteBuffer buffer)
BufferAllocatorbaseOffset in class BufferAllocatorpublic java.nio.ByteBuffer expand(java.nio.ByteBuffer buffer,
int required,
java.lang.String owner)
BufferAllocatorexpand in class BufferAllocatorpublic java.nio.ByteBuffer fromBytesToStorage(byte[] bytes,
int offset,
int length)
BufferAllocatorfromBytesToStorage in class BufferAllocatorpublic java.nio.ByteBuffer transfer(java.nio.ByteBuffer buffer,
java.lang.String owner)
BufferAllocatortransfer in class BufferAllocatorpublic boolean isDirect()
BufferAllocatorisDirect in class BufferAllocatorpublic void close()
BufferAllocatorclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class BufferAllocatorCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.