From f360f244eb6ff0683f3d8833385c9ecf999c7f2f Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 25 Dec 2014 03:19:29 +0300 Subject: [PATCH] dbms: tiny modifications [#METR-2944]. --- dbms/include/DB/Common/HashTable/HashMap.h | 2 ++ dbms/include/DB/Common/HashTable/HashTable.h | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) 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()