MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / insert

Method insert

sql/sql_hset.h:57–65  ·  view source on GitHub ↗

Insert a single value into a hash. Does not tell whether the value was inserted -- if an identical value existed, it is not replaced. @retval TRUE Out of memory. @retval FALSE OK. The value either was inserted or existed in the hash. */

Source from the content-addressed store, hash-verified

55 in the hash.
56 */
57 bool insert(T *value)
58 {
59 my_hash_init_opt(&m_hash, &my_charset_bin, START_SIZE, 0, 0, K, 0, MYF(0));
60 size_t key_len;
61 const uchar *key= K(reinterpret_cast<uchar*>(value), &key_len, FALSE);
62 if (my_hash_search(&m_hash, key, key_len) == NULL)
63 return my_hash_insert(&m_hash, reinterpret_cast<uchar *>(value));
64 return FALSE;
65 }
66 /** Is this hash set empty? */
67 bool is_empty() const { return m_hash.records == 0; }
68 /** Returns the number of unique elements. */

Callers

nothing calls this directly

Calls 2

my_hash_searchFunction · 0.85
my_hash_insertFunction · 0.85

Tested by

no test coverage detected