1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-27 21:01:50 +03:00

feat(IO): MCOL-5555 Reduce number of direct writes to the file storing BRM journal and tablelocks (#2974)

This commit is contained in:
Denis Khalikov
2023-09-30 19:00:39 +03:00
committed by GitHub
parent 86c1c5d537
commit fce971dcd2
4 changed files with 71 additions and 14 deletions

View File

@ -70,14 +70,28 @@ void TableLockServer::save()
if (!out)
throw runtime_error("TableLockServer::save(): could not open save file");
out->write((char*)&count, 4);
uint32_t bufferSize = 4;
for (const auto& lock : locks)
bufferSize += lock.second.getInternalSize();
std::unique_ptr<char[]> buffer(new char[bufferSize]);
uint32_t offset = 0;
std::memcpy(&buffer[offset], (char*)&count, 4);
offset += 4;
for (it = locks.begin(); it != locks.end(); ++it)
{
if (!out)
throw runtime_error("TableLockServer::save(): could not write save file");
it->second.serialize(buffer.get(), offset);
it->second.serialize(out.get());
uint32_t writtenSize = 0;
uint32_t sizeToWrite = bufferSize;
while (writtenSize != bufferSize)
{
uint32_t ret = out->write(&buffer[writtenSize], sizeToWrite);
if (!ret)
throw runtime_error("TableLockServer::save(): could not write to the file");
writtenSize += ret;
sizeToWrite -= ret;
}
}