Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipv4 read fix #398

Open
wants to merge 2 commits into
base: z-build
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Common/HashTable/Hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ requires (sizeof(T) <= sizeof(UInt64))
inline size_t hashCRC32(T key, DB::UInt64 updated_value = -1)
{
DB::UInt64 out {0};
std::memcpy(&out, &key, sizeof(T));
if constexpr (std::endian::native == std::endian::little)
std::memcpy(&out, &key, sizeof(T));
else
std::memcpy(reinterpret_cast<char*>(&out) + sizeof(UInt64) - sizeof(T), &key, sizeof(T));
return intHashCRC32(out, updated_value);
}

Expand Down
4 changes: 2 additions & 2 deletions src/DataTypes/Serializations/SerializationIPv4andIPv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ class SerializationIP : public SimpleTextSerialization
void serializeBinary(const Field & field, WriteBuffer & ostr, const FormatSettings &) const override
{
IPv x = field.get<IPv>();
writeBinary(x, ostr);
writeBinaryLittleEndian(x, ostr);
}
void deserializeBinary(Field & field, ReadBuffer & istr, const FormatSettings &) const override
{
IPv x;
readBinary(x.toUnderType(), istr);
readBinaryLittleEndian(x.toUnderType(), istr);
field = NearestFieldType<IPv>(x);
}
void serializeBinary(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override
Expand Down