feat(db): fake data for db meta

Former-commit-id: b6fb08599a93f48cc123998da9fa2c0f771a0d93
pull/191/head
Xu Peng 2019-04-17 18:37:12 +08:00 committed by xj.lin
parent adc087c57e
commit eb8907667b
1 changed files with 13 additions and 3 deletions

View File

@ -26,6 +26,13 @@ DBMetaImpl::DBMetaImpl(const DBMetaOptions& options_)
Status DBMetaImpl::initialize() {
// PXU TODO: Create DB Connection
if (boost::filesystem::is_directory(_options.path)) {
}
else if (boost::filesystem::create_directory(_options.path)) {
// PXU TODO: New MetaDB
} else {
return Status::InvalidDBPath("Cannot Create " + _options.path);
}
return Status::OK();
}
@ -60,7 +67,8 @@ Status DBMetaImpl::add_group_file(const std::string& group_id,
std::stringstream ss;
SimpleIDGenerator g;
std::string suffix = (file_type == GroupFileSchema::RAW) ? ".raw" : ".index";
ss << "/tmp/test/" << date
/* ss << "/tmp/test/" << date */
ss << _options.path << "/" << date
<< "/" << g.getNextIDNumber()
<< suffix;
group_file_info.group_id = "1";
@ -74,7 +82,8 @@ Status DBMetaImpl::files_to_index(GroupFilesSchema& files) {
// PXU TODO
files.clear();
std::stringstream ss;
ss << "/tmp/test/" << Meta::GetDate();
/* ss << "/tmp/test/" << Meta::GetDate(); */
ss << _options.path << "/" << Meta::GetDate();
boost::filesystem::path path(ss.str().c_str());
boost::filesystem::directory_iterator end_itr;
for (boost::filesystem::directory_iterator itr(path); itr != end_itr; ++itr) {
@ -96,7 +105,8 @@ Status DBMetaImpl::files_to_merge(const std::string& group_id,
//PXU TODO
files.clear();
std::stringstream ss;
ss << "/tmp/test/" << Meta::GetDate();
/* ss << "/tmp/test/" << Meta::GetDate(); */
ss << _options.path << "/" << Meta::GetDate();
boost::filesystem::path path(ss.str().c_str());
boost::filesystem::directory_iterator end_itr;
GroupFilesSchema gfiles;