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 bits = ((meta >> 8) * 8) + (meta & 0xff);
|
||||||
UInt32 size = (bits + 7) / 8;
|
UInt32 size = (bits + 7) / 8;
|
||||||
|
UInt64 val = 0UL;
|
||||||
Bitmap bitmap_value;
|
readBigEndianStrict(payload, reinterpret_cast<char *>(&val), size);
|
||||||
String byte_buffer;
|
row.push_back(val);
|
||||||
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()}});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MYSQL_TYPE_VARCHAR:
|
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);
|
bitmap.resize(bitmap_size * 8, false);
|
||||||
for (size_t i = 0; i < bitmap_size; ++i)
|
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;
|
class EventBase;
|
||||||
using BinlogEventPtr = std::shared_ptr<EventBase>;
|
using BinlogEventPtr = std::shared_ptr<EventBase>;
|
||||||
|
|
||||||
|
@ -149,11 +149,10 @@ namespace
|
|||||||
if (static_cast<int>(mysql_type) == 16)
|
if (static_cast<int>(mysql_type) == 16)
|
||||||
{
|
{
|
||||||
size_t n = value.size();
|
size_t n = value.size();
|
||||||
char *start = const_cast<char *>(value.data()), *end = start + n;
|
UInt64 val = 0UL;
|
||||||
std::reverse(start, end);
|
ReadBufferFromMemory payload(const_cast<char *>(value.data()), n);
|
||||||
MySQLReplication::Bitmap bitmap;
|
MySQLReplication::readBigEndianStrict(payload, reinterpret_cast<char *>(&val), n);
|
||||||
MySQLReplication::readBitmapFromStr(value.data(), bitmap, n);
|
assert_cast<ColumnUInt64 &>(column).insertValue(val);
|
||||||
assert_cast<ColumnUInt64 &>(column).insertValue(bitmap.to_ulong());
|
|
||||||
read_bytes_size += n;
|
read_bytes_size += n;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user