@PublicEvolving public class UniformIntegerDistribution extends Object implements DataDistribution
Constructor and Description |
---|
UniformIntegerDistribution() |
UniformIntegerDistribution(int min,
int max) |
Modifier and Type | Method and Description |
---|---|
IntValue[] |
getBucketBoundary(int bucketNum,
int totalNumBuckets)
Returns the i'th bucket's upper bound, given that the distribution is to be
split into
totalBuckets buckets. |
int |
getNumberOfFields()
The number of fields in the (composite) key.
|
void |
read(DataInputView in)
Reads the object's internal data from the given data input view.
|
void |
write(DataOutputView out)
Writes the object's internal data to the given data output view.
|
public UniformIntegerDistribution()
public UniformIntegerDistribution(int min, int max)
public IntValue[] getBucketBoundary(int bucketNum, int totalNumBuckets)
DataDistribution
totalBuckets
buckets.
Assuming n buckets, let B_i
be the result from calling getBucketBoundary(i, n)
,
then the distribution will partition the data domain in the following fashion:
(-inf, B_1] (B_1, B_2] ... (B_n-2, B_n-1] (B_n-1, inf)
Note: The last bucket's upper bound is actually discarded by many algorithms.
The last bucket is assumed to hold all values v such that
v > getBucketBoundary(n-1, n)
, where n is the number of buckets.
getBucketBoundary
in interface DataDistribution
bucketNum
- The number of the bucket for which to get the upper bound.totalNumBuckets
- The number of buckets to split the data into.public int getNumberOfFields()
DataDistribution
DataDistribution.getBucketBoundary(int, int)
.getNumberOfFields
in interface DataDistribution
public void write(DataOutputView out) throws IOException
IOReadableWritable
write
in interface IOReadableWritable
out
- the output view to receive the data.IOException
- thrown if any error occurs while writing to the output streampublic void read(DataInputView in) throws IOException
IOReadableWritable
read
in interface IOReadableWritable
in
- the input view to read the data fromIOException
- thrown if any error occurs while reading from the input streamCopyright © 2014–2017 The Apache Software Foundation. All rights reserved.