AggregateFunctionTopK: read alphaMap for generic

* the alpha_map vector always (de)serialises
  the actual version (could empty sometimes)
* AggregateFunctionTopK generic variant deserialises
  it as well instead of ignoring it
* AggregateFunctionTopK generic variant clears the
  array before deserialising

refs #1283
This commit is contained in:
Marek Vavruša 2017-09-28 00:01:54 -07:00 committed by alexey-milovidov
parent 6628b5d308
commit 28bb5e25cf
2 changed files with 19 additions and 1 deletions

View File

@ -195,7 +195,9 @@ public:
{
auto & set = this->data(place).value;
set.resize(reserved);
set.clear();
// Specialised here because there's no deserialiser for StringRef
size_t count = 0;
readVarUInt(count, buf);
for (size_t i = 0; i < count; ++i) {
@ -206,6 +208,8 @@ public:
set.insert(ref, count, error);
arena->rollback(ref.size);
}
set.readAlphaMap(buf);
}
void addImpl(AggregateDataPtr place, const IColumn & column, size_t row_num, Arena * arena) const

View File

@ -130,6 +130,11 @@ public:
return m_capacity;
}
void clear()
{
return destroyElements();
}
void resize(size_t new_capacity)
{
counter_list.reserve(new_capacity);
@ -255,6 +260,8 @@ public:
writeVarUInt(size(), wb);
for (auto counter : counter_list)
counter->write(wb);
writeVarUInt(alpha_map.size(), wb);
for (auto alpha : alpha_map)
writeVarUInt(alpha, wb);
}
@ -273,7 +280,14 @@ public:
push(counter);
}
for (size_t i = 0; i < nextAlphaSize(m_capacity); ++i)
readAlphaMap(rb);
}
void readAlphaMap(ReadBuffer & rb)
{
size_t alpha_size = 0;
readVarUInt(alpha_size, rb);
for (size_t i = 0; i < alpha_size; ++i)
{
UInt64 alpha = 0;
readVarUInt(alpha, rb);