dbms: more scalable aggragator: preparation [#METR-2944].

This commit is contained in:
Alexey Milovidov 2014-12-24 22:00:14 +03:00
parent 7da67fd139
commit 32a2ec00d1
2 changed files with 56 additions and 0 deletions

View 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>;

View File

@ -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 <>