提交 ca28817a 编写于 作者: G groot

MS-207 build_index return success when table not existed


Former-commit-id: 99ca21c7411d0fd31b8389efd1b0ce1fa4381992
上级 186e3984
......@@ -19,6 +19,7 @@ enum class EngineType {
FAISS_IDMAP = 1,
FAISS_IVFFLAT,
FAISS_IVFSQ8,
MAX_VALUE = FAISS_IVFSQ8,
};
class ExecutionEngine {
......
......@@ -291,7 +291,7 @@ ServerError HasTableTask::OnExecute() {
if(res != SERVER_SUCCESS) {
return SetError(res, "Invalid table name: " + table_name_);
}
//step 2: check table existence
engine::Status stat = DBWrapper::DB()->HasTable(table_name_, has_table_);
if(!stat.ok()) {
......
......@@ -56,18 +56,13 @@ ValidateTableDimension(int64_t dimension) {
ServerError
ValidateTableIndexType(int32_t index_type) {
auto engine_type = engine::EngineType(index_type);
switch (engine_type) {
case engine::EngineType::FAISS_IDMAP:
case engine::EngineType::FAISS_IVFFLAT:
case engine::EngineType::FAISS_IVFSQ8:{
SERVER_LOG_DEBUG << "Index type: " << index_type;
return SERVER_SUCCESS;
}
default: {
return SERVER_INVALID_INDEX_TYPE;
}
int engine_type = (int)engine::EngineType(index_type);
if(engine_type <= 0 || engine_type > (int)engine::EngineType::MAX_VALUE) {
return SERVER_INVALID_INDEX_TYPE;
}
SERVER_LOG_DEBUG << "Index type: " << index_type;
return SERVER_SUCCESS;
}
}
......
......@@ -7,9 +7,11 @@
#include "utils/ValidationUtil.h"
#include "utils/Error.h"
#include "db/ExecutionEngine.h"
#include <string>
using namespace zilliz::milvus;
using namespace zilliz::milvus::server;
TEST(ValidationUtilTest, TableNameTest) {
......@@ -53,9 +55,9 @@ TEST(ValidationUtilTest, TableDimensionTest) {
}
TEST(ValidationUtilTest, TableIndexTypeTest) {
ASSERT_EQ(ValidateTableIndexType(0), SERVER_INVALID_INDEX_TYPE);
ASSERT_EQ(ValidateTableIndexType(1), SERVER_SUCCESS);
ASSERT_EQ(ValidateTableIndexType(2), SERVER_SUCCESS);
ASSERT_EQ(ValidateTableIndexType(3), SERVER_INVALID_INDEX_TYPE);
ASSERT_EQ(ValidateTableIndexType(4), SERVER_INVALID_INDEX_TYPE);
ASSERT_EQ(ValidateTableIndexType((int)engine::EngineType::INVALID), SERVER_INVALID_INDEX_TYPE);
for(int i = 1; i <= (int)engine::EngineType::MAX_VALUE; i++) {
ASSERT_EQ(ValidateTableIndexType(i), SERVER_SUCCESS);
}
ASSERT_EQ(ValidateTableIndexType((int)engine::EngineType::MAX_VALUE + 1), SERVER_INVALID_INDEX_TYPE);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册