mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 07:01:59 +00:00
Backport #70979 to 24.9: Fix an error with negative zeros in two-level hash table
This commit is contained in:
parent
6a127867df
commit
9384ab24de
@ -369,11 +369,15 @@ namespace PackedZeroTraits
|
||||
{
|
||||
template <typename Second, template <typename, typename> class PackedPairNoInit>
|
||||
inline bool check(const PackedPairNoInit<StringRef, Second> p)
|
||||
{ return 0 == p.key.size; }
|
||||
{
|
||||
return 0 == p.key.size;
|
||||
}
|
||||
|
||||
template <typename Second, template <typename, typename> class PackedPairNoInit>
|
||||
inline void set(PackedPairNoInit<StringRef, Second> & p)
|
||||
{ p.key.size = 0; }
|
||||
{
|
||||
p.key.size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,19 +67,6 @@ struct HashTableNoState
|
||||
};
|
||||
|
||||
|
||||
/// These functions can be overloaded for custom types.
|
||||
namespace ZeroTraits
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
bool check(const T x) { return x == T{}; }
|
||||
|
||||
template <typename T>
|
||||
void set(T & x) { x = T{}; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** Numbers are compared bitwise.
|
||||
* Complex types are compared by operator== as usual (this is important if there are gaps).
|
||||
*
|
||||
@ -87,18 +74,32 @@ void set(T & x) { x = T{}; }
|
||||
* Otherwise the invariants in hash table probing do not met when NaNs are present.
|
||||
*/
|
||||
template <typename T>
|
||||
inline bool bitEquals(T && a, T && b)
|
||||
inline bool bitEquals(T a, T b)
|
||||
{
|
||||
using RealT = std::decay_t<T>;
|
||||
|
||||
if constexpr (std::is_floating_point_v<RealT>)
|
||||
/// Note that memcmp with constant size is compiler builtin.
|
||||
return 0 == memcmp(&a, &b, sizeof(RealT)); /// NOLINT
|
||||
if constexpr (std::is_floating_point_v<T>)
|
||||
/// Note that memcmp with constant size is a compiler builtin.
|
||||
return 0 == memcmp(&a, &b, sizeof(T)); /// NOLINT
|
||||
else
|
||||
return a == b;
|
||||
}
|
||||
|
||||
|
||||
/// These functions can be overloaded for custom types.
|
||||
namespace ZeroTraits
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
bool check(const T x)
|
||||
{
|
||||
return bitEquals(x, T{});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void set(T & x) { x = T{}; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getKey/Mapped -- methods to get key/"mapped" values from the LookupResult returned by find() and
|
||||
* emplace() methods of HashTable. Must not be called for a null LookupResult.
|
||||
|
@ -0,0 +1 @@
|
||||
7992019
|
@ -0,0 +1 @@
|
||||
WITH number % 1000 = 0 ? (rand() % 2 ? 0.0 : -0.0) : number::Float64 AS x SELECT length(uniqExactState(x)::String) FROM numbers(1000000);
|
Loading…
Reference in New Issue
Block a user