Class MemoryPool


  • public class MemoryPool
    extends java.lang.Object
    A thread-safe memory pool.
    • Constructor Summary

      Constructors 
      Constructor Description
      MemoryPool​(java.lang.String id, long maxBytes, long maxBytesPerQuery)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void free​(java.lang.String queryId, long bytes)  
      java.lang.String getId()  
      long getMaxBytes()  
      long getQueryMemoryReservedBytes​(java.lang.String queryId)  
      long getReservedBytes()  
      org.apache.iotdb.tsfile.utils.Pair<com.google.common.util.concurrent.ListenableFuture<java.lang.Void>,​java.lang.Boolean> reserve​(java.lang.String queryId, long bytes)  
      long tryCancel​(com.google.common.util.concurrent.ListenableFuture<java.lang.Void> future)
      Cancel the specified memory reservation.
      long tryComplete​(com.google.common.util.concurrent.ListenableFuture<java.lang.Void> future)
      Complete the specified memory reservation.
      boolean tryReserve​(java.lang.String queryId, long bytes)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MemoryPool

        public MemoryPool​(java.lang.String id,
                          long maxBytes,
                          long maxBytesPerQuery)
    • Method Detail

      • getId

        public java.lang.String getId()
      • getMaxBytes

        public long getMaxBytes()
      • reserve

        public org.apache.iotdb.tsfile.utils.Pair<com.google.common.util.concurrent.ListenableFuture<java.lang.Void>,​java.lang.Boolean> reserve​(java.lang.String queryId,
                                                                                                                                                      long bytes)
        Returns:
        if reserve succeed, pair.right will be true, otherwise false
      • tryReserve

        public boolean tryReserve​(java.lang.String queryId,
                                  long bytes)
      • tryCancel

        public long tryCancel​(com.google.common.util.concurrent.ListenableFuture<java.lang.Void> future)
        Cancel the specified memory reservation. If the reservation has finished, do nothing.
        Parameters:
        future - The future returned from reserve(String, long)
        Returns:
        If the future has not complete, return the number of bytes being reserved. Otherwise, return 0.
      • tryComplete

        public long tryComplete​(com.google.common.util.concurrent.ListenableFuture<java.lang.Void> future)
        Complete the specified memory reservation. If the reservation has finished, do nothing.
        Parameters:
        future - The future returned from reserve(String, long)
        Returns:
        If the future has not complete, return the number of bytes being reserved. Otherwise, return 0.
      • free

        public void free​(java.lang.String queryId,
                         long bytes)
      • getQueryMemoryReservedBytes

        public long getQueryMemoryReservedBytes​(java.lang.String queryId)
      • getReservedBytes

        public long getReservedBytes()