From 98270ac00422b68e56952a13a007337e5387efd6 Mon Sep 17 00:00:00 2001 From: Xu Peng Date: Thu, 18 Apr 2019 18:35:51 +0800 Subject: [PATCH] feat(db): create group and partition folders Former-commit-id: 8ac0992576c47435723d70d131d83571f30345b7 --- cpp/src/db/DBMetaImpl.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cpp/src/db/DBMetaImpl.cpp b/cpp/src/db/DBMetaImpl.cpp index 2dbe8cda..8f852816 100644 --- a/cpp/src/db/DBMetaImpl.cpp +++ b/cpp/src/db/DBMetaImpl.cpp @@ -96,6 +96,13 @@ Status DBMetaImpl::add_group(GroupSchema& group_info) { } catch(std::system_error& e) { return Status::GroupError("Add Group " + group_info.group_id + " Error"); } + + auto group_path = GetGroupPath(group_info.group_id); + + if (!boost::filesystem::is_directory(group_path)) { + assert(boost::filesystem::create_directory(group_path)); + } + return Status::OK(); } @@ -143,8 +150,10 @@ Status DBMetaImpl::add_group_file(GroupFileSchema& group_file) { } SimpleIDGenerator g; + std::stringstream ss; + ss << g.getNextIDNumber(); group_file.file_type = GroupFileSchema::NEW; - group_file.file_id = g.getNextIDNumber(); + group_file.file_id = ss.str(); group_file.dimension = group_info.dimension; GetGroupFilePath(group_file); try { @@ -155,6 +164,13 @@ Status DBMetaImpl::add_group_file(GroupFileSchema& group_file) { return Status::GroupError("Add GroupFile Group " + group_info.group_id + " File " + group_file.file_id + " Error"); } + + auto partition_path = GetGroupDatePartitionPath(group_file.group_id, group_file.date); + + if (!boost::filesystem::is_directory(partition_path)) { + assert(boost::filesystem::create_directory(partition_path)); + } + return Status::OK(); } -- GitLab