From 9509516e3c1ba2a2aedc0c569196d657856186b8 Mon Sep 17 00:00:00 2001 From: Maksim Kita Date: Wed, 10 Mar 2021 01:26:06 +0300 Subject: [PATCH] Fixed tests --- src/Dictionaries/DirectDictionary.cpp | 94 +-------------------------- 1 file changed, 1 insertion(+), 93 deletions(-) diff --git a/src/Dictionaries/DirectDictionary.cpp b/src/Dictionaries/DirectDictionary.cpp index 7934392c0a7..4cb9e0cd629 100644 --- a/src/Dictionaries/DirectDictionary.cpp +++ b/src/Dictionaries/DirectDictionary.cpp @@ -21,6 +21,7 @@ namespace ErrorCodes namespace { + inline UInt64 getAt(const PaddedPODArray & arr, const size_t idx) { return arr[idx]; @@ -31,99 +32,6 @@ namespace return value; } - /// TODO: Use this class from DictionaryHelpers after cache dictionaries pull request will be merged - template - class DictionaryKeysExtractor - { - public: - using KeyType = std::conditional_t; - static_assert(key_type != DictionaryKeyType::range, "Range key type is not supported by DictionaryKeysExtractor"); - - explicit DictionaryKeysExtractor(const Columns & key_columns, Arena & existing_arena) - { - assert(!key_columns.empty()); - - if constexpr (key_type == DictionaryKeyType::simple) - keys = getColumnVectorData(key_columns.front()); - else - keys = deserializeKeyColumnsInArena(key_columns, existing_arena); - } - - - const PaddedPODArray & getKeys() const - { - return keys; - } - - private: - static PaddedPODArray getColumnVectorData(const ColumnPtr column) - { - PaddedPODArray result; - - auto full_column = column->convertToFullColumnIfConst(); - const auto *vector_col = checkAndGetColumn>(full_column.get()); - - if (!vector_col) - throw Exception{ErrorCodes::TYPE_MISMATCH, "Column type mismatch for simple key expected UInt64"}; - - result.assign(vector_col->getData()); - - return result; - } - - static PaddedPODArray deserializeKeyColumnsInArena(const Columns & key_columns, Arena & temporary_arena) - { - size_t keys_size = key_columns.front()->size(); - - PaddedPODArray result; - result.reserve(keys_size); - - PaddedPODArray temporary_column_data(key_columns.size()); - - for (size_t key_index = 0; key_index < keys_size; ++key_index) - { - size_t allocated_size_for_columns = 0; - const char * block_start = nullptr; - - for (size_t column_index = 0; column_index < key_columns.size(); ++column_index) - { - const auto & column = key_columns[column_index]; - temporary_column_data[column_index] = column->serializeValueIntoArena(key_index, temporary_arena, block_start); - allocated_size_for_columns += temporary_column_data[column_index].size; - } - - result.push_back(StringRef{block_start, allocated_size_for_columns}); - } - - return result; - } - - PaddedPODArray keys; - }; - - /// TODO: Use this class from DictionaryHelpers after cache dictionaries pull request will be merged - class DefaultValueProvider final - { - public: - explicit DefaultValueProvider(Field default_value_, ColumnPtr default_values_column_ = nullptr) - : default_value(std::move(default_value_)) - , default_values_column(default_values_column_) - { - } - - - Field getDefaultValue(size_t row) const - { - if (default_values_column) - return (*default_values_column)[row]; - - return default_value; - } - - private: - Field default_value; - ColumnPtr default_values_column; - }; } template