mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 12:22:12 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <Common/HashTable/StringHashMap.h>
|
|
#include <Common/HashTable/TwoLevelStringHashTable.h>
|
|
|
|
template <typename TMapped, typename Allocator = HashTableAllocator, template <typename...> typename ImplTable = StringHashMap>
|
|
class TwoLevelStringHashMap : public TwoLevelStringHashTable<StringHashMapSubMaps<TMapped, Allocator>, ImplTable<TMapped, Allocator>>
|
|
{
|
|
public:
|
|
using Key = StringRef;
|
|
using Self = TwoLevelStringHashMap;
|
|
using Base = TwoLevelStringHashTable<StringHashMapSubMaps<TMapped, Allocator>, StringHashMap<TMapped, Allocator>>;
|
|
using LookupResult = typename Base::LookupResult;
|
|
|
|
using Base::Base;
|
|
|
|
template <typename Func>
|
|
void ALWAYS_INLINE forEachMapped(Func && func)
|
|
{
|
|
for (auto i = 0u; i < this->NUM_BUCKETS; ++i)
|
|
return this->impls[i].forEachMapped(func);
|
|
}
|
|
|
|
TMapped & ALWAYS_INLINE operator[](const Key & x)
|
|
{
|
|
bool inserted;
|
|
LookupResult it;
|
|
this->emplace(x, it, inserted);
|
|
if (inserted)
|
|
new (&it->getMapped()) TMapped();
|
|
return it->getMapped();
|
|
}
|
|
};
|