@edu.umd.cs.findbugs.annotations.SuppressWarnings(
      value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE",
      justification = "head can not be null as heapSize is greater than maxSize,"
        + " which means we have something in the queue")
  public void add(LruCachedBlock cb) {
    if (heapSize < maxSize) {
      queue.add(cb);
      heapSize += cb.heapSize();
    } else {
      LruCachedBlock head = queue.peek();
      if (cb.compareTo(head) > 0) {
        heapSize += cb.heapSize();
        heapSize -= head.heapSize();
        if (heapSize > maxSize) {
          queue.poll();
        } else {
          heapSize += head.heapSize();
        }
        queue.add(cb);
      }
    }
  }
Attempt to add the specified cached block to this queue.
<p>
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.
@param cb block to try to add to the queue
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruCachedBlockQueue.java