Updated DictionaryDefaultValueExtractor interface

This commit is contained in:
Maksim Kita 2021-01-23 19:47:33 +03:00
parent c4ffa2160f
commit b7a150cc63
23 changed files with 145 additions and 144 deletions

View File

@ -271,11 +271,10 @@ ColumnPtr CacheDictionary::getColumn(
{
using Type = std::decay_t<decltype(dictionary_attribute_type)>;
using AttributeType = typename Type::AttributeType;
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = static_cast<ValueType>(std::get<AttributeType>(attribute.null_value));
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto null_value = std::get<AttributeType>(attribute.null_value);
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(null_value, default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, keys_size);
@ -297,12 +296,12 @@ ColumnPtr CacheDictionary::getColumn(
return result;
}
template <typename AttributeType, typename OutputType>
template <typename AttributeType, typename OutputType, typename DefaultValueExtractor>
void CacheDictionary::getItemsNumberImpl(
Attribute & attribute,
const PaddedPODArray<Key> & ids,
ResultArrayType<OutputType> & out,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const
DefaultValueExtractor & default_value_extractor) const
{
/// First fill everything with default values
const auto rows = ext::size(ids);
@ -427,7 +426,7 @@ void CacheDictionary::getItemsString(
Attribute & attribute,
const PaddedPODArray<Key> & ids,
ColumnString * out,
DictionaryDefaultValueExtractor<StringRef> & default_value_extractor) const
DictionaryDefaultValueExtractor<String> & default_value_extractor) const
{
const auto rows = ext::size(ids);

View File

@ -204,18 +204,18 @@ private:
/* NOLINTNEXTLINE(readability-convert-member-functions-to-static) */
Attribute createAttributeWithTypeAndName(const AttributeUnderlyingType type, const String & name, const Field & null_value);
template <typename AttributeType, typename OutputType>
template <typename AttributeType, typename OutputType, typename DefaultValueExtractor>
void getItemsNumberImpl(
Attribute & attribute,
const PaddedPODArray<Key> & ids,
ResultArrayType<OutputType> & out,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const;
DefaultValueExtractor & default_value_extractor) const;
void getItemsString(
Attribute & attribute,
const PaddedPODArray<Key> & ids,
ColumnString * out,
DictionaryDefaultValueExtractor<StringRef> & default_value_extractor) const;
DictionaryDefaultValueExtractor<String> & default_value_extractor) const;
PaddedPODArray<Key> getCachedIds() const;

View File

@ -91,11 +91,10 @@ ColumnPtr ComplexKeyCacheDictionary::getColumn(
{
using Type = std::decay_t<decltype(dictionary_attribute_type)>;
using AttributeType = typename Type::AttributeType;
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = ValueType{std::get<AttributeType>(attribute.null_values)};
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto null_value = std::get<AttributeType>(attribute.null_values);
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(null_value, default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, keys_size);
@ -248,12 +247,12 @@ ColumnUInt8::Ptr ComplexKeyCacheDictionary::hasKeys(const Columns & key_columns,
}
template <typename AttributeType, typename OutputType>
template <typename AttributeType, typename OutputType, typename DefaultValueExtractor>
void ComplexKeyCacheDictionary::getItemsNumberImpl(
Attribute & attribute,
const Columns & key_columns,
PaddedPODArray<OutputType> & out,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const
DefaultValueExtractor & default_value_extractor) const
{
/// Mapping: <key> -> { all indices `i` of `key_columns` such that `key_columns[i]` = <key> }
MapType<std::vector<size_t>> outdated_keys;
@ -335,7 +334,7 @@ void ComplexKeyCacheDictionary::getItemsString(
Attribute & attribute,
const Columns & key_columns,
ColumnString * out,
DictionaryDefaultValueExtractor<StringRef> & default_value_extractor) const
DictionaryDefaultValueExtractor<String> & default_value_extractor) const
{
const auto rows_num = key_columns.front()->size();
/// save on some allocations

View File

@ -175,18 +175,18 @@ private:
Attribute createAttributeWithType(const AttributeUnderlyingType type, const Field & null_value);
template <typename AttributeType, typename OutputType>
template <typename AttributeType, typename OutputType, typename DefaultValueExtractor>
void getItemsNumberImpl(
Attribute & attribute,
const Columns & key_columns,
PaddedPODArray<OutputType> & out,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const;
DefaultValueExtractor & default_value_extractor) const;
void getItemsString(
Attribute & attribute,
const Columns & key_columns,
ColumnString * out,
DictionaryDefaultValueExtractor<StringRef> & default_value_extractor) const;
DictionaryDefaultValueExtractor<String> & default_value_extractor) const;
template <typename PresentKeyHandler, typename AbsentKeyHandler>
void update(

View File

@ -65,8 +65,9 @@ ColumnPtr ComplexKeyDirectDictionary::getColumn(
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = std::get<ValueType>(attribute.null_values);
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto attribute_null_value = std::get<ValueType>(attribute.null_values);
AttributeType null_value = static_cast<AttributeType>(attribute_null_value);
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(std::move(null_value), default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, keys_size);
@ -94,7 +95,8 @@ ColumnPtr ComplexKeyDirectDictionary::getColumn(
getItemsImpl<AttributeType, AttributeType>(
attribute,
key_columns,
[&](const size_t row, const auto value, bool is_null) {
[&](const size_t row, const auto value, bool is_null)
{
if (attribute.is_nullable)
(*vec_null_map_to)[row] = is_null;

View File

@ -67,8 +67,9 @@ ColumnPtr ComplexKeyHashedDictionary::getColumn(
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = std::get<ValueType>(attribute.null_values);
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto attribute_null_value = std::get<ValueType>(attribute.null_values);
AttributeType null_value = attribute_null_value;
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(std::move(null_value), default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, keys_size);
@ -370,12 +371,12 @@ ComplexKeyHashedDictionary::createAttribute(const DictionaryAttribute & attribut
}
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void ComplexKeyHashedDictionary::getItemsImpl(
const Attribute & attribute,
const Columns & key_columns,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const
DefaultValueExtractor & default_value_extractor) const
{
const auto & attr = std::get<ContainerType<AttributeType>>(attribute.maps);

View File

@ -140,12 +140,12 @@ private:
Attribute createAttribute(const DictionaryAttribute & attribute, const Field & null_value);
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void getItemsImpl(
const Attribute & attribute,
const Columns & key_columns,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const;
DefaultValueExtractor & default_value_extractor) const;
template <typename T>
bool setAttributeValueImpl(Attribute & attribute, const StringRef key, const T value);

View File

@ -10,6 +10,11 @@
namespace DB
{
namespace ErrorCodes
{
extern const int TYPE_MISMATCH;
}
/**
* In Dictionaries implementation String attribute is stored in arena and StringRefs are pointing to it.
*/
@ -50,66 +55,60 @@ public:
};
/**
* DictionaryDefaultValueExtractor used to simplify getting default value for IDictionary function `getColumn`.
* Provides interface for getting default value with operator[];
*
* If default_values_column is not null in constructor than this column values will be used as default values.
* If default_values_column is null then attribute_default_value will be used.
* DictionaryDefaultValueExtractor used to simplify getting default value for IDictionary function `getColumn`.
* Provides interface for getting default value with operator[];
*
* If default_values_column is null then attribute_default_value will be used.
* If default_values_column is not null in constructor than this column values will be used as default values.
*/
template <typename DefaultValueType>
template <typename DictionaryAttributeType>
class DictionaryDefaultValueExtractor
{
using ResultColumnType =
std::conditional_t< std::is_same_v<DefaultValueType, StringRef>, ColumnString,
std::conditional_t<IsDecimalNumber<DefaultValueType>, ColumnDecimal<DefaultValueType>,
ColumnVector<DefaultValueType>>>;
using DefaultColumnType = typename DictionaryAttributeColumnProvider<DictionaryAttributeType>::ColumnType;
public:
DictionaryDefaultValueExtractor(DefaultValueType attribute_default_value, ColumnPtr default_values_column_ = nullptr)
DictionaryDefaultValueExtractor(DictionaryAttributeType attribute_default_value, ColumnPtr default_values_column_ = nullptr)
{
if (default_values_column_ != nullptr)
if (!default_values_column_)
default_value = { std::move(attribute_default_value) };
else
{
if (const auto * const default_col = checkAndGetColumn<ResultColumnType>(*default_values_column))
if (const auto * const default_col = checkAndGetColumn<DefaultColumnType>(*default_values_column))
{
default_values_column = default_col;
}
else if (const auto * const default_col_const = checkAndGetColumnConst<ResultColumnType>(default_values_column_.get()))
else if (const auto * const default_col_const = checkAndGetColumnConst<DefaultColumnType>(default_values_column_.get()))
{
/// TODO: Check String lifetime safety
/// DefaultValueType for StringColumn is StringRef, but const column getValue will return String
using ConstColumnValue = std::conditional_t<std::is_same_v<DefaultValueType, StringRef>, String, DefaultValueType>;
default_value = std::make_optional<DefaultValueType>(default_col_const->template getValue<ConstColumnValue>());
default_value = { default_col_const->template getValue<DictionaryAttributeType>() };
}
else
throw Exception{"Type of default column is not the same as result type.", ErrorCodes::TYPE_MISMATCH};
throw Exception{"Type of default column is not the same as dictionary attribute type.", ErrorCodes::TYPE_MISMATCH};
}
else
default_value = std::make_optional<DefaultValueType>(attribute_default_value);
}
DefaultValueType operator[](size_t row)
DictionaryValueType<DictionaryAttributeType> operator[](size_t row)
{
if (default_value)
return *default_value;
return static_cast<DictionaryAttributeType>(*default_value);
if constexpr (std::is_same_v<ResultColumnType, ColumnString>)
if constexpr (std::is_same_v<DefaultColumnType, ColumnString>)
return default_values_column->getDataAt(row);
else
return default_values_column->getData()[row];
}
private:
const ResultColumnType * default_values_column = nullptr;
std::optional<DefaultValueType> default_value = {};
const DefaultColumnType * default_values_column = nullptr;
std::optional<DictionaryAttributeType> default_value = {};
};
/**
* Returns ColumnVector data as PaddedPodArray.
*
* If column is constant parameter backup_storage is used to store values.
*/
template <typename T>
static const PaddedPODArray<T> & getColumnVectorData(
const IDictionaryBase * dictionary [[maybe_unused]],
const IDictionaryBase * dictionary,
const ColumnPtr column,
PaddedPODArray<T> & backup_storage)
{

View File

@ -167,8 +167,9 @@ ColumnPtr DirectDictionary::getColumn(
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = std::get<ValueType>(attribute.null_values);
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto attribute_null_value = std::get<ValueType>(attribute.null_values);
AttributeType null_value = static_cast<AttributeType>(attribute_null_value);
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(std::move(null_value), default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, keys_size);

View File

@ -132,8 +132,9 @@ ColumnPtr FlatDictionary::getColumn(
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = std::get<ValueType>(attribute.null_values);
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto attribute_null_value = std::get<ValueType>(attribute.null_values);
AttributeType null_value = static_cast<AttributeType>(attribute_null_value);
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(std::move(null_value), default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, size);
@ -404,12 +405,12 @@ FlatDictionary::Attribute FlatDictionary::createAttribute(const DictionaryAttrib
}
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void FlatDictionary::getItemsImpl(
const Attribute & attribute,
const PaddedPODArray<Key> & ids,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const
DefaultValueExtractor & default_value_extractor) const
{
const auto & attr = std::get<ContainerType<AttributeType>>(attribute.arrays);
const auto rows = ext::size(ids);

View File

@ -148,12 +148,12 @@ private:
Attribute createAttribute(const DictionaryAttribute& attribute, const Field & null_value);
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void getItemsImpl(
const Attribute & attribute,
const PaddedPODArray<Key> & ids,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const;
DefaultValueExtractor & default_value_extractor) const;
template <typename T>
void resize(Attribute & attribute, const Key id);

View File

@ -153,8 +153,9 @@ ColumnPtr HashedDictionary::getColumn(
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = std::get<ValueType>(attribute.null_values);
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto attribute_null_value = std::get<ValueType>(attribute.null_values);
AttributeType null_value = static_cast<AttributeType>(attribute_null_value);
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(std::move(null_value), default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, size);
@ -518,12 +519,12 @@ HashedDictionary::Attribute HashedDictionary::createAttribute(const DictionaryAt
}
template <typename AttributeType, typename OutputType, typename MapType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename MapType, typename ValueSetter, typename DefaultValueExtractor>
void HashedDictionary::getItemsAttrImpl(
const MapType & attr,
const PaddedPODArray<Key> & ids,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const
DefaultValueExtractor & default_value_extractor) const
{
const auto rows = ext::size(ids);
@ -536,12 +537,12 @@ void HashedDictionary::getItemsAttrImpl(
query_count.fetch_add(rows, std::memory_order_relaxed);
}
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void HashedDictionary::getItemsImpl(
const Attribute & attribute,
const PaddedPODArray<Key> & ids,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const
DefaultValueExtractor & default_value_extractor) const
{
if (!sparse)
return getItemsAttrImpl<AttributeType, OutputType>(*std::get<CollectionPtrType<AttributeType>>(attribute.maps), ids, set_value, default_value_extractor);

View File

@ -182,19 +182,19 @@ private:
Attribute createAttribute(const DictionaryAttribute& attribute, const Field & null_value);
template <typename AttributeType, typename OutputType, typename MapType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename MapType, typename ValueSetter, typename DefaultValueExtractor>
void getItemsAttrImpl(
const MapType & attr,
const PaddedPODArray<Key> & ids,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & extractor) const;
DefaultValueExtractor & default_value_extractor) const;
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void getItemsImpl(
const Attribute & attribute,
const PaddedPODArray<Key> & ids,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & extractor) const;
DefaultValueExtractor & default_value_extractor) const;
template <typename T>
bool setAttributeValueImpl(Attribute & attribute, const Key id, const T value);

View File

@ -22,21 +22,20 @@ namespace DB
namespace ErrorCodes
{
extern const int NOT_IMPLEMENTED;
extern const int TYPE_MISMATCH;
}
struct IDictionaryBase;
using DictionaryPtr = std::unique_ptr<IDictionaryBase>;
/** DictionaryKeyType provides IDictionary client information about
* which key type is supported by dictionary.
* which key type is supported by dictionary.
*
* Simple is for dictionaries that support UInt64 key column.
* Simple is for dictionaries that support UInt64 key column.
*
* Complex is for dictionaries that support any combination of key columns.
* Complex is for dictionaries that support any combination of key columns.
*
* Range is for dictionary that support combination of UInt64 key column,
* and Integer representable range key column.
* Range is for dictionary that support combination of UInt64 key column,
* and numeric representable range key column.
*/
enum class DictionaryKeyType
{

View File

@ -291,8 +291,8 @@ ColumnPtr IPAddressDictionary::getColumn(
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = ValueType{std::get<AttributeType>(attribute.null_values)};
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto null_value = std::get<AttributeType>(attribute.null_values);
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(null_value, default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, size);
@ -637,12 +637,12 @@ const uint8_t * IPAddressDictionary::getIPv6FromOffset(const IPAddressDictionary
return reinterpret_cast<const uint8_t *>(&ipv6_col[i * IPV6_BINARY_LENGTH]);
}
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void IPAddressDictionary::getItemsByTwoKeyColumnsImpl(
const Attribute & attribute,
const Columns & key_columns,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const
DefaultValueExtractor & default_value_extractor) const
{
const auto first_column = key_columns.front();
const auto rows = first_column->size();
@ -718,12 +718,12 @@ void IPAddressDictionary::getItemsByTwoKeyColumnsImpl(
}
}
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void IPAddressDictionary::getItemsImpl(
const Attribute & attribute,
const Columns & key_columns,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const
DefaultValueExtractor & default_value_extractor) const
{
const auto first_column = key_columns.front();
const auto rows = first_column->size();

View File

@ -141,19 +141,19 @@ private:
Attribute createAttributeWithType(const AttributeUnderlyingType type, const Field & null_value);
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void getItemsByTwoKeyColumnsImpl(
const Attribute & attribute,
const Columns & key_columns,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const;
DefaultValueExtractor & default_value_extractor) const;
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void getItemsImpl(
const Attribute & attribute,
const Columns & key_columns,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const;
DefaultValueExtractor & default_value_extractor) const;
template <typename T>
void setAttributeValueImpl(Attribute & attribute, const T value);

View File

@ -112,11 +112,10 @@ ColumnPtr IPolygonDictionary::getColumn(
{
using Type = std::decay_t<decltype(dictionary_attribute_type)>;
using AttributeType = typename Type::AttributeType;
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = static_cast<ValueType>(std::get<AttributeType>(null_values[index]));
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto null_value = std::get<AttributeType>(null_values[index]);
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(null_value, default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, keys_size);

View File

@ -126,8 +126,9 @@ ColumnPtr RangeHashedDictionary::getColumn(
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = std::get<ValueType>(attribute.null_values);
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto attribute_null_value = std::get<ValueType>(attribute.null_values);
AttributeType null_value = static_cast<AttributeType>(attribute_null_value);
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(std::move(null_value), default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, keys_size);
@ -138,7 +139,8 @@ ColumnPtr RangeHashedDictionary::getColumn(
getItemsImpl<ValueType, ValueType>(
attribute,
modified_key_columns,
[&](const size_t row, const StringRef value, bool is_null) {
[&](const size_t row, const StringRef value, bool is_null)
{
if (attribute.is_nullable)
(*vec_null_map_to)[row] = is_null;
@ -153,7 +155,8 @@ ColumnPtr RangeHashedDictionary::getColumn(
getItemsImpl<ValueType, ValueType>(
attribute,
modified_key_columns,
[&](const size_t row, const auto value, bool is_null) {
[&](const size_t row, const auto value, bool is_null)
{
if (attribute.is_nullable)
(*vec_null_map_to)[row] = is_null;
@ -313,12 +316,12 @@ RangeHashedDictionary::createAttribute(const DictionaryAttribute& attribute, con
return attr;
}
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void RangeHashedDictionary::getItemsImpl(
const Attribute & attribute,
const Columns & key_columns,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const
DefaultValueExtractor & default_value_extractor) const
{
PaddedPODArray<Key> key_backup_storage;
PaddedPODArray<RangeStorageType> range_backup_storage;

View File

@ -152,12 +152,12 @@ private:
Attribute createAttribute(const DictionaryAttribute& attribute, const Field & null_value);
template <typename AttributeType, typename OutputType, typename ValueSetter>
template <typename AttributeType, typename OutputType, typename ValueSetter, typename DefaultValueExtractor>
void getItemsImpl(
const Attribute & attribute,
const Columns & key_columns,
ValueSetter && set_value,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const;
DefaultValueExtractor & default_value_extractor) const;
template <typename T>
void setAttributeValueImpl(Attribute & attribute, const Key id, const Range & range, const Field & value);

View File

@ -1348,11 +1348,10 @@ ColumnPtr SSDCacheDictionary::getColumn(
{
using Type = std::decay_t<decltype(dictionary_attribute_type)>;
using AttributeType = typename Type::AttributeType;
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = static_cast<ValueType>(std::get<AttributeType>(null_values[index]));
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto null_value = std::get<AttributeType>(null_values[index]);
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(null_value, default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, keys_size);

View File

@ -1401,12 +1401,10 @@ ColumnPtr SSDComplexKeyCacheDictionary::getColumn(
{
using Type = std::decay_t<decltype(dictionary_attribute_type)>;
using AttributeType = typename Type::AttributeType;
using ValueType = DictionaryValueType<AttributeType>;
using ColumnProvider = DictionaryAttributeColumnProvider<AttributeType>;
const auto null_value = static_cast<ValueType>(std::get<AttributeType>(null_values[index]));
DictionaryDefaultValueExtractor<ValueType> default_value_extractor(null_value, default_values_column);
const auto null_value = std::get<AttributeType>(null_values[index]);
DictionaryDefaultValueExtractor<AttributeType> default_value_extractor(null_value, default_values_column);
auto column = ColumnProvider::getColumn(dictionary_attribute, keys_size);
@ -1434,13 +1432,13 @@ ColumnPtr SSDComplexKeyCacheDictionary::getColumn(
return result;
}
template <typename AttributeType, typename OutputType>
template <typename AttributeType, typename OutputType, typename DefaultValueExtractor>
void SSDComplexKeyCacheDictionary::getItemsNumberImpl(
const size_t attribute_index,
const Columns & key_columns,
const DataTypes & key_types,
ResultArrayType<OutputType> & out,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const
DefaultValueExtractor & default_value_extractor) const
{
assert(dict_struct.key);
assert(key_columns.size() == key_types.size());
@ -1488,7 +1486,7 @@ void SSDComplexKeyCacheDictionary::getItemsStringImpl(
const Columns & key_columns,
const DataTypes & key_types,
ColumnString * out,
DictionaryDefaultValueExtractor<StringRef> & default_value_extractor) const
DictionaryDefaultValueExtractor<String> & default_value_extractor) const
{
dict_struct.validateKeyTypes(key_types);

View File

@ -593,20 +593,20 @@ private:
AttributeValueVariant createAttributeNullValueWithType(const AttributeUnderlyingType type, const Field & null_value);
void createAttributes();
template <typename AttributeType, typename OutputType>
template <typename AttributeType, typename OutputType, typename DefaultValueExtractor>
void getItemsNumberImpl(
const size_t attribute_index,
const Columns & key_columns,
const DataTypes & key_types,
ResultArrayType<OutputType> & out,
DictionaryDefaultValueExtractor<AttributeType> & default_value_extractor) const;
DefaultValueExtractor & default_value_extractor) const;
void getItemsStringImpl(
const size_t attribute_index,
const Columns & key_columns,
const DataTypes & key_types,
ColumnString * out,
DictionaryDefaultValueExtractor<StringRef> & default_value_extractor) const;
DictionaryDefaultValueExtractor<String> & default_value_extractor) const;
const std::string name;
const DictionaryStructure dict_struct;