2014-12-24 19:00:14 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/Common/HashTable/TwoLevelHashTable.h>
|
|
|
|
#include <DB/Common/HashTable/HashMap.h>
|
|
|
|
|
|
|
|
|
|
|
|
template
|
|
|
|
<
|
|
|
|
typename Key,
|
|
|
|
typename Cell,
|
|
|
|
typename Hash = DefaultHash<Key>,
|
2014-12-26 03:00:51 +00:00
|
|
|
typename Grower = TwoLevelHashTableGrower<>,
|
2014-12-24 19:00:14 +00:00
|
|
|
typename Allocator = HashTableAllocator
|
|
|
|
>
|
2014-12-30 20:38:05 +00:00
|
|
|
class TwoLevelHashMapTable : public TwoLevelHashTable<Key, Cell, Hash, Grower, Allocator, HashMapTable<Key, Cell, Hash, Grower, Allocator>>
|
2014-12-24 19:00:14 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef Key key_type;
|
|
|
|
typedef typename Cell::Mapped mapped_type;
|
|
|
|
typedef typename Cell::value_type value_type;
|
|
|
|
|
2014-12-30 12:58:02 +00:00
|
|
|
using TwoLevelHashTable<Key, Cell, Hash, Grower, Allocator, HashMapTable<Key, Cell, Hash, Grower, Allocator> >::TwoLevelHashTable;
|
|
|
|
|
2014-12-30 11:27:58 +00:00
|
|
|
mapped_type & ALWAYS_INLINE operator[](Key x)
|
2014-12-24 19:00:14 +00:00
|
|
|
{
|
|
|
|
typename TwoLevelHashMapTable::iterator it;
|
|
|
|
bool inserted;
|
|
|
|
this->emplace(x, it, inserted);
|
|
|
|
|
2015-03-07 01:03:14 +00:00
|
|
|
if (inserted)
|
2014-12-24 19:00:14 +00:00
|
|
|
new(&it->second) mapped_type();
|
|
|
|
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template
|
|
|
|
<
|
|
|
|
typename Key,
|
|
|
|
typename Mapped,
|
|
|
|
typename Hash = DefaultHash<Key>,
|
2014-12-26 03:00:51 +00:00
|
|
|
typename Grower = TwoLevelHashTableGrower<>,
|
2014-12-24 19:00:14 +00:00
|
|
|
typename Allocator = HashTableAllocator
|
|
|
|
>
|
|
|
|
using TwoLevelHashMap = TwoLevelHashMapTable<Key, HashMapCell<Key, Mapped, Hash>, Hash, Grower, Allocator>;
|
|
|
|
|
|
|
|
|
|
|
|
template
|
|
|
|
<
|
|
|
|
typename Key,
|
|
|
|
typename Mapped,
|
|
|
|
typename Hash = DefaultHash<Key>,
|
2014-12-26 03:00:51 +00:00
|
|
|
typename Grower = TwoLevelHashTableGrower<>,
|
2014-12-24 19:00:14 +00:00
|
|
|
typename Allocator = HashTableAllocator
|
|
|
|
>
|
2014-12-30 20:38:05 +00:00
|
|
|
using TwoLevelHashMapWithSavedHash = TwoLevelHashMapTable<Key, HashMapCellWithSavedHash<Key, Mapped, Hash>, Hash, Grower, Allocator>;
|