@Override public List<LlapCacheableBuffer> getHotBuffers() {
    List<LlapCacheableBuffer> buffers = Lists.newLinkedList();
    long allocatedBytesCounter = 0;
    long[] usageStats = metrics.getUsageStats();
    long limit = Math.round((usageStats[PolicyMetrics.DATAONHEAP] + usageStats[PolicyMetrics.DATAONLIST]) * cutoff);

    LlapCacheableBuffer[] copy;
    try {
      heapLock.lock();
      copy = Arrays.copyOf(heap, heap.length);
    } finally {
      heapLock.unlock();
    }

    long t = timer.get();
    Arrays.sort(copy,
        nullsLast(comparing(b -> b.lastUpdate == t ? b.priority : expirePriority(t, b.lastUpdate, b.priority))));
    for (int i = copy.length - 1; i >= 0; i--) {
      if (copy[i] != null && !(copy[i] instanceof MetadataCache.LlapMetadataBuffer)) {
        long memoryUsage = copy[i].getMemoryUsage();
        if (allocatedBytesCounter + memoryUsage <= limit) {
          buffers.add(copy[i]);
          allocatedBytesCounter += memoryUsage;
        } else {
          return buffers;
        }
      }
    }

    try {
      listLock.lock();
      LlapCacheableBuffer scan = listHead;
      while (null != scan) {
        if (scan instanceof MetadataCache.LlapMetadataBuffer) {
          scan = scan.next;
        } else {
          long memoryUsage = scan.getMemoryUsage();
          if (allocatedBytesCounter + memoryUsage <= limit) {
            buffers.add(scan);
            allocatedBytesCounter += memoryUsage;
            scan = scan.next;
          } else {
            return buffers;
          }
        }
      }
    } finally {
      listLock.unlock();
    }

    return buffers;
  }
Moves the minimum child of targetPos block up to targetPos; optionally compares priorities
and terminates if targetPos element has lesser value than either of its children.
@return the index of the child that was moved up; -1 if nothing was moved due to absence
        of the children, or a failed priority check.
llap-server/src/java/org/apache/hadoop/hive/llap/cache/LowLevelLrfuCachePolicy.java