From 02bcac92a11b78f30026d20bd6c9345f328f4055 Mon Sep 17 00:00:00 2001 From: Xu Peng Date: Sun, 14 Apr 2019 14:30:13 +0800 Subject: [PATCH] feat(cpp): add db and env Former-commit-id: fc2f7219ff7806ca1f98d402ac5120e6174d5e01 --- cpp/src/db.h | 23 +++++++++++++++++++++++ cpp/src/db_impl.cpp | 11 +++++++++++ cpp/src/db_impl.h | 24 ++++++++++++++++++++++++ cpp/src/env.cpp | 11 +++++++++++ cpp/src/env.h | 23 +++++++++++++++++++++++ cpp/src/options.h | 12 ++++++++++++ 6 files changed, 104 insertions(+) create mode 100644 cpp/src/db.h create mode 100644 cpp/src/db_impl.cpp create mode 100644 cpp/src/db_impl.h create mode 100644 cpp/src/env.cpp create mode 100644 cpp/src/env.h create mode 100644 cpp/src/options.h diff --git a/cpp/src/db.h b/cpp/src/db.h new file mode 100644 index 00000000..5d8c0cf7 --- /dev/null +++ b/cpp/src/db.h @@ -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_ diff --git a/cpp/src/db_impl.cpp b/cpp/src/db_impl.cpp new file mode 100644 index 00000000..66ee9633 --- /dev/null +++ b/cpp/src/db_impl.cpp @@ -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 diff --git a/cpp/src/db_impl.h b/cpp/src/db_impl.h new file mode 100644 index 00000000..7dc55273 --- /dev/null +++ b/cpp/src/db_impl.h @@ -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_ diff --git a/cpp/src/env.cpp b/cpp/src/env.cpp new file mode 100644 index 00000000..fd8088ca --- /dev/null +++ b/cpp/src/env.cpp @@ -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 diff --git a/cpp/src/env.h b/cpp/src/env.h new file mode 100644 index 00000000..cda7a553 --- /dev/null +++ b/cpp/src/env.h @@ -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_ diff --git a/cpp/src/options.h b/cpp/src/options.h new file mode 100644 index 00000000..11486110 --- /dev/null +++ b/cpp/src/options.h @@ -0,0 +1,12 @@ +#ifndef VECENGINE_OPTIONS_H_ +#define VECENGINE_OPTIONS_H_ + +namespace vecengine { + +struct Options { + +}; // Options + +} // namespace vecengine + +#endif // VECENGINE_OPTIONS_H_ -- GitLab