feat(cpp): add db and env

Former-commit-id: fc2f7219ff7806ca1f98d402ac5120e6174d5e01
This commit is contained in:
Xu Peng 2019-04-14 14:30:13 +08:00
parent d7f5e351a2
commit 02bcac92a1
6 changed files with 104 additions and 0 deletions

23
cpp/src/db.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef VECENGINE_DB_H_
#define VECENGINE_DB_H_
#include "options.h"
namespace vecengine {
class Env;
class DB {
public:
static DB* Open(const Options& options_, const std::string& name_);
DB() = default;
DB(const DB&) = delete;
DB& operator=(const DB&) = delete;
virtual ~DB();
}; // DB
} // namespace vecengine
#endif // VECENGINE_DB_H_

11
cpp/src/db_impl.cpp Normal file
View File

@ -0,0 +1,11 @@
include "db_impl.h"
namespace vecengine {
DB::DB(const Options& options_, const std::string& name_)
: _dbname(name_),
_env(options_.env),
_options(options_) {
}
} // namespace vecengine

24
cpp/src/db_impl.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef VECENGINE_DB_IMPL_H_
#define VECENGINE_DB_IMPL_H_
#include "db.h"
namespace vecengine {
class Env;
class DBImpl : public DB {
public:
DBImpl(const Options& options_, const std::string& name_);
virtual ~DBImpl();
private:
const _dbname;
Env* const _env;
const Options _options;
}; // DBImpl
} // namespace vecengine
#endif // VECENGINE_DB_IMPL_H_

11
cpp/src/env.cpp Normal file
View File

@ -0,0 +1,11 @@
#inlcude "env.h"
namespace vecengine {
DBConfig::DBConfig()
: _mem_sync_interval(10),
_file_merge_trigger_number(20),
_index_file_build_trigger_size(100000) {
}
} // namespace vecengine

23
cpp/src/env.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef STORAGE_VECENGINE_ENV_H_
#define STORAGE_VECENGINE_ENV_H_
namespace vecengine {
/* struct Options { */
/* std::string _db_location; */
/* size_t _mem_sync_interval; */
/* size_t _file_merge_trigger_number; */
/* size_t _index_file_build_trigger_size; */
/* }; // Config */
class Env {
public:
Env() = default;
private:
Options _option;
}; // Env
} //namespace vecengine
#endif // STORAGE_VECENGINE_ENV_H_

12
cpp/src/options.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef VECENGINE_OPTIONS_H_
#define VECENGINE_OPTIONS_H_
namespace vecengine {
struct Options {
}; // Options
} // namespace vecengine
#endif // VECENGINE_OPTIONS_H_