- All Superinterfaces:
AutoCloseable
Supports cumulative allocation reservation. Clients may increase the size of the reservation
repeatedly until they call for an allocation of the current total size. The reservation can only
be used once, and will throw an exception if it is used more than once.
For the purposes of airtight memory accounting, the reservation must be close()d whether it is used or not. This is not threadsafe.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int nBytes) Deprecated, for removal: This API element is subject to removal in a future version.booleanadd(long nBytes) Add to the current reservation.Allocate a buffer whose size is the total of all the add()s made.voidclose()intgetSize()Get the current size of the reservation (the sum of all the add()s).longGet the current size of the reservation (the sum of all the add()s) as a long value.booleanisClosed()Return whether or not the reservation has been closed.booleanisUsed()Return whether or not the reservation has been used.booleanreserve(int nBytes) Deprecated, for removal: This API element is subject to removal in a future version.usereserve(long)insteadbooleanreserve(long nBytes) Requests a reservation of additional space.
-
Method Details
-
add
Deprecated, for removal: This API element is subject to removal in a future version.useadd(long)insteadAdd to the current reservation.Adding may fail if the allocator is not allowed to consume any more space.
- Parameters:
nBytes- the number of bytes to add- Returns:
- true if the addition is possible, false otherwise
- Throws:
IllegalStateException- if called after buffer() is used to allocate the reservation
-
add
boolean add(long nBytes) Add to the current reservation.Adding may fail if the allocator is not allowed to consume any more space.
- Parameters:
nBytes- the number of bytes to add- Returns:
- true if the addition is possible, false otherwise
- Throws:
IllegalStateException- if called after buffer() is used to allocate the reservation
-
reserve
Deprecated, for removal: This API element is subject to removal in a future version.usereserve(long)insteadRequests a reservation of additional space.The implementation of the allocator's inner class provides this.
- Parameters:
nBytes- the amount to reserve- Returns:
- true if the reservation can be satisfied, false otherwise
-
reserve
boolean reserve(long nBytes) Requests a reservation of additional space.The implementation of the allocator's inner class provides this.
- Parameters:
nBytes- the amount to reserve- Returns:
- true if the reservation can be satisfied, false otherwise
-
allocateBuffer
ArrowBuf allocateBuffer()Allocate a buffer whose size is the total of all the add()s made.The allocation request can still fail, even if the amount of space requested is available, if the allocation cannot be made contiguously.
- Returns:
- the buffer, or null, if the request cannot be satisfied
- Throws:
IllegalStateException- if called more than once
-
getSize
int getSize()Get the current size of the reservation (the sum of all the add()s).- Returns:
- size of the current reservation
-
getSizeLong
long getSizeLong()Get the current size of the reservation (the sum of all the add()s) as a long value.- Returns:
- size of the current reservation
-
isUsed
boolean isUsed()Return whether or not the reservation has been used.- Returns:
- whether or not the reservation has been used
-
isClosed
boolean isClosed()Return whether or not the reservation has been closed.- Returns:
- whether or not the reservation has been closed
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-
add(long)instead