Class BaseAllocator.Reservation

java.lang.Object
org.apache.drill.exec.memory.BaseAllocator.Reservation
All Implemented Interfaces:
AutoCloseable, AllocationReservation
Enclosing class:
BaseAllocator

public class BaseAllocator.Reservation extends Object implements AllocationReservation
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(int nBytes)
    Add to the current reservation.
    Allocate a buffer whose size is the total of all the add()s made.
    void
     
    int
    Get the current size of the reservation (the sum of all the add()s).
    boolean
    Return whether or not the reservation has been closed.
    boolean
    Return whether or not the reservation has been used.
    boolean
    reserve(int nBytes)
    Requests a reservation of additional space.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 interface AllocationReservation
      Parameters:
      nBytes - the number of bytes to add
      Returns:
      true if the addition is possible, false otherwise
    • allocateBuffer

      public DrillBuf 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 interface AllocationReservation
      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 interface AllocationReservation
      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 interface AllocationReservation
      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 interface AllocationReservation
      Returns:
      whether or not the reservation has been closed
    • close

      public void close()
      Specified by:
      close in interface AllocationReservation
      Specified by:
      close in interface AutoCloseable
    • 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 interface AllocationReservation
      Parameters:
      nBytes - the amount to reserve
      Returns:
      true if the reservation can be satisfied, false otherwise