mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 19:02:04 +00:00
100c055510
* impl * stash * clean up * do not apply when HT is small * make branch static * also in merge * do not hardcode look ahead value * fix * apply to methods with cheap key calculation * more tests * silence tidy * fix build * support HashMethodKeysFixed * apply during merge only for cheap * stash * fixes * rename method * add feature flag * cache prefetch threshold value * fix * fix * Update HashMap.h * fix typo * 256KB as default l2 size Co-authored-by: Alexey Milovidov <milovidov@clickhouse.com>
69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <Common/HashTable/TwoLevelHashTable.h>
|
|
#include <Common/HashTable/HashMap.h>
|
|
|
|
|
|
template
|
|
<
|
|
typename Key,
|
|
typename Cell,
|
|
typename Hash = DefaultHash<Key>,
|
|
typename Grower = TwoLevelHashTableGrower<>,
|
|
typename Allocator = HashTableAllocator,
|
|
template <typename ...> typename ImplTable = HashMapTable
|
|
>
|
|
class TwoLevelHashMapTable : public TwoLevelHashTable<Key, Cell, Hash, Grower, Allocator, ImplTable<Key, Cell, Hash, Grower, Allocator>>
|
|
{
|
|
public:
|
|
using Impl = ImplTable<Key, Cell, Hash, Grower, Allocator>;
|
|
using Base = TwoLevelHashTable<Key, Cell, Hash, Grower, Allocator, ImplTable<Key, Cell, Hash, Grower, Allocator>>;
|
|
using LookupResult = typename Impl::LookupResult;
|
|
|
|
using Base::Base;
|
|
using Base::prefetch;
|
|
|
|
template <typename Func>
|
|
void ALWAYS_INLINE forEachMapped(Func && func)
|
|
{
|
|
for (auto i = 0u; i < this->NUM_BUCKETS; ++i)
|
|
this->impls[i].forEachMapped(func);
|
|
}
|
|
|
|
typename Cell::Mapped & ALWAYS_INLINE operator[](const Key & x)
|
|
{
|
|
LookupResult it;
|
|
bool inserted;
|
|
this->emplace(x, it, inserted);
|
|
|
|
if (inserted)
|
|
new (&it->getMapped()) typename Cell::Mapped();
|
|
|
|
return it->getMapped();
|
|
}
|
|
};
|
|
|
|
|
|
template
|
|
<
|
|
typename Key,
|
|
typename Mapped,
|
|
typename Hash = DefaultHash<Key>,
|
|
typename Grower = TwoLevelHashTableGrower<>,
|
|
typename Allocator = HashTableAllocator,
|
|
template <typename ...> typename ImplTable = HashMapTable
|
|
>
|
|
using TwoLevelHashMap = TwoLevelHashMapTable<Key, HashMapCell<Key, Mapped, Hash>, Hash, Grower, Allocator, ImplTable>;
|
|
|
|
|
|
template
|
|
<
|
|
typename Key,
|
|
typename Mapped,
|
|
typename Hash = DefaultHash<Key>,
|
|
typename Grower = TwoLevelHashTableGrower<>,
|
|
typename Allocator = HashTableAllocator,
|
|
template <typename ...> typename ImplTable = HashMapTable
|
|
>
|
|
using TwoLevelHashMapWithSavedHash = TwoLevelHashMapTable<Key, HashMapCellWithSavedHash<Key, Mapped, Hash>, Hash, Grower, Allocator, ImplTable>;
|