Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hulk committed Jun 1, 2024
1 parent f9f1bb4 commit 26ac817
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/server/namespace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool Namespace::IsAllowModify() const {
return config->HasConfigFile() || config->repl_namespace_enabled;
}

Status Namespace::loadFromDB(std::map<std::string, std::string>* dbTokens) const {
Status Namespace::loadFromDB(std::map<std::string, std::string>* db_tokens) const {
std::string value;
auto s = storage_->Get(rocksdb::ReadOptions(), cf_, kNamespaceDBKey, &value);
if (!s.ok()) {
Expand All @@ -61,7 +61,7 @@ Status Namespace::loadFromDB(std::map<std::string, std::string>* dbTokens) const

jsoncons::json j = jsoncons::json::parse(value);
for (const auto& iter : j.object_range()) {
dbTokens->insert({iter.key(), iter.value().as_string()});
db_tokens->insert({iter.key(), iter.value().as_string()});
}
return Status::OK();
}
Expand All @@ -71,18 +71,18 @@ Status Namespace::LoadAndRewrite() {
// Namespace is NOT allowed in the cluster mode, so we don't need to rewrite here.
if (config->cluster_enabled) return Status::OK();

std::map<std::string, std::string> dbTokens;
auto s = loadFromDB(&dbTokens);
std::map<std::string, std::string> db_tokens;
auto s = loadFromDB(&db_tokens);
if (!s.IsOK()) return s;

if (!dbTokens.empty() && !config->repl_namespace_enabled) {
if (!db_tokens.empty() && !config->repl_namespace_enabled) {
return {Status::NotOK, "cannot switch off repl_namespace_enabled when namespaces exist in db"};
}

// Load from the configuration file first
tokens_ = config->load_tokens;
// Merge the tokens from the database if the token is not in the configuration file
for (const auto& iter : dbTokens) {
for (const auto& iter : db_tokens) {
if (tokens_.find(iter.first) == tokens_.end()) {
tokens_[iter.first] = iter.second;
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ class Namespace {
rocksdb::ColumnFamilyHandle *cf_ = nullptr;
std::map<std::string, std::string> tokens_;

Status loadFromDB(std::map<std::string, std::string> *dbTokens) const;
Status loadFromDB(std::map<std::string, std::string> *db_tokens) const;
};

0 comments on commit 26ac817

Please sign in to comment.