提交 2d08fc41 编写于 作者: X Xu Peng

refactor(db): add NextGroupId in DBMetaImpl


Former-commit-id: 56deb4603db20ac4ef677f1851a1e76e703a234f
上级 425e4b4b
......@@ -69,6 +69,14 @@ void DBMetaImpl::GetGroupFilePath(GroupFileSchema& group_file) {
group_file.location = ss.str();
}
Status DBMetaImpl::NextGroupId(std::string& group_id) {
std::stringstream ss;
SimpleIDGenerator g;
ss << g.getNextIDNumber();
group_id = ss.str();
return Status::OK();
}
DBMetaImpl::DBMetaImpl(const DBMetaOptions& options_)
: _options(options_) {
initialize();
......@@ -134,10 +142,7 @@ Status DBMetaImpl::delete_group_partitions(const std::string& group_id,
Status DBMetaImpl::add_group(GroupSchema& group_info) {
if (group_info.group_id == "") {
std::stringstream ss;
SimpleIDGenerator g;
ss << g.getNextIDNumber();
group_info.group_id = ss.str();
NextGroupId(group_info.group_id);
}
group_info.files_cnt = 0;
group_info.id = -1;
......@@ -147,7 +152,6 @@ Status DBMetaImpl::add_group(GroupSchema& group_info) {
try {
auto id = ConnectorPtr->insert(group_info);
group_info.id = id;
/* LOG(DEBUG) << "Add group " << id; */
} catch (...) {
return Status::DBTransactionError("Add Group Error");
}
......
......@@ -65,7 +65,7 @@ public:
virtual ~DBMetaImpl();
private:
Status NextGroupId(std::string& group_id);
Status discard_files_of_size(long to_discard_size);
Status get_group_no_lock(GroupSchema& group_info);
std::string GetGroupPath(const std::string& group_id);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册