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

MCOL-4566: Add rebuildEM tool support to work with compressed files.

* This patch adds rebuildEM tool support to work with compressed files.
* This patch increases a version of the file header.

Note: Default version of the `rebuildEM` tool was using very old API,
those functions are not present currently. So `rebuildEM` will not work with
files created without compression, because we cannot deduce some info which are
needed to create column extent.
This commit is contained in:
Denis Khalikov
2021-03-10 17:23:13 +03:00
parent 2eec956977
commit 5d497e8821
25 changed files with 1560 additions and 406 deletions

View File

@ -1271,7 +1271,8 @@ void ExtentMap::reserveLBIDRange(LBID_t start, uint8_t size)
*/
void ExtentMap::loadVersion4or5(IDBDataFile* in, bool upgradeV4ToV5)
template <class T>
void ExtentMap::loadVersion4or5(T* in, bool upgradeV4ToV5)
{
int emNumElements = 0, flNumElements = 0;
@ -1456,20 +1457,9 @@ void ExtentMap::load(const string& filename, bool fixFL)
try
{
int emVersion = 0;
int bytes = in->read((char*) &emVersion, sizeof(int));
if (bytes == (int) sizeof(int) &&
(emVersion == EM_MAGIC_V4 || emVersion == EM_MAGIC_V5))
{
loadVersion4or5(in.get(), emVersion == EM_MAGIC_V4);
}
else
{
log("ExtentMap::load(): That file is not a valid ExtentMap image");
throw runtime_error("ExtentMap::load(): That file is not a valid ExtentMap image");
}
load(in.get());
}
catch (...)
{
releaseFreeList(WRITE);
@ -1482,6 +1472,80 @@ void ExtentMap::load(const string& filename, bool fixFL)
// checkConsistency();
}
// This is a quick workaround, to be able to initialize initial system tables
// from binary blob.
// This should be updated, probably we need inherit from `IDBDataFile`.
struct EMBinaryReader
{
EMBinaryReader(const char* data) : src(data) {}
ssize_t read(char* dst, size_t size)
{
memcpy(dst, src, size);
src += size;
return size;
}
const char* src;
};
void ExtentMap::loadFromBinaryBlob(const char* blob)
{
grabEMEntryTable(WRITE);
try
{
grabFreeList(WRITE);
}
catch (...)
{
releaseEMEntryTable(WRITE);
throw;
}
try
{
EMBinaryReader emBinReader(blob);
load(&emBinReader);
}
catch (...)
{
releaseFreeList(WRITE);
releaseEMEntryTable(WRITE);
throw;
}
releaseFreeList(WRITE);
releaseEMEntryTable(WRITE);
}
template <typename T> void ExtentMap::load(T* in)
{
if (!in)
return;
try
{
int emVersion = 0;
int bytes = in->read((char*) &emVersion, sizeof(int));
if (bytes == (int) sizeof(int) &&
(emVersion == EM_MAGIC_V4 || emVersion == EM_MAGIC_V5))
{
loadVersion4or5(in, emVersion == EM_MAGIC_V4);
}
else
{
log("ExtentMap::load(): That file is not a valid ExtentMap image");
throw runtime_error("ExtentMap::load(): That file is not a valid ExtentMap image");
}
}
catch (...)
{
throw;
}
}
void ExtentMap::save(const string& filename)
{
#ifdef BRM_INFO