mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Quantiles: better [#METR-20381].
This commit is contained in:
parent
1203a0a9c4
commit
d06a5906bf
@ -134,7 +134,7 @@ public:
|
||||
|
||||
std::sort(array, array + size, [](const Pair & a, const Pair & b) { return a.first < b.first; });
|
||||
|
||||
UInt64 threshold = sum_weight * level;
|
||||
UInt64 threshold = std::ceil(sum_weight * level);
|
||||
UInt64 accumulated = 0;
|
||||
|
||||
const Pair * it = array;
|
||||
@ -267,7 +267,7 @@ public:
|
||||
const Pair * end = array + size;
|
||||
|
||||
size_t level_index = 0;
|
||||
UInt64 threshold = sum_weight * levels.levels[levels.permutation[level_index]];
|
||||
UInt64 threshold = std::ceil(sum_weight * levels.levels[levels.permutation[level_index]]);
|
||||
|
||||
while (it < end)
|
||||
{
|
||||
@ -281,7 +281,7 @@ public:
|
||||
if (level_index == num_levels)
|
||||
return;
|
||||
|
||||
threshold = sum_weight * levels.levels[levels.permutation[level_index]];
|
||||
threshold = std::ceil(sum_weight * levels.levels[levels.permutation[level_index]]);
|
||||
}
|
||||
|
||||
++it;
|
||||
|
@ -402,7 +402,7 @@ namespace detail
|
||||
/// Получить значение квантиля уровня level. Уровень должен быть от 0 до 1.
|
||||
UInt16 get(double level) const
|
||||
{
|
||||
UInt64 pos = count * level;
|
||||
UInt64 pos = std::ceil(count * level);
|
||||
|
||||
UInt64 accumulated = 0;
|
||||
Iterator it(*this);
|
||||
@ -428,7 +428,7 @@ namespace detail
|
||||
const auto indices_end = indices + size;
|
||||
auto index = indices;
|
||||
|
||||
UInt64 pos = count * levels[*index];
|
||||
UInt64 pos = std::ceil(count * levels[*index]);
|
||||
|
||||
UInt64 accumulated = 0;
|
||||
Iterator it(*this);
|
||||
@ -445,7 +445,7 @@ namespace detail
|
||||
if (index == indices_end)
|
||||
return;
|
||||
|
||||
pos = count * levels[*index];
|
||||
pos = std::ceil(count * levels[*index]);
|
||||
}
|
||||
|
||||
it.next();
|
||||
|
Loading…
Reference in New Issue
Block a user