mirror of https://github.com/milvus-io/milvus.git
clean unused code (#3190)
Signed-off-by: groot <yihua.mo@zilliz.com> Co-authored-by: Wang Xiangyu <xy.wang@zilliz.com>pull/3185/head^2
parent
30e02954f6
commit
22ea1e3423
|
@ -381,43 +381,6 @@ ValidateSearchTopk(int64_t top_k) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
ValidatePartitionName(const std::string& partition_name) {
|
||||
if (partition_name.empty()) {
|
||||
std::string msg = "Partition name should not be empty.";
|
||||
LOG_SERVER_ERROR_ << msg;
|
||||
return Status(SERVER_INVALID_COLLECTION_NAME, msg);
|
||||
}
|
||||
|
||||
std::string invalid_msg = "Invalid partition name: " + partition_name + ". ";
|
||||
// Collection name size shouldn't exceed 255.
|
||||
if (partition_name.size() > engine::MAX_NAME_LENGTH) {
|
||||
std::string msg = invalid_msg + "The length of a partition name must be less than 255 characters.";
|
||||
LOG_SERVER_ERROR_ << msg;
|
||||
return Status(SERVER_INVALID_COLLECTION_NAME, msg);
|
||||
}
|
||||
|
||||
// Collection name first character should be underscore or character.
|
||||
char first_char = partition_name[0];
|
||||
if (first_char != '_' && std::isalpha(first_char) == 0) {
|
||||
std::string msg = invalid_msg + "The first character of a partition name must be an underscore or letter.";
|
||||
LOG_SERVER_ERROR_ << msg;
|
||||
return Status(SERVER_INVALID_COLLECTION_NAME, msg);
|
||||
}
|
||||
|
||||
int64_t table_name_size = partition_name.size();
|
||||
for (int64_t i = 1; i < table_name_size; ++i) {
|
||||
char name_char = partition_name[i];
|
||||
if (name_char != '_' && std::isalnum(name_char) == 0) {
|
||||
std::string msg = invalid_msg + "Partition name can only contain numbers, letters, and underscores.";
|
||||
LOG_SERVER_ERROR_ << msg;
|
||||
return Status(SERVER_INVALID_COLLECTION_NAME, msg);
|
||||
}
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
ValidatePartitionTags(const std::vector<std::string>& partition_tags) {
|
||||
for (const std::string& tag : partition_tags) {
|
||||
|
|
|
@ -29,18 +29,12 @@ ValidateCollectionName(const std::string& collection_name);
|
|||
extern Status
|
||||
ValidateFieldName(const std::string& field_name);
|
||||
|
||||
extern Status
|
||||
ValidateIndexName(const std::string& index_name);
|
||||
|
||||
extern Status
|
||||
ValidateDimension(int64_t dimension, bool is_binary);
|
||||
|
||||
extern Status
|
||||
ValidateIndexType(std::string& index_type);
|
||||
|
||||
extern Status
|
||||
ValidateVectorDimension(int64_t dimension, const std::string& metric_type);
|
||||
|
||||
extern Status
|
||||
ValidateIndexParams(const milvus::json& index_params, int64_t dimension, const std::string& index_type);
|
||||
|
||||
|
@ -53,9 +47,6 @@ ValidateIndexMetricType(const std::string& metric_type);
|
|||
extern Status
|
||||
ValidateSearchTopk(int64_t top_k);
|
||||
|
||||
extern Status
|
||||
ValidatePartitionName(const std::string& partition_name);
|
||||
|
||||
extern Status
|
||||
ValidatePartitionTags(const std::vector<std::string>& partition_tags);
|
||||
} // namespace server
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "utils/TimeRecorder.h"
|
||||
|
||||
#include <fiu-local.h>
|
||||
#include <set>
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
@ -62,10 +63,12 @@ CreateCollectionReq::OnExecute() {
|
|||
engine::snapshot::CreateCollectionContext create_collection_context;
|
||||
auto collection_schema = std::make_shared<engine::snapshot::Collection>(collection_name_, extra_params_);
|
||||
|
||||
std::set<std::string> unique_field_names;
|
||||
create_collection_context.collection = collection_schema;
|
||||
for (auto& field_kv : fields_) {
|
||||
auto& field_name = field_kv.first;
|
||||
auto& field_schema = field_kv.second;
|
||||
unique_field_names.insert(field_name);
|
||||
|
||||
auto& field_type = field_schema.field_type_;
|
||||
auto& field_params = field_schema.field_params_;
|
||||
|
@ -103,6 +106,11 @@ CreateCollectionReq::OnExecute() {
|
|||
create_collection_context.fields_schema[field] = {};
|
||||
}
|
||||
|
||||
// not allow duplicate field name
|
||||
if (unique_field_names.size() != fields_.size()) {
|
||||
return Status(DB_ERROR, "Duplicate field name");
|
||||
}
|
||||
|
||||
// step 3: create collection
|
||||
status = DBWrapper::DB()->CreateCollection(create_collection_context);
|
||||
fiu_do_on("CreateCollectionReq.OnExecute.invalid_db_execute",
|
||||
|
|
Loading…
Reference in New Issue