mirror of https://github.com/milvus-io/milvus.git
refactor(db): refactor DescribeTable
Former-commit-id: 021d731f3be6f338423caabef59bdd4c46ed02d8pull/191/head
parent
3d330e0aa4
commit
624e34f10d
|
@ -41,7 +41,7 @@ Status DBImpl<EngineT>::add_group(meta::TableSchema& table_schema) {
|
||||||
|
|
||||||
template<typename EngineT>
|
template<typename EngineT>
|
||||||
Status DBImpl<EngineT>::get_group(meta::TableSchema& table_schema) {
|
Status DBImpl<EngineT>::get_group(meta::TableSchema& table_schema) {
|
||||||
return _pMeta->get_group(table_schema);
|
return _pMeta->DescribeTable(table_schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename EngineT>
|
template<typename EngineT>
|
||||||
|
|
|
@ -119,7 +119,7 @@ Status DBMetaImpl::delete_group_partitions(const std::string& table_id,
|
||||||
|
|
||||||
TableSchema table_schema;
|
TableSchema table_schema;
|
||||||
table_schema.table_id = table_id;
|
table_schema.table_id = table_id;
|
||||||
auto status = get_group(table_schema);
|
auto status = DescribeTable(table_schema);
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -178,11 +178,7 @@ Status DBMetaImpl::CreateTable(TableSchema& table_schema) {
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
Status DBMetaImpl::get_group(TableSchema& table_schema) {
|
Status DBMetaImpl::DescribeTable(TableSchema& table_schema) {
|
||||||
return get_group_no_lock(table_schema);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status DBMetaImpl::get_group_no_lock(TableSchema& table_schema) {
|
|
||||||
try {
|
try {
|
||||||
auto groups = ConnectorPtr->select(columns(&TableSchema::id,
|
auto groups = ConnectorPtr->select(columns(&TableSchema::id,
|
||||||
&TableSchema::table_id,
|
&TableSchema::table_id,
|
||||||
|
@ -228,7 +224,7 @@ Status DBMetaImpl::add_group_file(TableFileSchema& group_file) {
|
||||||
}
|
}
|
||||||
TableSchema table_schema;
|
TableSchema table_schema;
|
||||||
table_schema.table_id = group_file.table_id;
|
table_schema.table_id = group_file.table_id;
|
||||||
auto status = get_group(table_schema);
|
auto status = DescribeTable(table_schema);
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +286,7 @@ Status DBMetaImpl::files_to_index(TableFilesSchema& files) {
|
||||||
if (groupItr == groups.end()) {
|
if (groupItr == groups.end()) {
|
||||||
TableSchema table_schema;
|
TableSchema table_schema;
|
||||||
table_schema.table_id = group_file.table_id;
|
table_schema.table_id = group_file.table_id;
|
||||||
auto status = get_group_no_lock(table_schema);
|
auto status = DescribeTable(table_schema);
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +325,7 @@ Status DBMetaImpl::files_to_search(const std::string &table_id,
|
||||||
|
|
||||||
TableSchema table_schema;
|
TableSchema table_schema;
|
||||||
table_schema.table_id = table_id;
|
table_schema.table_id = table_id;
|
||||||
auto status = get_group_no_lock(table_schema);
|
auto status = DescribeTable(table_schema);
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -374,7 +370,7 @@ Status DBMetaImpl::files_to_merge(const std::string& table_id,
|
||||||
|
|
||||||
TableSchema table_schema;
|
TableSchema table_schema;
|
||||||
table_schema.table_id = table_id;
|
table_schema.table_id = table_id;
|
||||||
auto status = get_group_no_lock(table_schema);
|
auto status = DescribeTable(table_schema);
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -672,7 +668,7 @@ Status DBMetaImpl::count(const std::string& table_id, long& result) {
|
||||||
|
|
||||||
TableSchema table_schema;
|
TableSchema table_schema;
|
||||||
table_schema.table_id = table_id;
|
table_schema.table_id = table_id;
|
||||||
auto status = get_group_no_lock(table_schema);
|
auto status = DescribeTable(table_schema);
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public:
|
||||||
DBMetaImpl(const DBMetaOptions& options_);
|
DBMetaImpl(const DBMetaOptions& options_);
|
||||||
|
|
||||||
virtual Status CreateTable(TableSchema& table_schema) override;
|
virtual Status CreateTable(TableSchema& table_schema) override;
|
||||||
virtual Status get_group(TableSchema& group_info_) override;
|
virtual Status DescribeTable(TableSchema& group_info_) override;
|
||||||
virtual Status has_group(const std::string& table_id_, bool& has_or_not_) override;
|
virtual Status has_group(const std::string& table_id_, bool& has_or_not_) override;
|
||||||
|
|
||||||
virtual Status add_group_file(TableFileSchema& group_file_info) override;
|
virtual Status add_group_file(TableFileSchema& group_file_info) override;
|
||||||
|
@ -68,7 +68,6 @@ private:
|
||||||
Status NextFileId(std::string& file_id);
|
Status NextFileId(std::string& file_id);
|
||||||
Status NextGroupId(std::string& table_id);
|
Status NextGroupId(std::string& table_id);
|
||||||
Status discard_files_of_size(long to_discard_size);
|
Status discard_files_of_size(long to_discard_size);
|
||||||
Status get_group_no_lock(TableSchema& group_info);
|
|
||||||
std::string GetGroupPath(const std::string& table_id);
|
std::string GetGroupPath(const std::string& table_id);
|
||||||
std::string GetGroupDatePartitionPath(const std::string& table_id, DateT& date);
|
std::string GetGroupDatePartitionPath(const std::string& table_id, DateT& date);
|
||||||
void GetGroupFilePath(TableFileSchema& group_file);
|
void GetGroupFilePath(TableFileSchema& group_file);
|
||||||
|
|
|
@ -123,11 +123,11 @@ Status LocalMetaImpl::CreateTable(TableSchema& table_schema) {
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
Status LocalMetaImpl::get_group(TableSchema& table_schema) {
|
Status LocalMetaImpl::DescribeTable(TableSchema& table_schema) {
|
||||||
bool group_exist;
|
bool exist;
|
||||||
has_group(table_schema.table_id, group_exist);
|
has_group(table_schema.table_id, exist);
|
||||||
if (!group_exist) {
|
if (!exist) {
|
||||||
return Status::NotFound("Group " + table_schema.table_id + " Not Found");
|
return Status::NotFound("Table " + table_schema.table_id + " Not Found");
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetGroupMetaInfo(table_schema.table_id, table_schema);
|
return GetGroupMetaInfo(table_schema.table_id, table_schema);
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
LocalMetaImpl(const DBMetaOptions& options_);
|
LocalMetaImpl(const DBMetaOptions& options_);
|
||||||
|
|
||||||
virtual Status CreateTable(TableSchema& table_schema) override;
|
virtual Status CreateTable(TableSchema& table_schema) override;
|
||||||
virtual Status get_group(TableSchema& table_schema_) override;
|
virtual Status DescribeTable(TableSchema& table_schema_) override;
|
||||||
virtual Status has_group(const std::string& table_id_, bool& has_or_not_) override;
|
virtual Status has_group(const std::string& table_id_, bool& has_or_not_) override;
|
||||||
|
|
||||||
virtual Status add_group_file(TableFileSchema& group_file_info) override;
|
virtual Status add_group_file(TableFileSchema& group_file_info) override;
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
using Ptr = std::shared_ptr<Meta>;
|
using Ptr = std::shared_ptr<Meta>;
|
||||||
|
|
||||||
virtual Status CreateTable(TableSchema& table_schema) = 0;
|
virtual Status CreateTable(TableSchema& table_schema) = 0;
|
||||||
virtual Status get_group(TableSchema& table_schema) = 0;
|
virtual Status DescribeTable(TableSchema& table_schema) = 0;
|
||||||
virtual Status has_group(const std::string& table_id_, bool& has_or_not_) = 0;
|
virtual Status has_group(const std::string& table_id_, bool& has_or_not_) = 0;
|
||||||
|
|
||||||
virtual Status add_group_file(TableFileSchema& group_file_info) = 0;
|
virtual Status add_group_file(TableFileSchema& group_file_info) = 0;
|
||||||
|
|
|
@ -27,13 +27,13 @@ TEST_F(MetaTest, GROUP_TEST) {
|
||||||
|
|
||||||
auto gid = group.id;
|
auto gid = group.id;
|
||||||
group.id = -1;
|
group.id = -1;
|
||||||
status = impl_->get_group(group);
|
status = impl_->DescribeTable(group);
|
||||||
ASSERT_TRUE(status.ok());
|
ASSERT_TRUE(status.ok());
|
||||||
ASSERT_EQ(group.id, gid);
|
ASSERT_EQ(group.id, gid);
|
||||||
ASSERT_EQ(group.table_id, table_id);
|
ASSERT_EQ(group.table_id, table_id);
|
||||||
|
|
||||||
group.table_id = "not_found";
|
group.table_id = "not_found";
|
||||||
status = impl_->get_group(group);
|
status = impl_->DescribeTable(group);
|
||||||
ASSERT_TRUE(!status.ok());
|
ASSERT_TRUE(!status.ok());
|
||||||
|
|
||||||
group.table_id = table_id;
|
group.table_id = table_id;
|
||||||
|
|
Loading…
Reference in New Issue