public abstract class BaseAllocator extends Accountant implements BufferAllocator
| Modifier and Type | Class and Description |
|---|---|
class |
BaseAllocator.Reservation |
static class |
BaseAllocator.Verbosity |
Accountant.AllocationOutcome| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
static String |
DEBUG_ALLOCATOR |
static int |
DEBUG_LOG_LENGTH |
ALLOW_LENIENCY, ALLOW_LENIENT_ALLOCATION, GRACE_MARGIN, MAX_GRACE, parent, reservation| Modifier | Constructor and Description |
|---|---|
protected |
BaseAllocator(BaseAllocator parentAllocator,
String name,
long initReservation,
long maxAllocation) |
| Modifier and Type | Method and Description |
|---|---|
void |
assertOpen()
Asserts (using java assertions) that the provided allocator is currently open.
|
DrillBuf |
buffer(int initialRequestSize)
Allocate a new or reused buffer of the provided size.
|
DrillBuf |
buffer(int initialRequestSize,
BufferManager manager)
Allocate a new or reused buffer of the provided size.
|
void |
close()
Close this Accountant.
|
io.netty.buffer.ByteBufAllocator |
getAsByteBufAllocator()
Returns the allocator this allocator falls back to when it needs more memory.
|
DrillBuf |
getEmpty()
Get a reference to the empty buffer associated with this allocator.
|
byte[] |
getIOBuffer() |
String |
getName()
Return the name of this allocator.
|
static StringBuilder |
indent(StringBuilder sb,
int indent) |
static boolean |
isDebug() |
static long |
longNextPowerOfTwo(long val)
Rounds up the provided value to the nearest power of two.
|
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.
|
void |
read(DrillBuf buf,
int length,
InputStream in)
Read the contents of a DrillBuf from a stream.
|
DrillBuf |
read(int length,
InputStream in)
Reads the specified number of bytes into a new Drillbuf.
|
String |
toString() |
String |
toVerboseString()
Provide a verbose string of the current allocator state.
|
void |
write(DrillBuf buf,
int length,
OutputStream out)
Write the contents of a DrillBuf to a stream.
|
void |
write(DrillBuf buf,
OutputStream out)
Write the contents of a DrillBuf to a stream.
|
forceLenient, getAllocatedMemory, getLimit, getPeakMemoryAllocation, isOverLimit, releaseBytes, setLenient, setLimitclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAllocatedMemory, getLimit, getPeakMemoryAllocation, isOverLimit, setLenient, setLimitpublic static final String DEBUG_ALLOCATOR
public static final int DEBUG_LOG_LENGTH
public static final boolean DEBUG
protected BaseAllocator(BaseAllocator parentAllocator, String name, long initReservation, long maxAllocation) throws OutOfMemoryException
OutOfMemoryExceptionpublic void assertOpen()
BufferAllocatorassertOpen in interface BufferAllocatorpublic String getName()
BufferAllocatorgetName in interface BufferAllocatorpublic DrillBuf getEmpty()
BufferAllocatorgetEmpty in interface BufferAllocatorpublic DrillBuf buffer(int initialRequestSize)
BufferAllocatorbuffer in interface BufferAllocatorinitialRequestSize - The size in bytes.public DrillBuf buffer(int initialRequestSize, BufferManager manager)
BufferAllocatorbuffer in interface BufferAllocatorinitialRequestSize - The size in bytes.manager - A buffer manager to manage reallocation.public io.netty.buffer.ByteBufAllocator 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 AllocationReservation newReservation()
BufferAllocatorAllocationReservation.newReservation in interface BufferAllocatorpublic void close()
Accountantclose in interface AutoCloseableclose in interface BufferAllocatorclose in class Accountantpublic String toVerboseString()
toVerboseString in interface BufferAllocatorpublic static int nextPowerOfTwo(int val)
val - An integer value.public static long longNextPowerOfTwo(long val)
val - An integer long value.public static StringBuilder indent(StringBuilder sb, int indent)
public static boolean isDebug()
public byte[] getIOBuffer()
public void read(DrillBuf buf, int length, InputStream in) throws IOException
BufferAllocatorread in interface BufferAllocatorbuf - the buffer to read with space already allocatedlength - number of bytes to readin - input stream from which to read dataIOException - if a read error occurspublic DrillBuf read(int length, InputStream in) throws IOException
BufferAllocatorread in interface BufferAllocatorlength - number of bytes to readin - input stream from which to read dataIOException - if a read error occurspublic void write(DrillBuf buf, OutputStream out) throws IOException
BufferAllocatorwrite in interface BufferAllocatorbuf - the Drillbuf to writeout - the output streamIOException - if a write error occurspublic void write(DrillBuf buf, int length, OutputStream out) throws IOException
BufferAllocatorwrite in interface BufferAllocatorbuf - the Drillbuf to writelength - the number of bytes to read. Must be less than or
equal to number of bytes allocated in the buffer.out - the output streamIOException - if a write error occursCopyright © 2021 The Apache Software Foundation. All rights reserved.