提交 12519155 编写于 作者: K kun yu

add empty and dim check


Former-commit-id: 319232d98f8c22d600ef31001a3798fff4dc18dc
上级 92467dc3
...@@ -243,7 +243,12 @@ ClientTest::Test(const std::string& address, const std::string& port) { ...@@ -243,7 +243,12 @@ ClientTest::Test(const std::string& address, const std::string& port) {
std::vector<int64_t> record_ids; std::vector<int64_t> record_ids;
auto start = std::chrono::high_resolution_clock::now(); 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(); 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"; std::cout << "InsertVector cost: " << std::chrono::duration_cast<std::chrono::duration<double>>(finish - start).count() << "s\n";
......
...@@ -405,6 +405,16 @@ ServerError InsertVectorTask::OnExecute() { ...@@ -405,6 +405,16 @@ ServerError InsertVectorTask::OnExecute() {
// TODO: change to one dimension array in protobuf or use multiple-thread to copy the data // 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 i = 0; i < insert_infos_.row_record_array_size(); i++) {
for (size_t j = 0; j < table_info.dimension_; j++) { 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); vec_f[i * table_info.dimension_ + j] = insert_infos_.row_record_array(i).vector_data(j);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册