mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
#15182_MaterializeMySQL_support_bit_type-improve bit2Uint64 function
This commit is contained in:
parent
4a0554c963
commit
039afc5cfe
@ -589,13 +589,9 @@ namespace MySQLReplication
|
||||
{
|
||||
UInt32 bits = ((meta >> 8) * 8) + (meta & 0xff);
|
||||
UInt32 size = (bits + 7) / 8;
|
||||
|
||||
Bitmap bitmap_value;
|
||||
String byte_buffer;
|
||||
byte_buffer.resize(size);
|
||||
readBigEndianStrict(payload, reinterpret_cast<char *>(byte_buffer.data()), size);
|
||||
readBitmapFromStr(byte_buffer.c_str(), bitmap_value, size);
|
||||
row.push_back(Field{UInt64{bitmap_value.to_ulong()}});
|
||||
UInt64 val = 0UL;
|
||||
readBigEndianStrict(payload, reinterpret_cast<char *>(&val), size);
|
||||
row.push_back(val);
|
||||
break;
|
||||
}
|
||||
case MYSQL_TYPE_VARCHAR:
|
||||
|
@ -78,8 +78,11 @@ namespace MySQLReplication
|
||||
}
|
||||
}
|
||||
|
||||
inline void readBitmapFromStr(const char * byte_buffer, Bitmap & bitmap, size_t bitmap_size)
|
||||
inline void readBitmap(ReadBuffer & payload, Bitmap & bitmap, size_t bitmap_size)
|
||||
{
|
||||
String byte_buffer;
|
||||
byte_buffer.resize(bitmap_size);
|
||||
payload.readStrict(reinterpret_cast<char *>(byte_buffer.data()), bitmap_size);
|
||||
bitmap.resize(bitmap_size * 8, false);
|
||||
for (size_t i = 0; i < bitmap_size; ++i)
|
||||
{
|
||||
@ -106,14 +109,6 @@ namespace MySQLReplication
|
||||
}
|
||||
}
|
||||
|
||||
inline void readBitmap(ReadBuffer & payload, Bitmap & bitmap, size_t bitmap_size)
|
||||
{
|
||||
String byte_buffer;
|
||||
byte_buffer.resize(bitmap_size);
|
||||
payload.readStrict(reinterpret_cast<char *>(byte_buffer.data()), bitmap_size);
|
||||
readBitmapFromStr(byte_buffer.c_str(), bitmap, bitmap_size);
|
||||
}
|
||||
|
||||
class EventBase;
|
||||
using BinlogEventPtr = std::shared_ptr<EventBase>;
|
||||
|
||||
|
@ -149,11 +149,10 @@ namespace
|
||||
if (static_cast<int>(mysql_type) == 16)
|
||||
{
|
||||
size_t n = value.size();
|
||||
char *start = const_cast<char *>(value.data()), *end = start + n;
|
||||
std::reverse(start, end);
|
||||
MySQLReplication::Bitmap bitmap;
|
||||
MySQLReplication::readBitmapFromStr(value.data(), bitmap, n);
|
||||
assert_cast<ColumnUInt64 &>(column).insertValue(bitmap.to_ulong());
|
||||
UInt64 val = 0UL;
|
||||
ReadBufferFromMemory payload(const_cast<char *>(value.data()), n);
|
||||
MySQLReplication::readBigEndianStrict(payload, reinterpret_cast<char *>(&val), n);
|
||||
assert_cast<ColumnUInt64 &>(column).insertValue(val);
|
||||
read_bytes_size += n;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user