From 8d99ba172d9be6c5425a621117e8ecc452441a9c Mon Sep 17 00:00:00 2001 From: groot Date: Mon, 17 Jun 2019 10:08:22 +0800 Subject: [PATCH] refine Former-commit-id: e0bb1ee1ff6c7bdac13ebe2d06ec45acb9db3d20 --- cpp/src/db/DBImpl.h | 2 +- cpp/src/db/Options.h | 6 +++++- cpp/src/server/RequestTask.cpp | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cpp/src/db/DBImpl.h b/cpp/src/db/DBImpl.h index eb68db622..1a2f80601 100644 --- a/cpp/src/db/DBImpl.h +++ b/cpp/src/db/DBImpl.h @@ -95,7 +95,7 @@ private: MetaPtr pMeta_; MemManagerPtr pMemMgr_; - + }; // DBImpl diff --git a/cpp/src/db/Options.h b/cpp/src/db/Options.h index 2c7625921..2a7740575 100644 --- a/cpp/src/db/Options.h +++ b/cpp/src/db/Options.h @@ -15,6 +15,10 @@ namespace engine { class Env; +static constexpr uint64_t ONE_KB = 1024; +static constexpr uint64_t ONE_MB = ONE_KB*ONE_KB; +static constexpr uint64_t ONE_GB = ONE_KB*ONE_MB; + struct ArchiveConf { using CriteriaT = std::map; @@ -42,7 +46,7 @@ struct Options { Options(); uint16_t memory_sync_interval = 1; //unit: second uint16_t merge_trigger_number = 2; - size_t index_trigger_size = 1024*1024*1024; //unit: byte + size_t index_trigger_size = ONE_GB; //unit: byte Env* env; DBMetaOptions meta; }; // Options diff --git a/cpp/src/server/RequestTask.cpp b/cpp/src/server/RequestTask.cpp index 2f0d50437..1f59087df 100644 --- a/cpp/src/server/RequestTask.cpp +++ b/cpp/src/server/RequestTask.cpp @@ -37,8 +37,8 @@ namespace { opt.memory_sync_interval = (uint16_t)config.GetInt32Value(CONFIG_DB_FLUSH_INTERVAL, 10); opt.meta.path = db_path + "/db"; int64_t index_size = config.GetInt64Value(CONFIG_DB_INDEX_TRIGGER_SIZE); - if(index_size > 0) {//ensure larger than zero - opt.index_trigger_size = (size_t)index_size; + if(index_size > 0) {//ensure larger than zero, unit is MB + opt.index_trigger_size = (size_t)index_size * engine::ONE_MB; } CommonUtil::CreateDirectory(opt.meta.path); -- GitLab