public abstract class BaseAllocator extends Object implements BufferAllocator
The class is abstract to enforce usage of RootAllocator/ChildAllocator facades.
| Modifier and Type | Class and Description |
|---|---|
class |
BaseAllocator.Reservation
Implementation of
AllocationReservation that supports
history tracking under DEBUG is true. |
static class |
BaseAllocator.Verbosity
Enum for logging verbosity.
|
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
static String |
DEBUG_ALLOCATOR |
static int |
DEBUG_LOG_LENGTH |
protected org.apache.arrow.memory.Accountant |
parent
The parent allocator.
|
protected long |
reservation
The amount of memory reserved for this allocator.
|
| Modifier | Constructor and Description |
|---|---|
protected |
BaseAllocator(BaseAllocator parentAllocator,
AllocationListener listener,
String name,
long initReservation,
long maxAllocation,
RoundingPolicy roundingPolicy)
Initialize an allocator
|
| Modifier and Type | Method and Description |
|---|---|
void |
assertOpen()
Asserts (using java assertions) that the provided allocator is currently open.
|
ArrowBuf |
buffer(int initialRequestSize)
Allocate a new or reused buffer of the provided size.
|
ArrowBuf |
buffer(int initialRequestSize,
BufferManager manager)
Allocate a new or reused buffer of the provided size.
|
void |
close()
Close this Accountant.
|
long |
getAllocatedMemory()
Return the current amount of allocated memory that this Accountant is managing accounting
for.
|
ArrowByteBufAllocator |
getAsByteBufAllocator()
Returns the allocator this allocator falls back to when it needs more memory.
|
Collection<BufferAllocator> |
getChildAllocators()
Returns the set of child allocators.
|
ArrowBuf |
getEmpty()
Get a reference to the empty buffer associated with this allocator.
|
long |
getHeadroom() |
long |
getInitReservation()
Return the initial reservation.
|
long |
getLimit()
Return the current limit of this Accountant.
|
String |
getName()
Return the name of the accountant.
|
BufferAllocator |
getParentAllocator()
Returns the parent allocator.
|
long |
getPeakMemoryAllocation()
The peak memory allocated by this Accountant.
|
static StringBuilder |
indent(StringBuilder sb,
int indent)
Specify an indentation amount when using a StringBuilder.
|
static boolean |
isDebug() |
boolean |
isOverLimit() |
BufferAllocator |
newChildAllocator(String name,
AllocationListener listener,
long initReservation,
long maxAllocation)
Create a new child allocator.
|
BufferAllocator |
newChildAllocator(String name,
long initReservation,
long maxAllocation)
Create a new child allocator.
|
AllocationReservation |
newReservation()
Create an allocation reservation.
|
static int |
nextPowerOfTwo(int val)
Rounds up the provided value to the nearest power of two.
|
static long |
nextPowerOfTwo(long val)
Rounds up the provided value to the nearest power of two.
|
void |
releaseBytes(long size) |
void |
setLimit(long newLimit)
Set the maximum amount of memory that can be allocated in the this Accountant before failing
an allocation.
|
String |
toString() |
String |
toVerboseString()
Provide a verbose string of the current allocator state.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAllocatedMemory, getHeadroom, getInitReservation, getLimit, getPeakMemoryAllocation, isOverLimit, setLimitpublic static final String DEBUG_ALLOCATOR
public static final int DEBUG_LOG_LENGTH
public static final boolean DEBUG
protected final org.apache.arrow.memory.Accountant parent
protected final long reservation
protected BaseAllocator(BaseAllocator parentAllocator, AllocationListener listener, String name, long initReservation, long maxAllocation, RoundingPolicy roundingPolicy) throws OutOfMemoryException
parentAllocator - parent allocator. null if defining a root allocatorlistener - listener callback. Must be non-null -- use
AllocationListener.NOOP if no listener desiredname - name of this allocatorinitReservation - initial reservation. Cannot be modified after constructionmaxAllocation - limit. Allocations past the limit fail. Can be modified after
constructionOutOfMemoryExceptionpublic BufferAllocator getParentAllocator()
BufferAllocatorgetParentAllocator in interface BufferAllocatorpublic Collection<BufferAllocator> getChildAllocators()
BufferAllocatorgetChildAllocators in interface BufferAllocatorpublic static int nextPowerOfTwo(int val)
val - An integer value.public static long nextPowerOfTwo(long val)
val - A long value.public static StringBuilder indent(StringBuilder sb, int indent)
sb - StringBuilder to useindent - Indentation amountpublic static boolean isDebug()
public void assertOpen()
BufferAllocatorassertOpen in interface BufferAllocatorpublic String getName()
getName in interface BufferAllocatorpublic ArrowBuf getEmpty()
BufferAllocatorgetEmpty in interface BufferAllocatorpublic ArrowBuf buffer(int initialRequestSize)
BufferAllocatorbuffer in interface BufferAllocatorinitialRequestSize - The size in bytes.public ArrowBuf buffer(int initialRequestSize, BufferManager manager)
BufferAllocatorbuffer in interface BufferAllocatorinitialRequestSize - The size in bytes.manager - A buffer manager to manage reallocation.public ArrowByteBufAllocator getAsByteBufAllocator()
BufferAllocatorgetAsByteBufAllocator in interface BufferAllocatorpublic BufferAllocator newChildAllocator(String name, long initReservation, long maxAllocation)
BufferAllocatornewChildAllocator in interface BufferAllocatorname - the name of the allocator.initReservation - the initial space reservation (obtained from this allocator)maxAllocation - maximum amount of space the new allocator can allocatepublic BufferAllocator newChildAllocator(String name, AllocationListener listener, long initReservation, long maxAllocation)
BufferAllocatornewChildAllocator in interface BufferAllocatorname - the name of the allocator.listener - allocation listener for the newly created childinitReservation - the initial space reservation (obtained from this allocator)maxAllocation - maximum amount of space the new allocator can allocatepublic AllocationReservation newReservation()
BufferAllocatornewReservation in interface BufferAllocatorAllocationReservationpublic void close()
close in interface AutoCloseableclose in interface BufferAllocatorpublic String toVerboseString()
toVerboseString in interface BufferAllocatorpublic void releaseBytes(long size)
public boolean isOverLimit()
public long getLimit()
public long getInitReservation()
public void setLimit(long newLimit)
newLimit - The limit in bytes.public long getAllocatedMemory()
public long getPeakMemoryAllocation()
public long getHeadroom()
Copyright © 2019 The Apache Software Foundation. All rights reserved.