#15182_MaterializeMySQL_support_bit_type-improve bit2Uint64 function

This commit is contained in:
zzsmdfj 2021-12-22 16:17:18 +08:00
parent 4a0554c963
commit 039afc5cfe
3 changed files with 11 additions and 21 deletions

View File

@ -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:

View File

@ -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>;

View File

@ -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