提交 f5348ed5 编写于 作者: X Xu Peng 提交者: xj.lin

feat(db): file name mock


Former-commit-id: e99baa04809535f5f3c10d5b0c007c9c06ab159c
上级 de8e9176
......@@ -167,7 +167,8 @@ Status DBImpl::background_merge_files(const std::string& group_id) {
Status DBImpl::build_index(const meta::GroupFileSchema& file) {
meta::GroupFileSchema group_file;
Status status = _pMeta->add_group_file(file.group_id, file.date, group_file);
Status status = _pMeta->add_group_file(file.group_id, file.date,
group_file, meta::GroupFileSchema::INDEX);
if (!status.ok()) {
return status;
}
......@@ -182,8 +183,16 @@ Status DBImpl::build_index(const meta::GroupFileSchema& file) {
from_index->id_map.data());
/* std::cout << "raw size=" << from_index->ntotal << " index size=" << index->ntotal << std::endl; */
// PXU TODO: Remove
auto location = group_file.location + ".index";
write_index(index, location.c_str());
/* auto location = group_file.location + ".index"; */
write_index(index, group_file.location.c_str());
group_file.file_type = meta::GroupFileSchema::INDEX;
/* auto to_remove = file; */
/* to_remove.file_type = TO_DELETE; */
/* GroupFilesSchema update_files = {to_remove, group_file}; */
/* _pMeta->update_files(update_files); */
return Status::OK();
}
......
......@@ -47,19 +47,22 @@ Status DBMetaImpl::has_group(const std::string& group_id_, bool& has_or_not_) {
}
Status DBMetaImpl::add_group_file(const std::string& group_id,
GroupFileSchema& group_file_info) {
GroupFileSchema& group_file_info,
GroupFileSchema::FILE_TYPE file_type) {
return add_group_file(group_id, Meta::GetDate(), group_file_info);
}
Status DBMetaImpl::add_group_file(const std::string& group_id,
DateT date,
GroupFileSchema& group_file_info) {
GroupFileSchema& group_file_info,
GroupFileSchema::FILE_TYPE file_type) {
//PXU TODO
std::stringstream ss;
SimpleIDGenerator g;
std::string suffix = (file_type == GroupFileSchema::RAW) ? ".raw" : ".index";
ss << "/tmp/test/" << date
<< "/" << g.getNextIDNumber()
<< ".log";
<< suffix;
group_file_info.group_id = "1";
group_file_info.dimension = 64;
group_file_info.location = ss.str();
......
......@@ -21,9 +21,13 @@ public:
virtual Status add_group_file(const std::string& group_id,
DateT date,
GroupFileSchema& group_file_info) override;
GroupFileSchema& group_file_info,
GroupFileSchema::FILE_TYPE file_type=GroupFileSchema::RAW) override;
virtual Status add_group_file(const std::string& group_id_,
GroupFileSchema& group_file_info_) override;
GroupFileSchema& group_file_info_,
GroupFileSchema::FILE_TYPE file_type=GroupFileSchema::RAW) override;
virtual Status has_group_file(const std::string& group_id_,
const std::string& file_id_,
bool& has_or_not_) override;
......
......@@ -56,10 +56,13 @@ public:
virtual Status has_group(const std::string& group_id_, bool& has_or_not_) = 0;
virtual Status add_group_file(const std::string& group_id_,
GroupFileSchema& group_file_info_) = 0;
GroupFileSchema& group_file_info_,
GroupFileSchema::FILE_TYPE file_type=GroupFileSchema::RAW) = 0;
virtual Status add_group_file(const std::string& group_id,
DateT date,
GroupFileSchema& group_file_info) = 0;
GroupFileSchema& group_file_info,
GroupFileSchema::FILE_TYPE file_type=GroupFileSchema::RAW) = 0;
virtual Status has_group_file(const std::string& group_id_,
const std::string& file_id_,
bool& has_or_not_) = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册