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

Added 'k, m, g' suffix processing to Config class

Started writing the Cache class.  Mostly stubs right now.
This commit is contained in:
Patrick LeBlanc
2019-02-21 16:19:29 -06:00
parent 449702895b
commit 402a49c27a
5 changed files with 141 additions and 2 deletions

79
src/Cache.cpp Normal file
View File

@@ -0,0 +1,79 @@
#include "Cache.h"
#include "Config.h"
#include <iostream>
#include <syslog.h>
#include <boost/filesystem.hpp>
using namespace std;
using namespace boost::filesystem;
namespace storagemanager
{
Cache::Cache()
{
Config *conf = Config::get();
string ssize = conf->getValue("Cache", "cache_size");
if (ssize.empty())
{
syslog(LOG_CRIT, "Cache/cache_size is not set");
throw runtime_error("Please set Cache/cache_size in the storagemanager.cnf file");
}
try
{
maxCacheSize = stol(ssize);
}
catch (invalid_argument &)
{
syslog(LOG_CRIT, "Cache/cache_size is not a number");
throw runtime_error("Please set Cache/cache_size to a number");
}
prefix = conf->getValue("Cache", "path");
if (prefix.empty())
{
syslog(LOG_CRIT, "Cache/path is not set");
throw runtime_error("Please set Cache/path in the storagemanager.cnf file");
}
try
{
boost::filesystem::create_directories(prefix);
}
catch (exception &e)
{
syslog(LOG_CRIT, "Failed to create %s, got: %s", prefix.string().c_str(), e.what());
throw e;
}
}
Cache::~Cache()
{
}
void Cache::read(const vector<string> &keys)
{
}
void Cache::exists(const vector<string> &keys, vector<bool> *out)
{
}
void Cache::newObject(const string &key, size_t size)
{
}
void Cache::deletedObject(const string &key, size_t size)
{
}
void Cache::setCacheSize(size_t size)
{
}
void Cache::makeSpace(size_t size)
{
}
}