Fix error

This commit is contained in:
Alexey Milovidov 2022-09-18 09:20:48 +02:00
parent c41e37fa8e
commit 5c75a7d661
2 changed files with 7 additions and 14 deletions

View File

@ -5,8 +5,9 @@
#include <type_traits>
/** \brief Returns value `from` converted to type `To` while retaining bit representation.
/** Returns value `from` converted to type `To` while retaining bit representation.
* `To` and `From` must satisfy `CopyConstructible`.
* In contrast to std::bit_cast can cast types of different width.
*/
template <typename To, typename From>
std::decay_t<To> bit_cast(const From & from)
@ -15,13 +16,3 @@ std::decay_t<To> bit_cast(const From & from)
memcpy(static_cast<void*>(&res), &from, std::min(sizeof(res), sizeof(from)));
return res;
}
/** \brief Returns value `from` converted to type `To` while retaining bit representation.
* `To` and `From` must satisfy `CopyConstructible`.
*/
template <typename To, typename From>
std::decay_t<To> safe_bit_cast(const From & from)
{
static_assert(sizeof(To) == sizeof(From), "bit cast on types of different width");
return bit_cast<To, From>(from);
}

View File

@ -1,6 +1,7 @@
#include <mutex>
#include <base/bit_cast.h>
#include <Common/FieldVisitorDump.h>
#include <Common/FieldVisitorConvertToNumber.h>
#include <DataTypes/DataTypeArray.h>
#include <Columns/ColumnString.h>
@ -920,8 +921,7 @@ private:
ColumnString::Offset current_dst_default_offset = 0;
for (size_t i = 0; i < size; ++i)
{
T key = src[i];
const auto * it = table.find(key);
const auto * it = table.find(bit_cast<UInt64>(src[i]));
StringRef ref;
if (it)
@ -1181,6 +1181,8 @@ private:
if (key.isNull())
continue;
std::cerr << applyVisitor(FieldVisitorDump(), key) << ": " << bitCastToUInt64(key) << "\n";
const String & str_to = to[i].get<const String &>();
StringRef ref{cache.string_pool.insert(str_to.data(), str_to.size() + 1), str_to.size() + 1};
table[bitCastToUInt64(key)] = ref;