public class ByteBufferHashTable extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
ByteBufferHashTable.BucketUpdateHandler |
Modifier and Type | Field and Description |
---|---|
protected int |
bucketSizeWithHash |
protected ByteBufferHashTable.BucketUpdateHandler |
bucketUpdateHandler |
protected ByteBuffer |
buffer |
protected int |
growthCount |
protected static int |
HASH_SIZE |
protected int |
initialBuckets |
protected int |
keySize |
protected int |
maxBuckets |
protected float |
maxLoadFactor |
protected int |
maxSizeForTesting |
protected int |
regrowthThreshold |
protected int |
size |
protected int |
tableArenaSize |
protected ByteBuffer |
tableBuffer |
protected int |
tableStart |
Constructor and Description |
---|
ByteBufferHashTable(float maxLoadFactor,
int initialBuckets,
int bucketSizeWithHash,
ByteBuffer buffer,
int keySize,
int maxSizeForTesting,
ByteBufferHashTable.BucketUpdateHandler bucketUpdateHandler) |
Modifier and Type | Method and Description |
---|---|
void |
adjustTableWhenFull() |
static int |
calculateTableArenaSizeWithFixedAdditionalSize(int bufferCapacity,
int bucketSize,
int fixedAdditionalSize) |
static int |
calculateTableArenaSizeWithPerBucketAdditionalSize(int bufferCapacity,
int bucketSize,
int perBucketAdditionalSize) |
protected boolean |
canAllowNewBucket() |
protected int |
findBucket(boolean allowNewBucket,
int buckets,
ByteBuffer targetTableBuffer,
ByteBuffer keyBuffer,
int keyHash)
Finds the bucket into which we should insert a key.
|
protected int |
findBucketWithAutoGrowth(ByteBuffer keyBuffer,
int keyHash)
Find a bucket for a key, attempting to resize the table with adjustTableWhenFull() if possible.
|
int |
getGrowthCount() |
int |
getMaxBuckets() |
protected int |
getOffsetForBucket(int bucket) |
int |
getRegrowthThreshold() |
int |
getSize() |
ByteBuffer |
getTableBuffer() |
protected void |
initializeNewBucketKey(int bucket,
ByteBuffer keyBuffer,
int keyHash) |
protected boolean |
isBucketUsed(int bucket) |
protected boolean |
isOffsetUsed(int bucketOffset) |
protected int |
maxSizeForBuckets(int buckets) |
void |
reset() |
protected final int maxSizeForTesting
protected static final int HASH_SIZE
protected final float maxLoadFactor
protected final int initialBuckets
protected final ByteBuffer buffer
protected final int bucketSizeWithHash
protected final int tableArenaSize
protected final int keySize
protected int tableStart
protected ByteBuffer tableBuffer
protected int size
protected int regrowthThreshold
protected int maxBuckets
protected int growthCount
protected ByteBufferHashTable.BucketUpdateHandler bucketUpdateHandler
public ByteBufferHashTable(float maxLoadFactor, int initialBuckets, int bucketSizeWithHash, ByteBuffer buffer, int keySize, int maxSizeForTesting, ByteBufferHashTable.BucketUpdateHandler bucketUpdateHandler)
public static int calculateTableArenaSizeWithPerBucketAdditionalSize(int bufferCapacity, int bucketSize, int perBucketAdditionalSize)
public static int calculateTableArenaSizeWithFixedAdditionalSize(int bufferCapacity, int bucketSize, int fixedAdditionalSize)
public void reset()
public void adjustTableWhenFull()
protected void initializeNewBucketKey(int bucket, ByteBuffer keyBuffer, int keyHash)
protected int findBucketWithAutoGrowth(ByteBuffer keyBuffer, int keyHash)
keyBuffer
- buffer containing the keykeyHash
- hash of the keyprotected int findBucket(boolean allowNewBucket, int buckets, ByteBuffer targetTableBuffer, ByteBuffer keyBuffer, int keyHash)
keyBuffer
- key, must have exactly keySize bytes remaining. Will not be modified.targetTableBuffer
- Need selectable buffer, since when resizing hash table,
findBucket() is used on the newly allocated table bufferprotected boolean canAllowNewBucket()
protected int getOffsetForBucket(int bucket)
protected int maxSizeForBuckets(int buckets)
protected boolean isBucketUsed(int bucket)
protected boolean isOffsetUsed(int bucketOffset)
public ByteBuffer getTableBuffer()
public int getSize()
public int getRegrowthThreshold()
public int getMaxBuckets()
public int getGrowthCount()
Copyright © 2011–2018 The Apache Software Foundation. All rights reserved.