init check
This commit is contained in:
parent
5561dd9cb0
commit
69874dc571
@ -222,20 +222,15 @@ class WQuantileSketch {
|
|||||||
};
|
};
|
||||||
/*!
|
/*!
|
||||||
* \brief intialize the quantile sketch, given the performance specification
|
* \brief intialize the quantile sketch, given the performance specification
|
||||||
* \param maxn maximum number of data points can be encountered
|
* \param maxn maximum number of data points can be feed into sketch
|
||||||
* \param eps accuracy level of summary
|
* \param eps accuracy level of summary
|
||||||
*/
|
*/
|
||||||
inline void Init(RType maxn, double eps) {
|
inline void Init(size_t maxn, double eps) {
|
||||||
nlevel = 0;
|
nlevel = std::max(ceil(maxn * eps), 1.0);
|
||||||
size_t b = std::max(floor(log2(eps * maxn) / eps), 8.0);
|
limit_size = ceil(nlevel / eps);
|
||||||
// check for small n case
|
// check invariant
|
||||||
while (b < maxn) {
|
utils::Assert((1 << nlevel) * limit_size > maxn, "invalid init parameter");
|
||||||
nlevel = ceil(log2(maxn / b)) + 1;
|
utils::Assert(nlevel <= limit_size * eps, "invalid init parameter");
|
||||||
if (nlevel < eps * b) break;
|
|
||||||
++b;
|
|
||||||
}
|
|
||||||
nlevel += 1;
|
|
||||||
limit_size = (b + 1) / 2 + 1;
|
|
||||||
// lazy reserve the space, if there is only one value, no need to allocate space
|
// lazy reserve the space, if there is only one value, no need to allocate space
|
||||||
inqueue.resize(1);
|
inqueue.resize(1);
|
||||||
qtail = 0;
|
qtail = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user