public interface AllocationReservation extends AutoCloseable
For the purposes of airtight memory accounting, the reservation must be close()d whether it is used or not. This is not threadsafe.
Modifier and Type | Method and Description |
---|---|
boolean |
add(int nBytes)
Add to the current reservation.
|
ArrowBuf |
allocateBuffer()
Allocate a buffer whose size is the total of all the add()s made.
|
void |
close() |
int |
getSize()
Get the current size of the reservation (the sum of all the add()s).
|
boolean |
isClosed()
Return whether or not the reservation has been closed.
|
boolean |
isUsed()
Return whether or not the reservation has been used.
|
boolean |
reserve(int nBytes)
Requests a reservation of additional space.
|
boolean add(int nBytes)
Adding may fail if the allocator is not allowed to consume any more space.
nBytes
- the number of bytes to addIllegalStateException
- if called after buffer() is used to allocate the reservationboolean reserve(int nBytes)
The implementation of the allocator's inner class provides this.
nBytes
- the amount to reserveArrowBuf allocateBuffer()
The allocation request can still fail, even if the amount of space requested is available, if the allocation cannot be made contiguously.
IllegalStateException
- if called called more than onceint getSize()
boolean isUsed()
boolean isClosed()
void close()
close
in interface AutoCloseable
Copyright © 2023 The Apache Software Foundation. All rights reserved.