mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
MS-449 Add vectors twice success, once with ids, the other no ids
Former-commit-id: 8ded87f809525d7bb43eaea21cbebf11ce30c6ef
This commit is contained in:
parent
4adc02a0ff
commit
05e9c06e81
@ -18,6 +18,7 @@ Please mark all change in change log and use the ticket from JIRA.
|
||||
- MS-443 - Create index hang again
|
||||
- MS-436 - Delete vectors failed if index created with index_type: IVF_FLAT/IVF_SQ8
|
||||
- MS-450 - server hang after run stop_server.sh
|
||||
- MS-449 - Add vectors twice success, once with ids, the other no ids
|
||||
|
||||
## Improvement
|
||||
- MS-327 - Clean code for milvus
|
||||
|
||||
@ -152,10 +152,6 @@ bool IsSameIndex(const TableIndex& index1, const TableIndex& index2) {
|
||||
&& index1.metric_type_ == index2.metric_type_;
|
||||
}
|
||||
|
||||
bool UserDefinedId(int64_t flag) {
|
||||
return flag & meta::FLAG_MASK_USERID;
|
||||
}
|
||||
|
||||
meta::DateT GetDate(const std::time_t& t, int day_delta) {
|
||||
struct tm ltm;
|
||||
localtime_r(&t, <m);
|
||||
|
||||
@ -28,8 +28,6 @@ Status DeleteTableFilePath(const DBMetaOptions& options, meta::TableFileSchema&
|
||||
|
||||
bool IsSameIndex(const TableIndex& index1, const TableIndex& index2);
|
||||
|
||||
bool UserDefinedId(int64_t flag);
|
||||
|
||||
meta::DateT GetDate(const std::time_t &t, int day_delta = 0);
|
||||
meta::DateT GetDate();
|
||||
meta::DateT GetDateWithDelta(int day_delta);
|
||||
|
||||
@ -22,7 +22,8 @@ constexpr int32_t DEFAULT_NLIST = 16384;
|
||||
constexpr int32_t DEFAULT_METRIC_TYPE = (int)MetricType::L2;
|
||||
constexpr int32_t DEFAULT_INDEX_FILE_SIZE = ONE_GB;
|
||||
|
||||
constexpr int64_t FLAG_MASK_USERID = 1;
|
||||
constexpr int64_t FLAG_MASK_NO_USERID = 0x1;
|
||||
constexpr int64_t FLAG_MASK_HAS_USERID = 0x1<<1;
|
||||
|
||||
typedef int DateT;
|
||||
const DateT EmptyDate = -1;
|
||||
|
||||
@ -457,21 +457,17 @@ InsertTask::OnExecute() {
|
||||
}
|
||||
}
|
||||
|
||||
//step 3: check table flag
|
||||
//all user provide id, or all internal id
|
||||
uint64_t row_count = 0;
|
||||
DBWrapper::DB()->GetTableRowCount(table_info.table_id_, row_count);
|
||||
bool empty_table = (row_count == 0);
|
||||
bool user_provide_ids = !insert_param_->row_id_array().empty();
|
||||
if(!empty_table) {
|
||||
//user already provided id before, all insert action require user id
|
||||
if(engine::utils::UserDefinedId(table_info.flag_) && !user_provide_ids) {
|
||||
return SetError(SERVER_INVALID_ARGUMENT, "Table vector ids are user defined, please provide id for this batch");
|
||||
}
|
||||
//user already provided id before, all insert action require user id
|
||||
if((table_info.flag_ & engine::meta::FLAG_MASK_HAS_USERID) && !user_provide_ids) {
|
||||
return SetError(SERVER_INVALID_ARGUMENT, "Table vector ids are user defined, please provide id for this batch");
|
||||
}
|
||||
|
||||
//user didn't provided id before, no need to provide user id
|
||||
if(!engine::utils::UserDefinedId(table_info.flag_) && user_provide_ids) {
|
||||
return SetError(SERVER_INVALID_ARGUMENT, "Table vector ids are auto generated, no need to provide id for this batch");
|
||||
}
|
||||
//user didn't provided id before, no need to provide user id
|
||||
if((table_info.flag_ & engine::meta::FLAG_MASK_NO_USERID) && user_provide_ids) {
|
||||
return SetError(SERVER_INVALID_ARGUMENT, "Table vector ids are auto generated, no need to provide id for this batch");
|
||||
}
|
||||
|
||||
rc.RecordSection("check validation");
|
||||
@ -482,7 +478,7 @@ InsertTask::OnExecute() {
|
||||
ProfilerStart(fname.c_str());
|
||||
#endif
|
||||
|
||||
//step 3: prepare float data
|
||||
//step 4: prepare float data
|
||||
std::vector<float> vec_f(insert_param_->row_record_array_size() * table_info.dimension_, 0);
|
||||
|
||||
// TODO: change to one dimension array in protobuf or use multiple-thread to copy the data
|
||||
@ -505,7 +501,7 @@ InsertTask::OnExecute() {
|
||||
|
||||
rc.ElapseFromBegin("prepare vectors data");
|
||||
|
||||
//step 4: insert vectors
|
||||
//step 5: insert vectors
|
||||
auto vec_count = (uint64_t) insert_param_->row_record_array_size();
|
||||
std::vector<int64_t> vec_ids(insert_param_->row_id_array_size(), 0);
|
||||
if(!insert_param_->row_id_array().empty()) {
|
||||
@ -530,11 +526,10 @@ InsertTask::OnExecute() {
|
||||
return SetError(SERVER_ILLEGAL_VECTOR_ID, msg);
|
||||
}
|
||||
|
||||
//step 5: update table flag
|
||||
if(empty_table && user_provide_ids) {
|
||||
stat = DBWrapper::DB()->UpdateTableFlag(insert_param_->table_name(),
|
||||
table_info.flag_ | engine::meta::FLAG_MASK_USERID);
|
||||
}
|
||||
//step 6: update table flag
|
||||
user_provide_ids ? table_info.flag_ |= engine::meta::FLAG_MASK_HAS_USERID
|
||||
: table_info.flag_ |= engine::meta::FLAG_MASK_NO_USERID;
|
||||
stat = DBWrapper::DB()->UpdateTableFlag(insert_param_->table_name(), table_info.flag_);
|
||||
|
||||
#ifdef MILVUS_ENABLE_PROFILING
|
||||
ProfilerStop();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user