mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Merge pull request #2005 from yandex/fix-dictionary-block-input-stream-for-empty-dicts
fix DictionaryBlockInputStream::getBlock for empty dictionary
This commit is contained in:
commit
3d0f298ace
@ -114,6 +114,15 @@ private:
|
|||||||
Columns data_columns;
|
Columns data_columns;
|
||||||
GetColumnsFunction get_key_columns_function;
|
GetColumnsFunction get_key_columns_function;
|
||||||
GetColumnsFunction get_view_columns_function;
|
GetColumnsFunction get_view_columns_function;
|
||||||
|
|
||||||
|
enum class DictionaryKeyType
|
||||||
|
{
|
||||||
|
Id,
|
||||||
|
ComplexKey,
|
||||||
|
Callback
|
||||||
|
};
|
||||||
|
|
||||||
|
DictionaryKeyType key_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename DictionaryType, typename Key>
|
template <typename DictionaryType, typename Key>
|
||||||
@ -124,7 +133,8 @@ DictionaryBlockInputStream<DictionaryType, Key>::DictionaryBlockInputStream(
|
|||||||
dictionary(std::static_pointer_cast<const DictionaryType>(dictionary)),
|
dictionary(std::static_pointer_cast<const DictionaryType>(dictionary)),
|
||||||
column_names(column_names), ids(std::move(ids)),
|
column_names(column_names), ids(std::move(ids)),
|
||||||
logger(&Poco::Logger::get("DictionaryBlockInputStream")),
|
logger(&Poco::Logger::get("DictionaryBlockInputStream")),
|
||||||
fillBlockFunction(&DictionaryBlockInputStream<DictionaryType, Key>::fillBlock<DictionaryGetter, DictionaryStringGetter>)
|
fillBlockFunction(&DictionaryBlockInputStream<DictionaryType, Key>::fillBlock<DictionaryGetter, DictionaryStringGetter>),
|
||||||
|
key_type(DictionaryKeyType::Id)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +145,8 @@ DictionaryBlockInputStream<DictionaryType, Key>::DictionaryBlockInputStream(
|
|||||||
: DictionaryBlockInputStreamBase(keys.size(), max_block_size),
|
: DictionaryBlockInputStreamBase(keys.size(), max_block_size),
|
||||||
dictionary(std::static_pointer_cast<const DictionaryType>(dictionary)), column_names(column_names),
|
dictionary(std::static_pointer_cast<const DictionaryType>(dictionary)), column_names(column_names),
|
||||||
logger(&Poco::Logger::get("DictionaryBlockInputStream")),
|
logger(&Poco::Logger::get("DictionaryBlockInputStream")),
|
||||||
fillBlockFunction(&DictionaryBlockInputStream<DictionaryType, Key>::fillBlock<GetterByKey, StringGetterByKey>)
|
fillBlockFunction(&DictionaryBlockInputStream<DictionaryType, Key>::fillBlock<GetterByKey, StringGetterByKey>),
|
||||||
|
key_type(DictionaryKeyType::ComplexKey)
|
||||||
{
|
{
|
||||||
const DictionaryStructure & dictionaty_structure = dictionary->getStructure();
|
const DictionaryStructure & dictionaty_structure = dictionary->getStructure();
|
||||||
fillKeyColumns(keys, 0, keys.size(), dictionaty_structure, key_columns);
|
fillKeyColumns(keys, 0, keys.size(), dictionaty_structure, key_columns);
|
||||||
@ -152,14 +163,17 @@ DictionaryBlockInputStream<DictionaryType, Key>::DictionaryBlockInputStream(
|
|||||||
logger(&Poco::Logger::get("DictionaryBlockInputStream")),
|
logger(&Poco::Logger::get("DictionaryBlockInputStream")),
|
||||||
fillBlockFunction(&DictionaryBlockInputStream<DictionaryType, Key>::fillBlock<GetterByKey, StringGetterByKey>),
|
fillBlockFunction(&DictionaryBlockInputStream<DictionaryType, Key>::fillBlock<GetterByKey, StringGetterByKey>),
|
||||||
data_columns(data_columns),
|
data_columns(data_columns),
|
||||||
get_key_columns_function(get_key_columns_function), get_view_columns_function(get_view_columns_function)
|
get_key_columns_function(get_key_columns_function), get_view_columns_function(get_view_columns_function),
|
||||||
|
key_type(DictionaryKeyType::Callback)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename DictionaryType, typename Key>
|
template <typename DictionaryType, typename Key>
|
||||||
Block DictionaryBlockInputStream<DictionaryType, Key>::getBlock(size_t start, size_t length) const
|
Block DictionaryBlockInputStream<DictionaryType, Key>::getBlock(size_t start, size_t length) const
|
||||||
{
|
{
|
||||||
if (!key_columns.empty())
|
switch (key_type)
|
||||||
|
{
|
||||||
|
case DictionaryKeyType::ComplexKey:
|
||||||
{
|
{
|
||||||
Columns columns;
|
Columns columns;
|
||||||
ColumnsWithTypeAndName view_columns;
|
ColumnsWithTypeAndName view_columns;
|
||||||
@ -172,12 +186,12 @@ Block DictionaryBlockInputStream<DictionaryType, Key>::getBlock(size_t start, si
|
|||||||
}
|
}
|
||||||
return (this->*fillBlockFunction)({}, columns, {}, std::move(view_columns));
|
return (this->*fillBlockFunction)({}, columns, {}, std::move(view_columns));
|
||||||
}
|
}
|
||||||
else if (!ids.empty())
|
case DictionaryKeyType::Id:
|
||||||
{
|
{
|
||||||
PaddedPODArray<Key> block_ids(ids.begin() + start, ids.begin() + start + length);
|
PaddedPODArray<Key> block_ids(ids.begin() + start, ids.begin() + start + length);
|
||||||
return (this->*fillBlockFunction)(block_ids, {}, {}, {});
|
return (this->*fillBlockFunction)(block_ids, {}, {}, {});
|
||||||
}
|
}
|
||||||
else
|
case DictionaryKeyType::Callback:
|
||||||
{
|
{
|
||||||
Columns columns;
|
Columns columns;
|
||||||
columns.reserve(data_columns.size());
|
columns.reserve(data_columns.size());
|
||||||
@ -196,6 +210,8 @@ Block DictionaryBlockInputStream<DictionaryType, Key>::getBlock(size_t start, si
|
|||||||
}
|
}
|
||||||
return (this->*fillBlockFunction)({}, columns, types, std::move(view_with_type_and_name));
|
return (this->*fillBlockFunction)({}, columns, types, std::move(view_with_type_and_name));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
throw Exception("Unexpected DictionaryKeyType.", ErrorCodes::LOGICAL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename DictionaryType, typename Key>
|
template <typename DictionaryType, typename Key>
|
||||||
|
Loading…
Reference in New Issue
Block a user