mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 17:20:50 +00:00
dbms: more scalable aggragator: preparation [#METR-2944].
This commit is contained in:
parent
7da67fd139
commit
32a2ec00d1
55
dbms/include/DB/Common/HashTable/TwoLevelHashMap.h
Normal file
55
dbms/include/DB/Common/HashTable/TwoLevelHashMap.h
Normal file
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include <DB/Common/HashTable/TwoLevelHashTable.h>
|
||||
#include <DB/Common/HashTable/HashMap.h>
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Key,
|
||||
typename Cell,
|
||||
typename Hash = DefaultHash<Key>,
|
||||
typename Grower = HashTableGrower<8>,
|
||||
typename Allocator = HashTableAllocator
|
||||
>
|
||||
class TwoLevelHashMapTable : public TwoLevelHashTable<Key, Cell, Hash, Grower, Allocator, HashMapTable<Key, Cell, Hash, Grower, Allocator> >
|
||||
{
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef typename Cell::Mapped mapped_type;
|
||||
typedef typename Cell::value_type value_type;
|
||||
|
||||
mapped_type & operator[](Key x)
|
||||
{
|
||||
typename TwoLevelHashMapTable::iterator it;
|
||||
bool inserted;
|
||||
this->emplace(x, it, inserted);
|
||||
|
||||
if (!__has_trivial_constructor(mapped_type) && inserted)
|
||||
new(&it->second) mapped_type();
|
||||
|
||||
return it->second;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Key,
|
||||
typename Mapped,
|
||||
typename Hash = DefaultHash<Key>,
|
||||
typename Grower = HashTableGrower<8>,
|
||||
typename Allocator = HashTableAllocator
|
||||
>
|
||||
using TwoLevelHashMap = TwoLevelHashMapTable<Key, HashMapCell<Key, Mapped, Hash>, Hash, Grower, Allocator>;
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Key,
|
||||
typename Mapped,
|
||||
typename Hash = DefaultHash<Key>,
|
||||
typename Grower = HashTableGrower<8>,
|
||||
typename Allocator = HashTableAllocator
|
||||
>
|
||||
using TwoLevelHashMapWithSavedHash = TwoLevelHashMapTable<Key, HashMapCellWithSavedHash<Key, Mapped, Hash>, Hash, Grower, Allocator>;
|
@ -10,6 +10,7 @@
|
||||
#include <DB/Core/StringRef.h>
|
||||
#include <DB/Columns/IColumn.h>
|
||||
#include <DB/Common/HashTable/HashMap.h>
|
||||
#include <DB/Common/HashTable/TwoLevelHashMap.h>
|
||||
|
||||
|
||||
template <>
|
||||
|
Loading…
Reference in New Issue
Block a user