24#ifndef MAP_HELPERS_INCLUDED
25#define MAP_HELPERS_INCLUDED
31#include <unordered_map>
32#include <unordered_set>
53template <
class Container,
class Key>
56 if constexpr (std::is_pointer_v<typename Container::mapped_type>) {
67template <
class Container,
class Value>
72 for (
auto it = it_range.first; it != it_range.second; ++it) {
73 if constexpr (std::is_pointer_v<typename Container::mapped_type>) {
74 if (it->second == value)
return container->erase(it);
77 if (it->second.get() == value)
return container->erase(it);
115 hash_sort(
cs, pointer_cast<const uchar *>(s.data()), s.size(), &nr1, &nr2);
130 size_t operator()(
const std::string &a,
const std::string &b)
const {
131 return strnncollsp(
cs, pointer_cast<const uchar *>(a.data()), a.size(),
132 pointer_cast<const uchar *>(b.data()), b.size()) == 0;
141template <
class Key,
class Value>
145template <
class Key,
class Value,
class Compare = std::less<Key>>
147 std::map<Key, Value, Compare, Map_allocator_type<Key, Value>>;
153template <
class Key,
class Value,
class Hash = std::hash<Key>,
154 class KeyEqual = std::equal_to<Key>>
157 Malloc_allocator<std::pair<const Key, Value>>> {
166 10,
Hash(), KeyEqual(),
174template <
class Key,
class Hash = std::hash<Key>,
175 class KeyEqual = std::equal_to<Key>>
185 10,
Hash(), KeyEqual(),
193template <
class Key,
class Value,
class Hash = std::hash<Key>,
194 class KeyEqual = std::equal_to<Key>>
196 :
public std::unordered_multimap<
197 Key, Value, Hash, KeyEqual,
198 Malloc_allocator<std::pair<const Key, Value>>> {
208 10,
Hash(), KeyEqual(),
215template <
class Key,
class Value>
219 Malloc_allocator<std::pair<const Key, Value>>> {
231template <
class Key,
class Value>
233 :
public std::unordered_multimap<
234 Key, Value, Collation_hasher, Collation_key_equal,
235 Malloc_allocator<std::pair<const Key, Value>>> {
251 Malloc_allocator<Key>> {
267template <
class Key,
class Hash = std::hash<Key>,
268 class KeyEqual = std::equal_to<Key>>
277 KeyEqual key_equal_arg = KeyEqual())
279 10, hash, key_equal_arg,
286template <
class Key,
class Value,
class Hash = std::hash<Key>,
287 class KeyEqual = std::equal_to<Key>>
290 Key, Value, Hash, KeyEqual,
291 Mem_root_allocator<std::pair<const Key, Value>>> {
296 10, hash, KeyEqual(),
303template <
class Key,
class Value,
class Hash = std::hash<Key>,
304 class KeyEqual = std::equal_to<Key>>
306 :
public std::unordered_multimap<
307 Key, Value, Hash, KeyEqual,
308 Mem_root_allocator<std::pair<const Key, Value>>> {
311 :
std::unordered_multimap<
314 10, hash, KeyEqual(),
321template <
class Key,
class Value>
324 Key, Value, Collation_hasher, Collation_key_equal,
325 Mem_root_allocator<std::pair<const Key, Value>>> {
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
A Hasher that hashes std::strings according to a MySQL collation.
Definition: map_helpers.h:108
decltype(cs->coll->hash_sort) hash_sort
Definition: map_helpers.h:121
Collation_hasher(const CHARSET_INFO *cs_arg)
Definition: map_helpers.h:110
const CHARSET_INFO * cs
Definition: map_helpers.h:120
size_t operator()(const std::string &s) const
Definition: map_helpers.h:113
A KeyEqual that compares std::strings according to a MySQL collation.
Definition: map_helpers.h:125
decltype(cs->coll->strnncollsp) strnncollsp
Definition: map_helpers.h:137
Collation_key_equal(const CHARSET_INFO *cs_arg)
Definition: map_helpers.h:127
size_t operator()(const std::string &a, const std::string &b) const
Definition: map_helpers.h:130
const CHARSET_INFO * cs
Definition: map_helpers.h:136
Malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: malloc_allocator.h:63
Mem_root_allocator is a C++ STL memory allocator based on MEM_ROOT.
Definition: mem_root_allocator.h:68
std::unordered_map, but with my_malloc and collation-aware comparison.
Definition: map_helpers.h:219
collation_unordered_map(const CHARSET_INFO *cs, PSI_memory_key psi_key)
Definition: map_helpers.h:221
std::unordered_multimap, but with my_malloc and collation-aware comparison.
Definition: map_helpers.h:235
collation_unordered_multimap(CHARSET_INFO *cs, PSI_memory_key psi_key)
Definition: map_helpers.h:237
std::unordered_set, but with my_malloc and collation-aware comparison.
Definition: map_helpers.h:251
collation_unordered_set(std::initializer_list< Key > il, CHARSET_INFO *cs, PSI_memory_key psi_key)
Definition: map_helpers.h:258
collation_unordered_set(CHARSET_INFO *cs, PSI_memory_key psi_key)
Definition: map_helpers.h:253
std::unordered_map, but with my_malloc, so that you can track the memory used using PSI memory keys.
Definition: map_helpers.h:157
malloc_unordered_map(PSI_memory_key psi_key)
Definition: map_helpers.h:163
std::unordered_multimap, but with my_malloc, so that you can track the memory used using PSI memory k...
Definition: map_helpers.h:198
malloc_unordered_multimap(PSI_memory_key psi_key)
Definition: map_helpers.h:205
std::unordered_set, but with my_malloc, so that you can track the memory used using PSI memory keys.
Definition: map_helpers.h:177
malloc_unordered_set(PSI_memory_key psi_key)
Definition: map_helpers.h:183
std::unordered_map, but collation aware and allocated on a MEM_ROOT.
Definition: map_helpers.h:325
mem_root_collation_unordered_map(const CHARSET_INFO *cs, MEM_ROOT *mem_root)
Definition: map_helpers.h:327
std::unordered_map, but allocated on a MEM_ROOT.
Definition: map_helpers.h:291
mem_root_unordered_map(MEM_ROOT *mem_root, Hash hash=Hash())
Definition: map_helpers.h:293
std::unordered_multimap, but allocated on a MEM_ROOT.
Definition: map_helpers.h:308
mem_root_unordered_multimap(MEM_ROOT *mem_root, Hash hash=Hash())
Definition: map_helpers.h:310
std::unordered_set, but allocated on a MEM_ROOT.
Definition: map_helpers.h:270
mem_root_unordered_set(MEM_ROOT *mem_root, Hash hash=Hash(), KeyEqual key_equal_arg=KeyEqual())
Definition: map_helpers.h:276
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
#define free(A)
Definition: lexyy.cc:915
A better implementation of the UNIX ctype(3) library.
Container::iterator erase_specific_element(Container *container, const typename Container::key_type &key, const Value &value)
For unordered_multimap<Key, Value>, erase the first specific element that matches both the given key ...
Definition: map_helpers.h:68
std::unique_ptr< T, Free_deleter > unique_ptr_free
std::unique_ptr, but with free as deleter.
Definition: map_helpers.h:105
std::unique_ptr< T, My_free_deleter > unique_ptr_my_free
std::unique_ptr, but with my_free as deleter.
Definition: map_helpers.h:97
std::unique_ptr< T, void(*)(T *)> unique_ptr_with_deleter
std::unique_ptr, but with a custom delete function.
Definition: map_helpers.h:89
static auto find_or_nullptr(const Container &container, const Key &key)
Some useful helpers for associative arrays with MySQL-specific semantics.
Definition: map_helpers.h:54
std::map< Key, Value, Compare, Map_allocator_type< Key, Value > > Map_myalloc
Map using custom Malloc_allocator allocator.
Definition: map_helpers.h:147
Some integer typedefs for easier portability.
uint64_t uint64
Definition: my_inttypes.h:69
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
std::unordered_map< Key, CHARSET_INFO * > Hash
Definition: collations_internal.cc:548
Definition: atomics_array.h:39
Definition: commit_order_queue.h:34
std::string_view Key
The key type for the hash structure in HashJoinRowBuffer.
Definition: hash_join_buffer.h:102
int key_type
Definition: method.h:38
Definition: gcs_xcom_synode.h:64
std::unordered_map< Key, Value, Hash, Key_equal, ut::allocator< std::pair< const Key, Value > > > unordered_map
Definition: ut0new.h:2899
std::unordered_set< Key, std::hash< Key >, std::equal_to< Key >, ut::allocator< Key > > unordered_set
Definition: ut0new.h:2888
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2439
required string key
Definition: replication_asynchronous_connection_failover.proto:60
Definition: m_ctype.h:423
Definition: map_helpers.h:99
void operator()(void *ptr) const
Definition: map_helpers.h:100
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: map_helpers.h:91
void operator()(void *ptr) const
Definition: map_helpers.h:92