1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-12-18 13:54:11 +03:00

Filled in some key manipulation stubs.

This commit is contained in:
Patrick LeBlanc
2019-03-21 14:45:51 -05:00
parent 07b4bdd19c
commit 719cf3f2fa
2 changed files with 26 additions and 8 deletions

View File

@@ -8,6 +8,7 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/uuid/uuid.hpp> #include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp> #include <boost/uuid/uuid_io.hpp>
#include <boost/algorithm/string.hpp>
#define max(x, y) (x > y ? x : y) #define max(x, y) (x > y ? x : y)
#define min(x, y) (x < y ? x : y) #define min(x, y) (x < y ? x : y)
@@ -166,7 +167,7 @@ string MetadataFile::getNewKeyFromOldKey(string oldKey, size_t length)
{ {
boost::uuids::uuid u; boost::uuids::uuid u;
if (length != 0) if (length != 0)
setLength(oldKey, length); setLengthInKey(oldKey, length);
strcpy(&oldKey[0], boost::uuids::to_string(u).c_str()); strcpy(&oldKey[0], boost::uuids::to_string(u).c_str());
return oldKey; return oldKey;
} }
@@ -190,25 +191,42 @@ string MetadataFile::getNewKey(string sourceName, size_t offset, size_t length)
off_t MetadataFile::getOffsetFromKey(const string &key) off_t MetadataFile::getOffsetFromKey(const string &key)
{ {
return 0; vector<string> split;
boost::split(split, key, boost::is_any_of("_"));
return stoll(split[1]);
} }
string MetadataFile::getSourceFromKey(const string &key) string MetadataFile::getSourceFromKey(const string &key)
{ {
return "dookie"; vector<string> split;
boost::split(split, key, boost::is_any_of("_"));
return split[3];
} }
size_t MetadataFile::getLengthFromKey(const string &key) size_t MetadataFile::getLengthFromKey(const string &key)
{ {
return 0; vector<string> split;
boost::split(split, key, boost::is_any_of("_"));
return stoull(split[2]);
} }
void MetadataFile::setOffset(string &key, off_t newOffset) // more efficient way to do these?
void MetadataFile::setOffsetInKey(string &key, off_t newOffset)
{ {
vector<string> split;
boost::split(split, key, boost::is_any_of("_"));
ostringstream oss;
oss << split[0] << "_" << newOffset << "_" << split[2] << "_" << split[3];
key = oss.str();
} }
void MetadataFile::setLength(string &key, size_t newLength) void MetadataFile::setLengthInKey(string &key, size_t newLength)
{ {
vector<string> split;
boost::split(split, key, boost::is_any_of("_"));
ostringstream oss;
oss << split[0] << "_" << split[1] << "_" << newLength << "_" << split[3];
key = oss.str();
} }
void MetadataFile::printObjects() void MetadataFile::printObjects()

View File

@@ -48,8 +48,8 @@ class MetadataFile
static off_t getOffsetFromKey(const std::string &key); static off_t getOffsetFromKey(const std::string &key);
static std::string getSourceFromKey(const std::string &key); static std::string getSourceFromKey(const std::string &key);
static size_t getLengthFromKey(const std::string &key); static size_t getLengthFromKey(const std::string &key);
static void setOffset(std::string &key, off_t newOffset); static void setOffsetInKey(std::string &key, off_t newOffset);
static void setLength(std::string &key, size_t newLength); static void setLengthInKey(std::string &key, size_t newLength);
private: private: