public interface BufferAllocator extends AutoCloseable
Modifier and Type | Method and Description |
---|---|
void |
assertOpen()
Asserts (using java assertions) that the provided allocator is currently open.
|
DrillBuf |
buffer(int size)
Allocate a new or reused buffer of the provided size.
|
DrillBuf |
buffer(int size,
BufferManager manager)
Allocate a new or reused buffer of the provided size.
|
void |
close()
Close and release all buffers generated from this buffer pool.
|
long |
getAllocatedMemory()
Returns the amount of memory currently allocated from this allocator.
|
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.
|
long |
getLimit()
Return the current maximum limit this allocator imposes.
|
String |
getName()
Return the name of this allocator.
|
long |
getPeakMemoryAllocation()
Returns the peak amount of memory allocated from this allocator.
|
boolean |
isOverLimit()
Return whether or not this allocator (or one if its parents) is over its limits.
|
BufferAllocator |
newChildAllocator(String name,
long initReservation,
long maxAllocation)
Create a new child allocator.
|
AllocationReservation |
newReservation()
Create an allocation reservation.
|
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.
|
boolean |
setLenient()
Request lenient enforcement of the allocation limits.
|
void |
setLimit(long newLimit)
Set the maximum amount of memory this allocator is allowed to allocate.
|
String |
toVerboseString()
Return a verbose string describing this allocator.
|
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.
|
DrillBuf buffer(int size)
size
- The size in bytes.OutOfMemoryException
- if buffer cannot be allocatedDrillBuf buffer(int size, BufferManager manager)
size
- The size in bytes.manager
- A buffer manager to manage reallocation.OutOfMemoryException
- if buffer cannot be allocatedio.netty.buffer.ByteBufAllocator getAsByteBufAllocator()
BufferAllocator newChildAllocator(String name, long initReservation, long maxAllocation)
name
- the name of the allocator.initReservation
- the initial space reservation (obtained from this allocator)maxAllocation
- maximum amount of space the new allocator can allocatevoid close()
When assertions are on, complains if there are any outstanding buffers; to avoid that, release all buffers before the allocator is closed.
close
in interface AutoCloseable
long getAllocatedMemory()
void setLimit(long newLimit)
newLimit
- The new Limit to apply to allocationsboolean setLenient()
long getLimit()
long getPeakMemoryAllocation()
AllocationReservation newReservation()
AllocationReservation
.DrillBuf getEmpty()
String getName()
boolean isOverLimit()
String toVerboseString()
void assertOpen()
void write(DrillBuf buf, OutputStream out) throws IOException
buf
- the Drillbuf to writeout
- the output streamIOException
- if a write error occursvoid write(DrillBuf buf, int length, OutputStream out) throws IOException
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 occursvoid read(DrillBuf buf, int length, InputStream in) throws IOException
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 occursDrillBuf read(int length, InputStream in) throws IOException
length
- number of bytes to readin
- input stream from which to read dataIOException
- if a read error occursCopyright © 1970 The Apache Software Foundation. All rights reserved.