public class BucketDistribution extends Object
Modifier and Type | Field and Description |
---|---|
private int[] |
bucketToColumn |
private static Logger |
log |
private int |
numBucketBits |
private int |
numColumns |
Constructor and Description |
---|
BucketDistribution(BucketDistribution other)
Constructs a new bucket distribution object as a copy of another.
|
BucketDistribution(int numColumns,
int numBucketBits)
Constructs a new bucket distribution object with a given number of columns and buckets.
|
Modifier and Type | Method and Description |
---|---|
private void |
addColumn()
Adds a single column to this bucket distribution object.
|
private static List<Integer> |
getBucketCount(int numColumns,
int numBucketBits)
This method returns a list that contains the distributions of the given number of buckets over the given number
of columns.
|
private static List<Integer> |
getBucketMigrateCount(int numColumns,
int numBucketBits)
This method returns a list similar to
getBucketCount(int, int) , except that the returned list
contains the number of buckets that will have to be migrated from each column if an additional column was added. |
int |
getColumn(BucketId bucketId)
This method maps the given bucket id to its corresponding column.
|
int |
getNumBucketBits()
Returns the number of bits used for bucket identifiers.
|
int |
getNumBuckets()
Returns the number of buckets available using the configured number of bucket bits.
|
private static int |
getNumBuckets(int numBucketBits)
Returns the number of buckets that the given number of bucket bits will allow.
|
int |
getNumColumns()
Returns the number of columns to distribute to.
|
void |
reset()
Sets the number of columns to distribute to to 1, and resets the content of the internal bucket-to-column map so
that it all buckets point to that single column.
|
void |
setNumBucketBits(int numBucketBits)
Sets the number of buckets to use for this document distribution object.
|
void |
setNumColumns(int numColumns)
Sets the number of columns to use for this document distribution object.
|
private static Logger log
private int[] bucketToColumn
private int numColumns
private int numBucketBits
public BucketDistribution(int numColumns, int numBucketBits)
numColumns
- The number of columns to distribute to.numBucketBits
- The number of bits to use for bucket id.public BucketDistribution(BucketDistribution other)
other
- The distribution object to copy.private static int getNumBuckets(int numBucketBits)
numBucketBits
- The number of bits to use for bucket id.private static List<Integer> getBucketCount(int numColumns, int numBucketBits)
numColumns
- The number of columns to distribute to.numBucketBits
- The number of bits to use for bucket id.private static List<Integer> getBucketMigrateCount(int numColumns, int numBucketBits)
getBucketCount(int, int)
, except that the returned list
contains the number of buckets that will have to be migrated from each column if an additional column was added.numColumns
- The original number of columns.numBucketBits
- The number of bits to use for bucket id.public void reset()
private void addColumn()
public void setNumColumns(int numColumns)
numColumns
- The new number of columns to distribute to.public int getNumColumns()
public void setNumBucketBits(int numBucketBits)
numBucketBits
- The new number of bits to use for bucket id.public int getNumBucketBits()
public int getNumBuckets()
public int getColumn(BucketId bucketId)
bucketId
- The bucket whose column to lookup.Copyright © 2017. All rights reserved.