diff --git a/dbms/include/DB/Common/HashTable/HashMap.h b/dbms/include/DB/Common/HashTable/HashMap.h index 82664e21a59..b73ccb7ab88 100644 --- a/dbms/include/DB/Common/HashTable/HashMap.h +++ b/dbms/include/DB/Common/HashTable/HashMap.h @@ -129,6 +129,8 @@ public: typedef typename Cell::Mapped mapped_type; typedef typename Cell::value_type value_type; + using HashTable::HashTable; + mapped_type & operator[](Key x) { typename HashMapTable::iterator it; diff --git a/dbms/include/DB/Common/HashTable/HashTable.h b/dbms/include/DB/Common/HashTable/HashTable.h index 16f07e526a2..92e656456cd 100644 --- a/dbms/include/DB/Common/HashTable/HashTable.h +++ b/dbms/include/DB/Common/HashTable/HashTable.h @@ -240,7 +240,7 @@ protected: Grower grower; #ifdef DBMS_HASH_MAP_COUNT_COLLISIONS - mutable size_t collisions; + mutable size_t collisions = 0; #endif /// Найти ячейку с тем же ключём или пустую ячейку, начиная с заданного места и далее по цепочке разрешения коллизий. @@ -372,10 +372,14 @@ public: if (Cell::need_zero_value_storage) this->zeroValue()->setZero(); alloc(grower); + } -#ifdef DBMS_HASH_MAP_COUNT_COLLISIONS - collisions = 0; -#endif + HashTable(size_t reserve_for_num_elements) + { + if (Cell::need_zero_value_storage) + this->zeroValue()->setZero(); + grower.set(reserve_for_num_elements); + alloc(grower); } ~HashTable()