public final class ReservoirSize extends Object
The value itself is a fractional power of 2, with 5 bits of exponent and 11 bits of mantissa. The exponent allows a choice of anywhere from 0-30, and there are 2048 possible reservoir size values within each octave. Because reservoir size must be an integer, this means that some sizes below 2048 may have multiple valid encodings.
Reservoir sizes can be specified exactly to 4096, and may be off by up to 0.03% thereafter. The value returned is always at least as large as the requested size, but may be larger.
NOTE: Numerical instability may cause an off-by-one error on reservoir size, causing a slight increase in storage over the optimal value.
| Modifier and Type | Method and Description |
|---|---|
static short |
computeSize(int k)
Given target reservoir size k, computes the smallest representable reservoir size that can
hold k entries and returns it in a 16-bit fixed-point format as a short.
|
static int |
decodeValue(short encodedSize)
Decodes the 16-bit reservoir size value into an int.
|
public static short computeSize(int k)
k - target reservoir sizepublic static int decodeValue(short encodedSize)
encodedSize - Encoded 16-bit valueCopyright © 2015–2017 Yahoo! Inc.. All rights reserved.