#include "ComplexKeyCacheDictionary.h" namespace DB { void ComplexKeyCacheDictionary::setAttributeValue(Attribute & attribute, const size_t idx, const Field & value) const { switch (attribute.type) { case AttributeUnderlyingType::utUInt8: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utUInt16: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utUInt32: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utUInt64: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utUInt128: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utInt8: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utInt16: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utInt32: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utInt64: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utFloat32: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utFloat64: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utDecimal32: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utDecimal64: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utDecimal128: std::get>(attribute.arrays)[idx] = value.get(); break; case AttributeUnderlyingType::utString: { const auto & string = value.get(); auto & string_ref = std::get>(attribute.arrays)[idx]; const auto & null_value_ref = std::get(attribute.null_values); /// free memory unless it points to a null_value if (string_ref.data && string_ref.data != null_value_ref.data()) string_arena->free(const_cast(string_ref.data), string_ref.size); const auto str_size = string.size(); if (str_size != 0) { auto str_ptr = string_arena->alloc(str_size); std::copy(string.data(), string.data() + str_size, str_ptr); string_ref = StringRef{str_ptr, str_size}; } else string_ref = {}; break; } } } }