Interface BufferManager

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
BufferManagerImpl

public interface BufferManager extends AutoCloseable
Manages a list of DrillBufs that can be reallocated as needed. Upon re-allocation the old buffer will be freed. Managing a list of these buffers prevents some parts of the system from needing to define a correct location to place the final call to free them. The current uses of these types of buffers are within the pluggable components of Drill. In UDFs, memory management should not be a concern. We provide access to re-allocatable DrillBufs to give UDF writers general purpose buffers we can account for. To prevent the need for UDFs to contain boilerplate to close all of the buffers they request, this list is tracked at a higher level and all of the buffers are freed once we are sure that the code depending on them is done executing (currently FragmentContext and QueryContext.
  • Method Details

    • replace

      DrillBuf replace(DrillBuf old, int newSize)
      Replace an old buffer with a new version at least of the provided size. Does not copy data.
      Parameters:
      old - Old Buffer that the user is no longer going to use.
      newSize - Size of new replacement buffer.
      Returns:
    • getManagedBuffer

      DrillBuf getManagedBuffer()
      Get a managed buffer of indeterminate size.
      Returns:
      A buffer.
    • getManagedBuffer

      DrillBuf getManagedBuffer(int size)
      Get a managed buffer of at least a certain size.
      Parameters:
      size - The desired size
      Returns:
      A buffer
    • getAllocator

      BufferAllocator getAllocator()
    • close

      void close()
      Specified by:
      close in interface AutoCloseable