mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-23 10:10:50 +00:00
AggregateFunctionTopK: minor modifications [#CLICKHOUSE-2].
This commit is contained in:
parent
32a75147f5
commit
d3e6321967
@ -72,9 +72,8 @@ public:
|
||||
void addImpl(AggregateDataPtr place, const IColumn & column, size_t row_num, Arena *) const
|
||||
{
|
||||
auto & set = this->data(place).value;
|
||||
if (set.capacity() != reserved) {
|
||||
if (set.capacity() != reserved)
|
||||
set.resize(reserved);
|
||||
}
|
||||
set.insert(static_cast<const ColumnVector<T> &>(column).getData()[row_num]);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
m_capacity = new_capacity;
|
||||
}
|
||||
|
||||
Counter * insert(const TKey & key, UInt64 increment = 1, UInt64 error = 0)
|
||||
void insert(const TKey & key, UInt64 increment = 1, UInt64 error = 0)
|
||||
{
|
||||
// Increase weight of a key that already exists
|
||||
// It uses hashtable for both value mapping as a presence test (c_i != 0)
|
||||
@ -97,7 +97,7 @@ public:
|
||||
c->count += increment;
|
||||
c->error += error;
|
||||
percolate(c);
|
||||
return c;
|
||||
return;
|
||||
}
|
||||
|
||||
// Key doesn't exist, but can fit in the top K
|
||||
@ -105,7 +105,7 @@ public:
|
||||
{
|
||||
auto c = new Counter(key, increment, error);
|
||||
push(c);
|
||||
return c;
|
||||
return;
|
||||
}
|
||||
|
||||
auto min = counter_list.back();
|
||||
@ -113,12 +113,12 @@ public:
|
||||
if (alpha + increment < min->count)
|
||||
{
|
||||
alpha += increment;
|
||||
return nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
// Erase the current minimum element
|
||||
auto minHash = counter_map.hash(min->key);
|
||||
it = counter_map.find(min->key, minHash);
|
||||
auto min_hash = counter_map.hash(min->key);
|
||||
it = counter_map.find(min->key, min_hash);
|
||||
if (it != counter_map.end())
|
||||
{
|
||||
auto cell = it.getPtr();
|
||||
@ -130,15 +130,13 @@ public:
|
||||
counter_map.emplace(key, it, inserted, hash);
|
||||
if (inserted)
|
||||
{
|
||||
alpha_map[minHash % alpha_map.size()] = min->count;
|
||||
alpha_map[min_hash % alpha_map.size()] = min->count;
|
||||
min->key = key;
|
||||
min->count = alpha + increment;
|
||||
min->error = alpha + error;
|
||||
it->second = min;
|
||||
percolate(min);
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user