Class SimpleLocalMemoryContext

java.lang.Object
io.trino.memory.context.SimpleLocalMemoryContext
All Implemented Interfaces:
LocalMemoryContext

@ThreadSafe public final class SimpleLocalMemoryContext extends Object implements LocalMemoryContext
  • Constructor Details

  • Method Details

    • getBytes

      public long getBytes()
      Specified by:
      getBytes in interface LocalMemoryContext
    • setBytes

      public com.google.common.util.concurrent.ListenableFuture<Void> setBytes(long bytes)
      Description copied from interface: LocalMemoryContext
      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.

      Specified by:
      setBytes in interface LocalMemoryContext
    • trySetBytes

      public boolean trySetBytes(long bytes)
      Description copied from interface: LocalMemoryContext
      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).

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

      public void close()
      Description copied from interface: LocalMemoryContext
      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.
      Specified by:
      close in interface LocalMemoryContext
    • toString

      public String toString()
      Overrides:
      toString in class Object