提交 5264144d 编写于 作者: Y yudong.cai

optimize grpc insert


Former-commit-id: 1f9d5ee34055303208c48e745d1252ae3c0b60a8
上级 d416d1c6
...@@ -428,7 +428,6 @@ InsertTask::OnExecute() { ...@@ -428,7 +428,6 @@ InsertTask::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_param_.row_record_array_size(); i++) { 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()) { if (insert_param_.row_record_array(i).vector_data().empty()) {
return SetError(SERVER_INVALID_ROWRECORD_ARRAY, "Row record float array is empty"); return SetError(SERVER_INVALID_ROWRECORD_ARRAY, "Row record float array is empty");
} }
...@@ -440,8 +439,10 @@ InsertTask::OnExecute() { ...@@ -440,8 +439,10 @@ InsertTask::OnExecute() {
std::to_string(table_info.dimension_); std::to_string(table_info.dimension_);
return SetError(error_code, error_msg); return SetError(error_code, error_msg);
} }
vec_f[i * table_info.dimension_ + j] = insert_param_.row_record_array(i).vector_data(j);
} 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"); rc.ElapseFromBegin("prepare vectors data");
...@@ -453,8 +454,7 @@ InsertTask::OnExecute() { ...@@ -453,8 +454,7 @@ InsertTask::OnExecute() {
vec_ids[i] = insert_param_.row_id_array(i); vec_ids[i] = insert_param_.row_id_array(i);
} }
stat = DBWrapper::DB()->InsertVectors(insert_param_.table_name(), vec_count, vec_f.data(), stat = DBWrapper::DB()->InsertVectors(insert_param_.table_name(), vec_count, vec_f.data(), vec_ids);
vec_ids);
rc.ElapseFromBegin("add vectors to engine"); rc.ElapseFromBegin("add vectors to engine");
if (!stat.ok()) { if (!stat.ok()) {
return SetError(SERVER_CACHE_ERROR, "Cache error: " + stat.ToString()); 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.
先完成此消息的编辑!
想要评论请 注册