Skip to content

Commit

Permalink
Refactor more codes (#1226)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

_Briefly describe what this PR aims to solve. Include background context
that will help reviewers understand the purpose of the PR._

### Type of change

- [x] Refactoring

Signed-off-by: Jin Hai <[email protected]>
  • Loading branch information
JinHai-CN authored May 19, 2024
1 parent c76f129 commit a0bd724
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 65 deletions.
18 changes: 9 additions & 9 deletions src/common/default_values.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ export {

constexpr SizeT MIN_CLEANUP_INTERVAL_SEC = 0; // 0 means disable the function
constexpr SizeT DEFAULT_CLEANUP_INTERVAL_SEC = 10;
constexpr String DEFAULT_CLEANUP_INTERVAL_SEC_STR = "10s"; // 10 seconds
constexpr std::string_view DEFAULT_CLEANUP_INTERVAL_SEC_STR = "10s"; // 10 seconds
constexpr SizeT MAX_CLEANUP_INTERVAL_SEC = 60 * 60 * 24 * 30; // 1 month

constexpr SizeT MIN_COMPACT_INTERVAL_SEC = 0; // 0 means disable the function
constexpr SizeT DEFAULT_COMPACT_INTERVAL_SEC = 10;
constexpr String DEFAULT_COMPACT_INTERVAL_SEC_STR = "10s"; // 10 seconds
constexpr std::string_view DEFAULT_COMPACT_INTERVAL_SEC_STR = "10s"; // 10 seconds
constexpr SizeT MAX_COMPACT_INTERVAL_SEC = 60 * 60 * 24 * 30; // 1 month

constexpr SizeT MIN_OPTIMIZE_INTERVAL_SEC = 1;
constexpr SizeT DEFAULT_OPTIMIZE_INTERVAL_SEC = 10;
constexpr String DEFAULT_OPTIMIZE_INTERVAL_SEC_STR = "10s"; // 10 seconds
constexpr std::string_view DEFAULT_OPTIMIZE_INTERVAL_SEC_STR = "10s"; // 10 seconds
constexpr SizeT MAX_OPTIMIZE_INTERVAL_SEC = 60 * 60 * 24 * 30; // 1 month

constexpr SizeT MIN_MEMINDEX_CAPACITY = DEFAULT_BLOCK_CAPACITY; // 1 Block
Expand All @@ -108,22 +108,22 @@ export {

constexpr i64 MIN_WAL_FILE_SIZE_THRESHOLD = 1024; // 1KB
constexpr i64 DEFAULT_WAL_FILE_SIZE_THRESHOLD = 1 * 1024l * 1024l * 1024l; // 1GB
constexpr String DEFAULT_WAL_FILE_SIZE_THRESHOLD_STR = "1GB"; // 1GB
constexpr std::string_view DEFAULT_WAL_FILE_SIZE_THRESHOLD_STR = "1GB"; // 1GB
constexpr i64 MAX_WAL_FILE_SIZE_THRESHOLD = 1024l * DEFAULT_WAL_FILE_SIZE_THRESHOLD; // 1TB

constexpr i64 MIN_FULL_CHECKPOINT_INTERVAL_SEC = 0; // 0 means disable full checkpoint
constexpr i64 DEFAULT_FULL_CHECKPOINT_INTERVAL_SEC = 30; // 30 seconds
constexpr String DEFAULT_FULL_CHECKPOINT_INTERVAL_SEC_STR = "30s"; // 30 seconds
constexpr std::string_view DEFAULT_FULL_CHECKPOINT_INTERVAL_SEC_STR = "30s"; // 30 seconds
constexpr i64 MAX_FULL_CHECKPOINT_INTERVAL_SEC = 60 * 60 * 24 * 30; // 1 month

constexpr i64 MIN_DELTA_CHECKPOINT_INTERVAL_SEC = 0; // 0 means disable delta checkpoint
constexpr i64 DEFAULT_DELTA_CHECKPOINT_INTERVAL_SEC = 5; // 5 seconds
constexpr String DEFAULT_DELTA_CHECKPOINT_INTERVAL_SEC_STR = "5s"; // 5 seconds
constexpr std::string_view DEFAULT_DELTA_CHECKPOINT_INTERVAL_SEC_STR = "5s"; // 5 seconds
constexpr i64 MAX_DELTA_CHECKPOINT_INTERVAL_SEC = 60 * 60 * 24 * 30; // 1 month

constexpr i64 MIN_CHECKPOINT_INTERVAL_WAL_BYTES = 1024; // 1K
constexpr i64 DELTA_CHECKPOINT_INTERVAL_WAL_BYTES = 64 * 1024l * 1024l; // 64 MB
constexpr String DELTA_CHECKPOINT_INTERVAL_WAL_BYTES_STR = "64MB"; // 64 MB
constexpr std::string_view DELTA_CHECKPOINT_INTERVAL_WAL_BYTES_STR = "64MB"; // 64 MB
constexpr i64 MAX_CHECKPOINT_INTERVAL_WAL_BYTES = 1024l * 1024l * 1024l; // 1GB


Expand Down Expand Up @@ -154,10 +154,10 @@ export {
constexpr u32 DEFAULT_TENSOR_MAXSIM_OPTION_TOP_N = 10;

constexpr SizeT DEFAULT_BUFFER_MANAGER_SIZE = 4 * 1024lu * 1024lu * 1024lu; // 4Gib
constexpr String DEFAULT_BUFFER_MANAGER_SIZE_STR = "4GB"; // 4Gib
constexpr std::string_view DEFAULT_BUFFER_MANAGER_SIZE_STR = "4GB"; // 4Gib

constexpr SizeT DEFAULT_LOG_FILE_SIZE = 64 * 1024lu * 1024lu; // 64MB
constexpr String DEFAULT_LOG_FILE_SIZE_STR = "64MB"; // 64MB
constexpr std::string_view DEFAULT_LOG_FILE_SIZE_STR = "64MB"; // 64MB

// config name
constexpr std::string_view VERSION_OPTION_NAME = "version";
Expand Down
18 changes: 9 additions & 9 deletions src/main/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ Status Config::Init(const SharedPtr<String> &config_path) {
// Log File Max Size
i64 log_file_max_size = DEFAULT_LOG_FILE_SIZE;
if (elem.second.is_string()) {
String log_file_max_size_str = elem.second.value_or(DEFAULT_LOG_FILE_SIZE_STR);
String log_file_max_size_str = elem.second.value_or(DEFAULT_LOG_FILE_SIZE_STR.data());
auto res = ParseByteSize(log_file_max_size_str, log_file_max_size);
if (!res.ok()) {
return res;
Expand Down Expand Up @@ -934,7 +934,7 @@ Status Config::Init(const SharedPtr<String> &config_path) {
// Cleanup Interval
i64 cleanup_interval = DEFAULT_CLEANUP_INTERVAL_SEC;
if(elem.second.is_string()) {
String cleanup_interval_str = elem.second.value_or(DEFAULT_CLEANUP_INTERVAL_SEC_STR);
String cleanup_interval_str = elem.second.value_or(DEFAULT_CLEANUP_INTERVAL_SEC_STR.data());
auto res = ParseTimeInfo(cleanup_interval_str, cleanup_interval);
if (!res.ok()) {
return res;
Expand All @@ -958,7 +958,7 @@ Status Config::Init(const SharedPtr<String> &config_path) {
// Compact Interval
i64 compact_interval = DEFAULT_COMPACT_INTERVAL_SEC;
if(elem.second.is_string()) {
String compact_interval_str = elem.second.value_or(DEFAULT_COMPACT_INTERVAL_SEC_STR);
String compact_interval_str = elem.second.value_or(DEFAULT_COMPACT_INTERVAL_SEC_STR.data());
auto res = ParseTimeInfo(compact_interval_str, compact_interval);
if (!res.ok()) {
return res;
Expand All @@ -982,7 +982,7 @@ Status Config::Init(const SharedPtr<String> &config_path) {
// Optimize Index Interval
i64 optimize_index_interval = DEFAULT_OPTIMIZE_INTERVAL_SEC;
if(elem.second.is_string()) {
String optimize_index_interval_str = elem.second.value_or(DEFAULT_OPTIMIZE_INTERVAL_SEC_STR);
String optimize_index_interval_str = elem.second.value_or(DEFAULT_OPTIMIZE_INTERVAL_SEC_STR.data());
auto res = ParseTimeInfo(optimize_index_interval_str, optimize_index_interval);
if (!res.ok()) {
return res;
Expand Down Expand Up @@ -1104,7 +1104,7 @@ Status Config::Init(const SharedPtr<String> &config_path) {
case GlobalOptionIndex::kBufferManagerSize: {
i64 buffer_manager_size = DEFAULT_BUFFER_MANAGER_SIZE;
if(elem.second.is_string()) {
String buffer_manager_size_str = elem.second.value_or(DEFAULT_BUFFER_MANAGER_SIZE_STR);
String buffer_manager_size_str = elem.second.value_or(DEFAULT_BUFFER_MANAGER_SIZE_STR.data());
auto res = ParseByteSize(buffer_manager_size_str, buffer_manager_size);
if (!res.ok()) {
return res;
Expand Down Expand Up @@ -1201,7 +1201,7 @@ Status Config::Init(const SharedPtr<String> &config_path) {
i64 wal_compact_threshold = DEFAULT_WAL_FILE_SIZE_THRESHOLD;

if (elem.second.is_string()) {
String wal_compact_threshold_str = elem.second.value_or(DEFAULT_WAL_FILE_SIZE_THRESHOLD_STR);
String wal_compact_threshold_str = elem.second.value_or(DEFAULT_WAL_FILE_SIZE_THRESHOLD_STR.data());
auto res = ParseByteSize(wal_compact_threshold_str, wal_compact_threshold);
if (!res.ok()) {
return res;
Expand All @@ -1227,7 +1227,7 @@ Status Config::Init(const SharedPtr<String> &config_path) {
// Full Checkpoint Interval
i64 full_checkpoint_interval = DEFAULT_FULL_CHECKPOINT_INTERVAL_SEC;
if (elem.second.is_string()) {
String full_checkpoint_interval_str = elem.second.value_or(DEFAULT_FULL_CHECKPOINT_INTERVAL_SEC_STR);
String full_checkpoint_interval_str = elem.second.value_or(DEFAULT_FULL_CHECKPOINT_INTERVAL_SEC_STR.data());
auto res = ParseTimeInfo(full_checkpoint_interval_str, full_checkpoint_interval);
if (!res.ok()) {
return res;
Expand All @@ -1254,7 +1254,7 @@ Status Config::Init(const SharedPtr<String> &config_path) {
// Delta Checkpoint Interval
i64 delta_checkpoint_interval = DEFAULT_DELTA_CHECKPOINT_INTERVAL_SEC;
if (elem.second.is_string()) {
String delta_checkpoint_interval_str = elem.second.value_or(DEFAULT_DELTA_CHECKPOINT_INTERVAL_SEC_STR);
String delta_checkpoint_interval_str = elem.second.value_or(DEFAULT_DELTA_CHECKPOINT_INTERVAL_SEC_STR.data());
auto res = ParseTimeInfo(delta_checkpoint_interval_str, delta_checkpoint_interval);
if (!res.ok()) {
return res;
Expand All @@ -1281,7 +1281,7 @@ Status Config::Init(const SharedPtr<String> &config_path) {
// Delta Checkpoint Threshold
i64 delta_checkpoint_threshold = DELTA_CHECKPOINT_INTERVAL_WAL_BYTES;
if (elem.second.is_string()) {
String delta_checkpoint_threshold_str = elem.second.value_or(DELTA_CHECKPOINT_INTERVAL_WAL_BYTES_STR);
String delta_checkpoint_threshold_str = elem.second.value_or(DELTA_CHECKPOINT_INTERVAL_WAL_BYTES_STR.data());
auto res = ParseByteSize(delta_checkpoint_threshold_str, delta_checkpoint_threshold);
if (!res.ok()) {
return res;
Expand Down
Loading

0 comments on commit a0bd724

Please sign in to comment.