Class LruCachedBlockQueue

java.lang.Object
org.apache.hadoop.hbase.io.hfile.LruCachedBlockQueue
All Implemented Interfaces:
HeapSize

@Private public class LruCachedBlockQueue extends Object implements HeapSize
A memory-bound queue that will grow until an element brings total size >= maxSize. From then on, only entries that are sorted larger than the smallest current entry will be inserted/replaced.

Use this when you want to find the largest elements (according to their ordering, not their heap size) that consume as close to the specified maxSize as possible. Default behavior is to grow just above rather than just below specified max.

Object used in this queue must implement HeapSize as well as Comparable.

  • Field Details

    • queue

      private org.apache.hbase.thirdparty.com.google.common.collect.MinMaxPriorityQueue<LruCachedBlock> queue
    • heapSize

      private long heapSize
    • maxSize

      private long maxSize
  • Constructor Details

    • LruCachedBlockQueue

      public LruCachedBlockQueue(long maxSize, long blockSize)
      Parameters:
      maxSize - the target size of elements in the queue
      blockSize - expected average size of blocks
  • Method Details

    • add

      public void add(LruCachedBlock cb)
      Attempt to add the specified cached block to this queue.

      If the queue is smaller than the max size, or if the specified element is ordered before the smallest element in the queue, the element will be added to the queue. Otherwise, there is no side effect of this call.

      Parameters:
      cb - block to try to add to the queue
    • poll

      public LruCachedBlock poll()
      Returns The next element in this queue, or null if the queue is empty.
    • pollLast

      Returns The last element in this queue, or null if the queue is empty.
    • heapSize

      public long heapSize()
      Total size of all elements in this queue.
      Specified by:
      heapSize in interface HeapSize
      Returns:
      size of all elements currently in queue, in bytes