提交 59a67627 编写于 作者: Y yudong.cai

optimize grpc insert


Former-commit-id: f7b24e65118f52bdd0ad2f0f2c5b3ce44dfdb3f2
上级 c15063e2
......@@ -428,20 +428,21 @@ InsertTask::OnExecute() {
// TODO: change to one dimension array in protobuf or use multiple-thread to copy the data
for (size_t i = 0; i < insert_param_.row_record_array_size(); i++) {
for (size_t j = 0; j < table_info.dimension_; j++) {
if (insert_param_.row_record_array(i).vector_data().empty()) {
return SetError(SERVER_INVALID_ROWRECORD_ARRAY, "Row record float array is empty");
}
uint64_t vec_dim = insert_param_.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_param_.row_record_array(i).vector_data(j);
if (insert_param_.row_record_array(i).vector_data().empty()) {
return SetError(SERVER_INVALID_ROWRECORD_ARRAY, "Row record float array is empty");
}
uint64_t vec_dim = insert_param_.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);
}
memcpy(&vec_f[i * table_info.dimension_],
insert_param_.row_record_array(i).vector_data().data(),
table_info.dimension_ * sizeof(float));
}
rc.ElapseFromBegin("prepare vectors data");
......@@ -453,8 +454,7 @@ InsertTask::OnExecute() {
vec_ids[i] = insert_param_.row_id_array(i);
}
stat = DBWrapper::DB()->InsertVectors(insert_param_.table_name(), vec_count, vec_f.data(),
vec_ids);
stat = DBWrapper::DB()->InsertVectors(insert_param_.table_name(), vec_count, vec_f.data(), vec_ids);
rc.ElapseFromBegin("add vectors to engine");
if (!stat.ok()) {
return SetError(SERVER_CACHE_ERROR, "Cache error: " + stat.ToString());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册