From cb0af7c3af233e1c2c689ae3320e45a04eb2b5a3 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 3 Sep 2018 03:33:29 +0300 Subject: [PATCH] Removed unused aggregation method [#CLICKHOUSE-2] --- dbms/src/Interpreters/AggregationCommon.h | 20 ------- dbms/src/Interpreters/Aggregator.cpp | 2 - dbms/src/Interpreters/Aggregator.h | 63 ----------------------- 3 files changed, 85 deletions(-) diff --git a/dbms/src/Interpreters/AggregationCommon.h b/dbms/src/Interpreters/AggregationCommon.h index 5766062d27b..61b352360e2 100644 --- a/dbms/src/Interpreters/AggregationCommon.h +++ b/dbms/src/Interpreters/AggregationCommon.h @@ -174,26 +174,6 @@ static inline T ALWAYS_INLINE packFixed( /// Hash a set of keys into a UInt128 value. -static inline UInt128 ALWAYS_INLINE hash128( - size_t i, size_t keys_size, const ColumnRawPtrs & key_columns, StringRefs & keys) -{ - UInt128 key; - SipHash hash; - - for (size_t j = 0; j < keys_size; ++j) - { - /// Hashes the key. - keys[j] = key_columns[j]->getDataAtWithTerminatingZero(i); - hash.update(keys[j].data, keys[j].size); - } - - hash.get128(key.low, key.high); - - return key; -} - - -/// Almost the same as above but it doesn't return any reference to key data. static inline UInt128 ALWAYS_INLINE hash128( size_t i, size_t keys_size, const ColumnRawPtrs & key_columns) { diff --git a/dbms/src/Interpreters/Aggregator.cpp b/dbms/src/Interpreters/Aggregator.cpp index 49c519cc5f3..f4874a748bd 100644 --- a/dbms/src/Interpreters/Aggregator.cpp +++ b/dbms/src/Interpreters/Aggregator.cpp @@ -480,8 +480,6 @@ AggregatedDataVariants::Type Aggregator::chooseAggregationMethod() return AggregatedDataVariants::Type::key_fixed_string; return AggregatedDataVariants::Type::serialized; - - /// NOTE AggregatedDataVariants::Type::hashed is not used. It's proven to be less efficient than 'serialized' in most cases. } diff --git a/dbms/src/Interpreters/Aggregator.h b/dbms/src/Interpreters/Aggregator.h index 43a49f42c96..5eff86a4bc4 100644 --- a/dbms/src/Interpreters/Aggregator.h +++ b/dbms/src/Interpreters/Aggregator.h @@ -67,13 +67,11 @@ using AggregatedDataWithUInt64Key = HashMap; using AggregatedDataWithKeys128 = HashMap; using AggregatedDataWithKeys256 = HashMap; -using AggregatedDataHashed = HashMap, UInt128TrivialHash>; using AggregatedDataWithUInt64KeyTwoLevel = TwoLevelHashMap>; using AggregatedDataWithStringKeyTwoLevel = TwoLevelHashMapWithSavedHash; using AggregatedDataWithKeys128TwoLevel = TwoLevelHashMap; using AggregatedDataWithKeys256TwoLevel = TwoLevelHashMap; -using AggregatedDataHashedTwoLevel = TwoLevelHashMap, UInt128TrivialHash>; /** Variants with better hash function, using more than 32 bits for hash. * Using for merging phase of external aggregation, where number of keys may be far greater than 4 billion, @@ -550,61 +548,6 @@ struct AggregationMethodSerialized }; -/// For other cases. Aggregates by 128-bit hash from the key. -template -struct AggregationMethodHashed -{ - using Data = TData; - using Key = typename Data::key_type; - using Mapped = typename Data::mapped_type; - using iterator = typename Data::iterator; - using const_iterator = typename Data::const_iterator; - - Data data; - - AggregationMethodHashed() {} - - template - AggregationMethodHashed(const Other & other) : data(other.data) {} - - struct State - { - void init(ColumnRawPtrs &) - { - } - - ALWAYS_INLINE Key getKey( - const ColumnRawPtrs & key_columns, - size_t keys_size, - size_t i, - const Sizes &, - StringRefs & keys, - Arena &) const - { - return hash128(i, keys_size, key_columns, keys); - } - }; - - static AggregateDataPtr & getAggregateData(Mapped & value) { return value.second; } - static const AggregateDataPtr & getAggregateData(const Mapped & value) { return value.second; } - - static ALWAYS_INLINE void onNewKey(typename Data::value_type & value, size_t keys_size, StringRefs & keys, Arena & pool) - { - value.second.first = placeKeysInPool(keys_size, keys, pool); - } - - static ALWAYS_INLINE void onExistingKey(const Key &, StringRefs &, Arena &) {} - - static const bool no_consecutive_keys_optimization = false; - - static void insertKeyIntoColumns(const typename Data::value_type & value, MutableColumns & key_columns, size_t keys_size, const Sizes &) - { - for (size_t i = 0; i < keys_size; ++i) - key_columns[i]->insertDataWithTerminatingZero(value.second.first[i].data, value.second.first[i].size); - } -}; - - class Aggregator; struct AggregatedDataVariants : private boost::noncopyable @@ -648,7 +591,6 @@ struct AggregatedDataVariants : private boost::noncopyable std::unique_ptr> key_fixed_string; std::unique_ptr> keys128; std::unique_ptr> keys256; - std::unique_ptr> hashed; std::unique_ptr> serialized; std::unique_ptr> key32_two_level; @@ -657,7 +599,6 @@ struct AggregatedDataVariants : private boost::noncopyable std::unique_ptr> key_fixed_string_two_level; std::unique_ptr> keys128_two_level; std::unique_ptr> keys256_two_level; - std::unique_ptr> hashed_two_level; std::unique_ptr> serialized_two_level; std::unique_ptr> key64_hash64; @@ -683,7 +624,6 @@ struct AggregatedDataVariants : private boost::noncopyable M(key_fixed_string, false) \ M(keys128, false) \ M(keys256, false) \ - M(hashed, false) \ M(serialized, false) \ M(key32_two_level, true) \ M(key64_two_level, true) \ @@ -691,7 +631,6 @@ struct AggregatedDataVariants : private boost::noncopyable M(key_fixed_string_two_level, true) \ M(keys128_two_level, true) \ M(keys256_two_level, true) \ - M(hashed_two_level, true) \ M(serialized_two_level, true) \ M(key64_hash64, false) \ M(key_string_hash64, false) \ @@ -817,7 +756,6 @@ struct AggregatedDataVariants : private boost::noncopyable M(key_fixed_string) \ M(keys128) \ M(keys256) \ - M(hashed) \ M(serialized) \ M(nullable_keys128) \ M(nullable_keys256) \ @@ -860,7 +798,6 @@ struct AggregatedDataVariants : private boost::noncopyable M(key_fixed_string_two_level) \ M(keys128_two_level) \ M(keys256_two_level) \ - M(hashed_two_level) \ M(serialized_two_level) \ M(nullable_keys128_two_level) \ M(nullable_keys256_two_level)