2020-06-17 10:02:04 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Common/HashTable/HashTableKeyHolder.h>
|
|
|
|
#include <Columns/IColumn.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-06-19 20:13:07 +00:00
|
|
|
template <bool is_plain_column = false>
|
2020-06-17 10:02:04 +00:00
|
|
|
static auto getKeyHolder(const IColumn & column, size_t row_num, Arena & arena)
|
|
|
|
{
|
|
|
|
if constexpr (is_plain_column)
|
|
|
|
{
|
|
|
|
return ArenaKeyHolder{column.getDataAt(row_num), arena};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const char * begin = nullptr;
|
|
|
|
StringRef serialized = column.serializeValueIntoArena(row_num, arena, begin);
|
|
|
|
assert(serialized.data != nullptr);
|
|
|
|
return SerializedKeyHolder{serialized, arena};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <bool is_plain_column>
|
|
|
|
static void deserializeAndInsert(StringRef str, IColumn & data_to)
|
|
|
|
{
|
|
|
|
if constexpr (is_plain_column)
|
|
|
|
data_to.insertData(str.data, str.size);
|
|
|
|
else
|
|
|
|
data_to.deserializeAndInsertFromArena(str.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|