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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(int nBytes) Add to the current reservation.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.
-
Constructor Details
-
Reservation
public Reservation()
-
-
Method Details
-
add
public boolean add(int nBytes) Description copied from interface:AllocationReservation
Add to the current reservation.Adding may fail if the allocator is not allowed to consume any more space.
- Specified by:
add
in interfaceAllocationReservation
- Parameters:
nBytes
- the number of bytes to add- Returns:
- true if the addition is possible, false otherwise
-
allocateBuffer
Description copied from interface:AllocationReservation
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.
- Specified by:
allocateBuffer
in interfaceAllocationReservation
- Returns:
- the buffer, or null, if the request cannot be satisfied
-
getSize
public int getSize()Description copied from interface:AllocationReservation
Get the current size of the reservation (the sum of all the add()s).- Specified by:
getSize
in interfaceAllocationReservation
- Returns:
- size of the current reservation
-
isUsed
public boolean isUsed()Description copied from interface:AllocationReservation
Return whether or not the reservation has been used.- Specified by:
isUsed
in interfaceAllocationReservation
- Returns:
- whether or not the reservation has been used
-
isClosed
public boolean isClosed()Description copied from interface:AllocationReservation
Return whether or not the reservation has been closed.- Specified by:
isClosed
in interfaceAllocationReservation
- Returns:
- whether or not the reservation has been closed
-
close
public void close()- Specified by:
close
in interfaceAllocationReservation
- Specified by:
close
in interfaceAutoCloseable
-
reserve
public boolean reserve(int nBytes) Description copied from interface:AllocationReservation
Requests a reservation of additional space.The implementation of the allocator's inner class provides this.
- Specified by:
reserve
in interfaceAllocationReservation
- Parameters:
nBytes
- the amount to reserve- Returns:
- true if the reservation can be satisfied, false otherwise
-