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

Merge remote-tracking branch 'upstream/develop' into S3-project

This commit is contained in:
Patrick LeBlanc
2019-06-24 15:41:10 -05:00
179 changed files with 4688 additions and 311 deletions

View File

@ -1067,6 +1067,32 @@ void VBBM::loadVersion2(IDBDataFile* in)
throw runtime_error("VBBM::load(): Failed to load vb file meta data");
}
size_t readSize = vbbmEntries * sizeof(entry);
char *readBuf = new char[readSize];
size_t progress = 0;
int err;
while (progress < readSize)
{
err = in->read(readBuf + progress, readSize - progress);
if (err < 0)
{
log_errno("VBBM::load()");
throw runtime_error("VBBM::load(): Failed to load, check the critical log file");
}
else if (err == 0)
{
log("VBBM::load(): Got early EOF");
throw runtime_error("VBBM::load(): Got early EOF");
}
progress += err;
}
VBBMEntry *loadedEntries = (VBBMEntry *) readBuf;
for (i = 0; i < vbbmEntries; i++)
insert(loadedEntries[i].lbid, loadedEntries[i].verID, loadedEntries[i].vbOID,
loadedEntries[i].vbFBO, true);
/*
for (i = 0; i < vbbmEntries; i++)
{
if (in->read((char*)&entry, sizeof(entry)) != sizeof(entry))
@ -1077,6 +1103,7 @@ void VBBM::loadVersion2(IDBDataFile* in)
insert(entry.lbid, entry.verID, entry.vbOID, entry.vbFBO, true);
}
*/
}
@ -1132,16 +1159,15 @@ void VBBM::load(string filename)
void VBBM::save(string filename)
{
int i;
mode_t utmp = ::umask(0);
int var;
// XXXPAT: forcing the IDB* path. Delete the fstream path when appropriate.
if (true || IDBPolicy::useHdfs())
{
const char* filename_p = filename.c_str();
scoped_ptr<IDBDataFile> out(IDBDataFile::open(
IDBPolicy::getType(filename_p, IDBPolicy::WRITEENG),
filename_p, "wb", IDBDataFile::USE_VBUF));
::umask(utmp);
if (!out)
{
@ -1159,6 +1185,50 @@ void VBBM::save(string filename)
bytesWritten += out->write((char*) files, sizeof(VBFileMetadata) * vbbm->nFiles);
bytesToWrite += sizeof(VBFileMetadata) * vbbm->nFiles;
int first = -1, last = -1, err;
size_t progress, writeSize;
for (i = 0; i < vbbm->vbCapacity; i++)
{
if (storage[i].lbid != -1 && first == -1)
first = i;
else if (storage[i].lbid == -1 && first != -1)
{
last = i;
writeSize = (last - first) * sizeof(VBBMEntry);
progress = 0;
char *writePos = (char *) &storage[first];
while (progress < writeSize)
{
err = out->write(writePos + progress, writeSize - progress);
if (err < 0)
{
log_errno("VBBM::save()");
throw runtime_error("VBBM::save(): Failed to write the file");
}
progress += err;
}
first = -1;
}
}
if (first != -1)
{
writeSize = (vbbm->vbCapacity - first) * sizeof(VBBMEntry);
progress = 0;
char *writePos = (char *) &storage[first];
while (progress < writeSize)
{
err = out->write(writePos + progress, writeSize - progress);
if (err < 0)
{
log_errno("VBBM::save()");
throw runtime_error("VBBM::save(): Failed to write the file");
}
progress += err;
}
}
/*
for (i = 0; i < vbbm->vbCapacity; i++)
{
if (storage[i].lbid != -1)
@ -1173,12 +1243,12 @@ void VBBM::save(string filename)
log_errno("VBBM::save()");
throw runtime_error("VBBM::save(): Failed to write the file");
}
*/
}
else
{
ofstream out;
out.open(filename.c_str(), ios_base::trunc | ios_base::out | ios_base::binary);
::umask(utmp);
if (!out)
{