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

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

@InterfaceAudience.Private
public final class BucketAllocator
extends Object

This class is used to allocate a block with specified size and free the block when evicting. It manages an array of buckets, each bucket is associated with a size and caches elements up to this size. For completely empty bucket, this size could be re-specified dynamically. This class is not thread safe.


Field Summary
static int FEWEST_ITEMS_IN_BUCKET
           
 
Method Summary
 long allocateBlock(int blockSize)
          Allocate a block with specified size.
 void dumpToLog()
           
 int freeBlock(long offset)
          Free a block with the offset
 long freeBlock(long[] freeList)
           
 long getFreeSize()
           
 org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocator.IndexStatistics[] getIndexStatistics()
           
 org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocator.IndexStatistics[] getIndexStatistics(org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocator.IndexStatistics grandTotal)
           
 String getInfo()
           
static int getMaximumAllocationIndex()
           
 long getTotalSize()
           
 long getUsedSize()
           
 void logStatistics()
           
 org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocator.BucketSizeInfo roundUpToBucketSizeInfo(int blockSize)
          Round up the given block size to bucket size, and get the corresponding BucketSizeInfo
 int sizeIndexOfAllocation(long offset)
           
 int sizeOfAllocation(long offset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FEWEST_ITEMS_IN_BUCKET

public static final int FEWEST_ITEMS_IN_BUCKET
See Also:
Constant Field Values
Method Detail

roundUpToBucketSizeInfo

public org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocator.BucketSizeInfo roundUpToBucketSizeInfo(int blockSize)
Round up the given block size to bucket size, and get the corresponding BucketSizeInfo

Parameters:
blockSize -
Returns:
BucketSizeInfo

getInfo

public String getInfo()

getUsedSize

public long getUsedSize()

getFreeSize

public long getFreeSize()

getTotalSize

public long getTotalSize()

allocateBlock

public long allocateBlock(int blockSize)
                   throws CacheFullException,
                          BucketAllocatorException
Allocate a block with specified size. Return the offset

Parameters:
blockSize - size of block
Returns:
the offset in the IOEngine
Throws:
BucketAllocatorException,CacheFullException
CacheFullException
BucketAllocatorException

freeBlock

public int freeBlock(long offset)
Free a block with the offset

Parameters:
offset - block's offset
Returns:
size freed

sizeIndexOfAllocation

public int sizeIndexOfAllocation(long offset)

sizeOfAllocation

public int sizeOfAllocation(long offset)

getMaximumAllocationIndex

public static int getMaximumAllocationIndex()

dumpToLog

public void dumpToLog()

logStatistics

public void logStatistics()

getIndexStatistics

public org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocator.IndexStatistics[] getIndexStatistics(org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocator.IndexStatistics grandTotal)

getIndexStatistics

public org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocator.IndexStatistics[] getIndexStatistics()

freeBlock

public long freeBlock(long[] freeList)


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.