You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-15 12:09:09 +03:00
Added another merge-journal fcn that will work on in-mem obj data.
This commit is contained in:
@@ -309,7 +309,6 @@ boost::shared_array<uint8_t> IOCoordinator::mergeJournal(const char *object, con
|
||||
assert(header.get<string>("version") == "1");
|
||||
|
||||
// start processing the entries
|
||||
bool eof = false;
|
||||
while (1)
|
||||
{
|
||||
uint64_t offlen[2];
|
||||
@@ -359,6 +358,60 @@ boost::shared_array<uint8_t> IOCoordinator::mergeJournal(const char *object, con
|
||||
return ret;
|
||||
}
|
||||
|
||||
// MergeJournalInMem is a specialized version of mergeJournal(). TODO: refactor if possible.
|
||||
int IOCoordinator::mergeJournalInMem(uint8_t *objData, const char *journalPath)
|
||||
{
|
||||
int journalFD = ::open(journalPath, O_RDONLY);
|
||||
if (journalFD < 0)
|
||||
return -1;
|
||||
scoped_closer s(journalFD);
|
||||
|
||||
// grab the journal header and make sure the version is 1
|
||||
boost::shared_array<char> headertxt = seekToEndOfHeader1(journalFD);
|
||||
stringstream ss;
|
||||
ss << headertxt.get();
|
||||
boost::property_tree::ptree header;
|
||||
boost::property_tree::json_parser::read_json(ss, header);
|
||||
assert(header.get<string>("version") == "1");
|
||||
|
||||
// start processing the entries
|
||||
while (1)
|
||||
{
|
||||
uint64_t offlen[2];
|
||||
int err = ::read(journalFD, &offlen, 16);
|
||||
if (err != 16) // got EOF
|
||||
break;
|
||||
|
||||
uint64_t startReadingAt = offlen[0];
|
||||
uint64_t lengthOfRead = offlen[1];
|
||||
|
||||
::lseek(journalFD, startReadingAt, SEEK_CUR);
|
||||
|
||||
uint count = 0;
|
||||
while (count < lengthOfRead)
|
||||
{
|
||||
err = ::read(journalFD, &objData[startReadingAt + count], lengthOfRead - count);
|
||||
if (err < 0)
|
||||
{
|
||||
char buf[80];
|
||||
int l_errno = errno;
|
||||
logger->log(LOG_ERR, "mergeJournal: got %s", strerror_r(errno, buf, 80));
|
||||
errno = l_errno;
|
||||
return -1;
|
||||
}
|
||||
else if (err == 0)
|
||||
{
|
||||
logger->log(LOG_ERR, "mergeJournal: got early EOF");
|
||||
errno = ENODATA; // is there a better errno for early EOF?
|
||||
return -1;
|
||||
}
|
||||
count += err;
|
||||
}
|
||||
::lseek(journalFD, offlen[1] - lengthOfRead, SEEK_CUR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void IOCoordinator::getNewKeyFromOldKey(const string &oldKey, string *newKey)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class IOCoordinator : public boost::noncopyable
|
||||
// The default values for offset and len mean 'process the whole file'. Otherwise,
|
||||
// offset is relative to the object.
|
||||
boost::shared_array<uint8_t> mergeJournal(const char *objectPath, const char *journalPath, off_t offset = 0, size_t len = 0) const;
|
||||
int mergeJournalInMem(uint8_t *objData, const char *journalPath);
|
||||
|
||||
private:
|
||||
IOCoordinator();
|
||||
|
||||
Reference in New Issue
Block a user