Package org.apache.drill.exec.memory
Class BaseAllocator.Reservation
java.lang.Object
org.apache.drill.exec.memory.BaseAllocator.Reservation
- All Implemented Interfaces:
AutoCloseable,AllocationReservation
- Enclosing class:
BaseAllocator
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int 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).booleanisClosed()Return whether or not the reservation has been closed.booleanisUsed()Return whether or not the reservation has been used.booleanreserve(int nBytes) Requests a reservation of additional space.
-
Constructor Details
-
Reservation
public Reservation()
-
-
Method Details
-
add
public boolean add(int nBytes) Description copied from interface:AllocationReservationAdd to the current reservation.Adding may fail if the allocator is not allowed to consume any more space.
- Specified by:
addin interfaceAllocationReservation- Parameters:
nBytes- the number of bytes to add- Returns:
- true if the addition is possible, false otherwise
-
allocateBuffer
Description copied from interface:AllocationReservationAllocate 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.
- Specified by:
allocateBufferin interfaceAllocationReservation- Returns:
- the buffer, or null, if the request cannot be satisfied
-
getSize
public int getSize()Description copied from interface:AllocationReservationGet the current size of the reservation (the sum of all the add()s).- Specified by:
getSizein interfaceAllocationReservation- Returns:
- size of the current reservation
-
isUsed
public boolean isUsed()Description copied from interface:AllocationReservationReturn whether or not the reservation has been used.- Specified by:
isUsedin interfaceAllocationReservation- Returns:
- whether or not the reservation has been used
-
isClosed
public boolean isClosed()Description copied from interface:AllocationReservationReturn whether or not the reservation has been closed.- Specified by:
isClosedin interfaceAllocationReservation- Returns:
- whether or not the reservation has been closed
-
close
public void close()- Specified by:
closein interfaceAllocationReservation- Specified by:
closein interfaceAutoCloseable
-
reserve
public boolean reserve(int nBytes) Description copied from interface:AllocationReservationRequests a reservation of additional space.The implementation of the allocator's inner class provides this.
- Specified by:
reservein interfaceAllocationReservation- Parameters:
nBytes- the amount to reserve- Returns:
- true if the reservation can be satisfied, false otherwise
-