Interface LocalMemoryContext

All Known Implementing Classes:
SimpleLocalMemoryContext

public interface LocalMemoryContext
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes this LocalMemoryContext.
    long
     
    com.google.common.util.concurrent.ListenableFuture<Void>
    setBytes(long bytes)
    When this method returns, the bytes tracked by this LocalMemoryContext has been updated.
    boolean
    trySetBytes(long bytes)
    This method can return false when there is not enough memory available to satisfy a positive delta allocation (bytes is greater than the bytes tracked by this LocalMemoryContext).
  • Method Details

    • getBytes

      long getBytes()
    • setBytes

      com.google.common.util.concurrent.ListenableFuture<Void> setBytes(long bytes)
      When this method returns, the bytes tracked by this LocalMemoryContext has been updated. The returned future will tell the caller whether it should block before reserving more memory (which happens when the memory pools are low on memory).

      Note: Canceling the returned future will complete it immediately even though the memory pools are low on memory, and callers blocked on this future will proceed to allocating more memory from the exhausted pools, which will violate the protocol of Trino MemoryPool implementation.

    • trySetBytes

      boolean trySetBytes(long bytes)
      This method can return false when there is not enough memory available to satisfy a positive delta allocation (bytes is greater than the bytes tracked by this LocalMemoryContext).

      Returns:
      true if the bytes tracked by this LocalMemoryContext can be set to bytes.
    • close

      void close()
      Closes this LocalMemoryContext. Once closed the bytes tracked by this LocalMemoryContext will be set to 0, and none of its methods (except getBytes()) can be called.