mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Use Cell::setMapped() over separate helper insertSetMapped()
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
2996b38606
commit
7c8d8eeb56
@ -358,7 +358,7 @@ public:
|
||||
std::pair<LookupResult, bool> res;
|
||||
emplace(Cell::getKey(x), res.first, res.second);
|
||||
if (res.second)
|
||||
insertSetMapped(res.first->getMapped(), x);
|
||||
res.first->setMapped(x);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ inline bool bitEquals(T && a, T && b)
|
||||
* 3) Hash tables that store the key and do not have a "mapped" value, e.g. the normal HashTable.
|
||||
* GetKey returns the key, and GetMapped returns a zero void pointer. This simplifies generic
|
||||
* code that works with mapped values: it can overload on the return type of GetMapped(), and
|
||||
* doesn't need other parameters. One example is insertSetMapped() function.
|
||||
* doesn't need other parameters. One example is Cell::setMapped() function.
|
||||
*
|
||||
* 4) Hash tables that store both the key and the "mapped" value, e.g. HashMap. Both GetKey and
|
||||
* GetMapped are supported.
|
||||
@ -216,17 +216,6 @@ struct HashTableCell
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* A helper function for HashTable::insert() to set the "mapped" value.
|
||||
* Overloaded on the mapped type, does nothing if it's VoidMapped.
|
||||
*/
|
||||
template <typename ValueType>
|
||||
void insertSetMapped(VoidMapped /* dest */, const ValueType & /* src */) {}
|
||||
|
||||
template <typename MappedType, typename ValueType>
|
||||
void insertSetMapped(MappedType & dest, const ValueType & src) { dest = src.second; }
|
||||
|
||||
|
||||
/** Determines the size of the hash table, and when and how much it should be resized.
|
||||
* Has very small state (one UInt8) and useful for Set-s allocated in automatic memory (see uniqExact as an example).
|
||||
*/
|
||||
@ -1046,7 +1035,7 @@ public:
|
||||
}
|
||||
|
||||
if (res.second)
|
||||
insertSetMapped(res.first->getMapped(), x);
|
||||
res.first->setMapped(x);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ public:
|
||||
emplace(Cell::getKey(x), res.first, res.second, hash_value);
|
||||
|
||||
if (res.second)
|
||||
insertSetMapped(res.first->getMapped(), x);
|
||||
res.first->setMapped(x);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user