public class RootAllocator extends Object
Modifier and Type | Class and Description |
---|---|
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 |
static org.apache.arrow.memory.BaseAllocator.Config |
DEFAULT_CONFIG |
protected org.apache.arrow.memory.Accountant |
parent
The parent allocator.
|
protected long |
reservation
The amount of memory reserved for this allocator.
|
Constructor and Description |
---|
RootAllocator() |
RootAllocator(AllocationListener listener,
long limit) |
RootAllocator(AllocationListener listener,
long limit,
RoundingPolicy roundingPolicy)
Constructor.
|
RootAllocator(org.apache.arrow.memory.BaseAllocator.Config config) |
RootAllocator(long limit) |
Modifier and Type | Method and Description |
---|---|
void |
assertOpen()
Asserts (using java assertions) that the provided allocator is currently open.
|
ArrowBuf |
buffer(long initialRequestSize)
Allocate a new or reused buffer of the provided size.
|
ArrowBuf |
buffer(long initialRequestSize,
BufferManager manager)
Allocate a new or reused buffer of the provided size.
|
void |
close()
Close this Accountant.
|
static ImmutableConfig.Builder |
configBuilder()
Returns a builder class for configuring BaseAllocator's options.
|
static org.apache.arrow.memory.BaseAllocator.Config |
defaultConfig()
Returns a default
Config instance. |
boolean |
forceAllocate(long size)
Increase the accounting.
|
long |
getAllocatedMemory()
Return the current amount of allocated memory that this Accountant is managing accounting
for.
|
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.
|
AllocationListener |
getListener()
Returns the allocation listener used by this allocator.
|
String |
getName()
Return the name of the accountant.
|
org.apache.arrow.memory.BaseAllocator |
getParentAllocator()
Returns the parent allocator.
|
long |
getPeakMemoryAllocation()
The peak memory allocated by this Accountant.
|
BufferAllocator |
getRoot()
Get the root allocator of this allocator.
|
RoundingPolicy |
getRoundingPolicy()
Gets the rounding policy of the allocator.
|
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.
|
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.
|
void |
verify()
Verify the accounting state of the allocation system.
|
ArrowBuf |
wrapForeignAllocation(ForeignAllocation allocation)
EXPERIMENTAL: Wrap an allocation created outside this BufferAllocator.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forceAllocate, getAllocatedMemory, getHeadroom, getInitReservation, getLimit, getPeakMemoryAllocation, isOverLimit, releaseBytes, setLimit
public static final String DEBUG_ALLOCATOR
public static final int DEBUG_LOG_LENGTH
public static final boolean DEBUG
public static final org.apache.arrow.memory.BaseAllocator.Config DEFAULT_CONFIG
protected final org.apache.arrow.memory.Accountant parent
protected final long reservation
public RootAllocator()
public RootAllocator(long limit)
public RootAllocator(AllocationListener listener, long limit)
public RootAllocator(AllocationListener listener, long limit, RoundingPolicy roundingPolicy)
listener
- the allocation listenerlimit
- max allocation size in bytesroundingPolicy
- the policy for rounding the buffer sizepublic RootAllocator(org.apache.arrow.memory.BaseAllocator.Config config)
public void verify()
public AllocationListener getListener()
BufferAllocator
getListener
in interface BufferAllocator
AllocationListener
instance. Or AllocationListener.NOOP
by default if no listener
is configured when this allocator was created.public org.apache.arrow.memory.BaseAllocator getParentAllocator()
BufferAllocator
getParentAllocator
in interface BufferAllocator
public Collection<BufferAllocator> getChildAllocators()
BufferAllocator
getChildAllocators
in interface BufferAllocator
public static boolean isDebug()
public void assertOpen()
BufferAllocator
assertOpen
in interface BufferAllocator
public String getName()
getName
in interface BufferAllocator
public ArrowBuf getEmpty()
BufferAllocator
getEmpty
in interface BufferAllocator
public ArrowBuf wrapForeignAllocation(ForeignAllocation allocation)
BufferAllocator
This is useful to integrate allocations from native code into the same memory management framework as Java-allocated buffers, presenting users a consistent API. The created buffer will be tracked by this allocator and can be transferred like Java-allocated buffers.
The underlying allocation will be closed when all references to the buffer are released. If this method throws, the underlying allocation will also be closed.
wrapForeignAllocation
in interface BufferAllocator
allocation
- The underlying allocation.public ArrowBuf buffer(long initialRequestSize)
BufferAllocator
buffer
in interface BufferAllocator
initialRequestSize
- The size in bytes.public ArrowBuf buffer(long initialRequestSize, BufferManager manager)
BufferAllocator
buffer
in interface BufferAllocator
initialRequestSize
- The size in bytes.manager
- A buffer manager to manage reallocation.public BufferAllocator getRoot()
BufferAllocator
getRoot
in interface BufferAllocator
public BufferAllocator newChildAllocator(String name, long initReservation, long maxAllocation)
BufferAllocator
newChildAllocator
in interface BufferAllocator
name
- 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)
BufferAllocator
newChildAllocator
in interface BufferAllocator
name
- 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()
BufferAllocator
newReservation
in interface BufferAllocator
AllocationReservation
public void close()
close
in interface AutoCloseable
close
in interface BufferAllocator
public String toVerboseString()
toVerboseString
in interface BufferAllocator
public static org.apache.arrow.memory.BaseAllocator.Config defaultConfig()
Config
instance.ImmutableConfig.Builder
public static ImmutableConfig.Builder configBuilder()
public RoundingPolicy getRoundingPolicy()
BufferAllocator
getRoundingPolicy
in interface BufferAllocator
public boolean forceAllocate(long size)
size
- to increasepublic 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 © 2023 The Apache Software Foundation. All rights reserved.