org.apache.hadoop.hbase.io.hfile.bucket
Class CachedEntryQueue

java.lang.Object
  extended by org.apache.hadoop.hbase.io.hfile.bucket.CachedEntryQueue

@InterfaceAudience.Private
public class CachedEntryQueue
extends Object

A memory-bound queue that will grow until an element brings total size larger than 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.


Constructor Summary
CachedEntryQueue(long maxSize, long blockSize)
           
 
Method Summary
 void add(Map.Entry<BlockCacheKey,org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.BucketEntry> entry)
          Attempt to add the specified entry to this queue.
 long cacheSize()
          Total size of all elements in this queue.
 Map.Entry<BlockCacheKey,org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.BucketEntry> poll()
           
 Map.Entry<BlockCacheKey,org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.BucketEntry> pollLast()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachedEntryQueue

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

add

public void add(Map.Entry<BlockCacheKey,org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.BucketEntry> entry)
Attempt to add the specified entry to this queue.

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

Parameters:
entry - a bucket entry with key to try to add to the queue

poll

public Map.Entry<BlockCacheKey,org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.BucketEntry> poll()
Returns:
The next element in this queue, or null if the queue is empty.

pollLast

public Map.Entry<BlockCacheKey,org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.BucketEntry> pollLast()
Returns:
The last element in this queue, or null if the queue is empty.

cacheSize

public long cacheSize()
Total size of all elements in this queue.

Returns:
size of all elements currently in queue, in bytes


Copyright © 2015 The Apache Software Foundation. All rights reserved.