mirror of https://github.com/milvus-io/milvus.git
add empty and dim check
Former-commit-id: 319232d98f8c22d600ef31001a3798fff4dc18dcpull/191/head
parent
92467dc304
commit
125191557c
|
@ -243,7 +243,12 @@ ClientTest::Test(const std::string& address, const std::string& port) {
|
|||
std::vector<int64_t> record_ids;
|
||||
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
Status stat = conn->InsertVector(TABLE_NAME, record_array, record_ids);
|
||||
|
||||
std::vector<RowRecord> null_record;
|
||||
RowRecord rowRecord;
|
||||
rowRecord.data.resize(0);
|
||||
null_record.push_back(rowRecord);
|
||||
Status stat = conn->InsertVector(TABLE_NAME, null_record, record_ids);
|
||||
auto finish = std::chrono::high_resolution_clock::now();
|
||||
std::cout << "InsertVector cost: " << std::chrono::duration_cast<std::chrono::duration<double>>(finish - start).count() << "s\n";
|
||||
|
||||
|
|
|
@ -405,6 +405,16 @@ ServerError InsertVectorTask::OnExecute() {
|
|||
// TODO: change to one dimension array in protobuf or use multiple-thread to copy the data
|
||||
for (size_t i = 0; i < insert_infos_.row_record_array_size(); i++) {
|
||||
for (size_t j = 0; j < table_info.dimension_; j++) {
|
||||
if (insert_infos_.row_record_array(i).vector_data().empty()) {
|
||||
return SetError(SERVER_INVALID_ROWRECORD_ARRAY, "Row record float array is empty");
|
||||
}
|
||||
uint64_t vec_dim = insert_infos_.row_record_array(i).vector_data().size();
|
||||
if (vec_dim != table_info.dimension_) {
|
||||
ServerError error_code = SERVER_INVALID_VECTOR_DIMENSION;
|
||||
std::string error_msg = "Invalid rowrecord dimension: " + std::to_string(vec_dim)
|
||||
+ " vs. table dimension:" + std::to_string(table_info.dimension_);
|
||||
return SetError(error_code, error_msg);
|
||||
}
|
||||
vec_f[i * table_info.dimension_ + j] = insert_infos_.row_record_array(i).vector_data(j);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue