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, setLimit
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAllocatedMemory, getLimit, getPeakMemoryAllocation, isOverLimit, setLenient, setLimit
public 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
OutOfMemoryException
public void assertOpen()
BufferAllocator
assertOpen
in interface BufferAllocator
public String getName()
BufferAllocator
getName
in interface BufferAllocator
public DrillBuf getEmpty()
BufferAllocator
getEmpty
in interface BufferAllocator
public DrillBuf buffer(int initialRequestSize)
BufferAllocator
buffer
in interface BufferAllocator
initialRequestSize
- The size in bytes.public DrillBuf buffer(int initialRequestSize, BufferManager manager)
BufferAllocator
buffer
in interface BufferAllocator
initialRequestSize
- The size in bytes.manager
- A buffer manager to manage reallocation.public io.netty.buffer.ByteBufAllocator getAsByteBufAllocator()
BufferAllocator
getAsByteBufAllocator
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 AllocationReservation newReservation()
BufferAllocator
AllocationReservation
.newReservation
in interface BufferAllocator
public void close()
Accountant
close
in interface AutoCloseable
close
in interface BufferAllocator
close
in class Accountant
public String toVerboseString()
toVerboseString
in interface BufferAllocator
public 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
BufferAllocator
read
in interface BufferAllocator
buf
- 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
BufferAllocator
read
in interface BufferAllocator
length
- 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
BufferAllocator
write
in interface BufferAllocator
buf
- the Drillbuf to writeout
- the output streamIOException
- if a write error occurspublic void write(DrillBuf buf, int length, OutputStream out) throws IOException
BufferAllocator
write
in interface BufferAllocator
buf
- 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 © 1970 The Apache Software Foundation. All rights reserved.