Skip to content

Commit

Permalink
[fix][store]Fix coprocessor error and add blockcache value conf
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuRuoyu01 authored and rock-git committed Jan 14, 2025
1 parent d1e195b commit 32c1b29
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/config/config_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,14 @@ double ConfigHelper::GetRaftWorkerThreadRatio() {
return config->GetDouble("server.raft_worker_thread_ratio");
}

std::string ConfigHelper::GetBlockCacheValue(){
auto config = ConfigManager::GetInstance().GetRoleConfig();
if (config == nullptr) {
return Constant::kBlockCacheDefaultValue;
}

int64_t num = config->GetInt64("store.block_cache_size");
return (num <= 0) ? Constant::kBlockCacheDefaultValue : std::to_string(num);
}

} // namespace dingodb
2 changes: 2 additions & 0 deletions src/config/config_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class ConfigHelper {
static int64_t GetSplitMergeInterval();
static float GetMergeSizeRatio();
static float GetMergeKeysRatio();

static std::string GetBlockCacheValue();
};

} // namespace dingodb
Expand Down
2 changes: 2 additions & 0 deletions src/coprocessor/coprocessor_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ void CoprocessorV2::Close() {
original_serial_schemas_.reset();
original_column_indexes_.clear();
selection_column_indexes_.clear();
selection_column_indexes_serial_.clear();
result_serial_schemas_.reset();
result_record_encoder_.reset();
original_record_decoder_.reset();
Expand Down Expand Up @@ -684,6 +685,7 @@ void CoprocessorV2::GetSelectionColumnIndexes() {
int i = index;
DINGO_LOG(DEBUG) << "index:" << i;
selection_column_indexes_.push_back(original_column_indexes_[i]);
selection_column_indexes_serial_[original_column_indexes_[i]] = i;
}
} else {
DINGO_LOG(DEBUG) << "selection_columns empty()";
Expand Down
2 changes: 1 addition & 1 deletion src/engine/rocks_raw_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ RocksRawEngine::~RocksRawEngine() = default;
static rocks::ColumnFamilyMap GenColumnFamilyByDefaultConfig(const std::vector<std::string>& column_family_names) {
rocks::ColumnFamily::ColumnFamilyConfig default_config;
default_config.emplace(Constant::kBlockSize, Constant::kBlockSizeDefaultValue);
default_config.emplace(Constant::kBlockCache, Constant::kBlockCacheDefaultValue);
default_config.emplace(Constant::kBlockCache, ConfigHelper::GetBlockCacheValue());
default_config.emplace(Constant::kArenaBlockSize, Constant::kArenaBlockSizeDefaultValue);
default_config.emplace(Constant::kMinWriteBufferNumberToMerge, Constant::kMinWriteBufferNumberToMergeDefaultValue);
default_config.emplace(Constant::kMaxWriteBufferNumber, Constant::kMaxWriteBufferNumberDefaultValue);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/xdprocks_raw_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ XDPRocksRawEngine::~XDPRocksRawEngine() = default;
static xdp::ColumnFamilyMap GenColumnFamilyByDefaultConfig(const std::vector<std::string>& column_family_names) {
xdp::ColumnFamily::ColumnFamilyConfig default_config;
default_config.emplace(Constant::kBlockSize, "4096");
default_config.emplace(Constant::kBlockCache, Constant::kBlockCacheDefaultValue);
default_config.emplace(Constant::kBlockCache, ConfigHelper::GetBlockCacheValue());
default_config.emplace(Constant::kArenaBlockSize, Constant::kArenaBlockSizeDefaultValue);
default_config.emplace(Constant::kMinWriteBufferNumberToMerge, Constant::kMinWriteBufferNumberToMergeDefaultValue);
default_config.emplace(Constant::kMaxWriteBufferNumber, Constant::kMaxWriteBufferNumberDefaultValue);
Expand Down
3 changes: 2 additions & 1 deletion src/log/rocks_log_storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "common/constant.h"
#include "common/helper.h"
#include "common/logging.h"
#include "config/config_helper.h"
#include "fmt/format.h"
#include "gflags/gflags.h"
#include "glog/logging.h"
Expand Down Expand Up @@ -383,7 +384,7 @@ static rocksdb::ColumnFamilyOptions GenColumnFamilyOptions() {

rocksdb::BlockBasedTableOptions table_options;
table_options.block_size = Helper::StringToInt64(Constant::kBlockSizeDefaultValue);
table_options.block_cache = rocksdb::NewLRUCache(Helper::StringToInt64(Constant::kBlockCacheDefaultValue));
table_options.block_cache = rocksdb::NewLRUCache(Helper::StringToInt64(ConfigHelper::GetBlockCacheValue()));

table_options.filter_policy.reset(rocksdb::NewBloomFilterPolicy(10.0, false));
table_options.whole_key_filtering = true;
Expand Down

0 comments on commit 32c1b29

Please sign in to comment.