Package io.trino.memory.context
Class ValidatingLocalMemoryContext
java.lang.Object
io.trino.memory.context.ValidatingLocalMemoryContext
- All Implemented Interfaces:
LocalMemoryContext
-
Constructor Summary
ConstructorsConstructorDescriptionValidatingLocalMemoryContext(LocalMemoryContext delegate, String allocationTag, MemoryAllocationValidator memoryValidator) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this LocalMemoryContext.longgetBytes()com.google.common.util.concurrent.ListenableFuture<Void>setBytes(long bytes) When this method returns, the bytes tracked by this LocalMemoryContext has been updated.booleantrySetBytes(long bytes) This method can return false when there is not enough memory available to satisfy a positive delta allocation (bytesis greater than the bytes tracked by this LocalMemoryContext).
-
Constructor Details
-
ValidatingLocalMemoryContext
public ValidatingLocalMemoryContext(LocalMemoryContext delegate, String allocationTag, MemoryAllocationValidator memoryValidator)
-
-
Method Details
-
getBytes
public long getBytes()- Specified by:
getBytesin interfaceLocalMemoryContext
-
setBytes
Description copied from interface:LocalMemoryContextWhen 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:
setBytesin interfaceLocalMemoryContext
-
trySetBytes
public boolean trySetBytes(long bytes) Description copied from interface:LocalMemoryContextThis method can return false when there is not enough memory available to satisfy a positive delta allocation (bytesis greater than the bytes tracked by this LocalMemoryContext).- Specified by:
trySetBytesin interfaceLocalMemoryContext- Returns:
- true if the bytes tracked by this LocalMemoryContext can be set to
bytes.
-
close
public void close()Description copied from interface:LocalMemoryContextCloses this LocalMemoryContext. Once closed the bytes tracked by this LocalMemoryContext will be set to 0, and none of its methods (exceptgetBytes()) can be called.- Specified by:
closein interfaceLocalMemoryContext
-