Reduce copy while retrieving primary keys (#26616)

Signed-off-by: yah01 <yang.cen@zilliz.com>
pull/27151/head
yah01 2023-09-11 21:31:18 +08:00 committed by GitHub
parent c3f15c6b95
commit 3203ce1654
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -513,7 +513,8 @@ SegmentGrowingImpl::search_ids(const IdArray& id_array,
auto res_id_arr = std::make_unique<IdArray>(); auto res_id_arr = std::make_unique<IdArray>();
std::vector<SegOffset> res_offsets; std::vector<SegOffset> res_offsets;
for (auto pk : pks) { res_offsets.reserve(pks.size());
for (auto& pk : pks) {
auto segOffsets = insert_record_.search_pk(pk, timestamp); auto segOffsets = insert_record_.search_pk(pk, timestamp);
for (auto offset : segOffsets) { for (auto offset : segOffsets) {
switch (data_type) { switch (data_type) {
@ -524,7 +525,7 @@ SegmentGrowingImpl::search_ids(const IdArray& id_array,
} }
case DataType::VARCHAR: { case DataType::VARCHAR: {
res_id_arr->mutable_str_id()->add_data( res_id_arr->mutable_str_id()->add_data(
std::get<std::string>(pk)); std::get<std::string>(std::move(pk)));
break; break;
} }
default: { default: {

View File

@ -956,7 +956,8 @@ SegmentSealedImpl::search_ids(const IdArray& id_array,
auto res_id_arr = std::make_unique<IdArray>(); auto res_id_arr = std::make_unique<IdArray>();
std::vector<SegOffset> res_offsets; std::vector<SegOffset> res_offsets;
for (auto pk : pks) { res_offsets.reserve(pks.size());
for (auto& pk : pks) {
auto segOffsets = insert_record_.search_pk(pk, timestamp); auto segOffsets = insert_record_.search_pk(pk, timestamp);
for (auto offset : segOffsets) { for (auto offset : segOffsets) {
switch (data_type) { switch (data_type) {
@ -967,7 +968,7 @@ SegmentSealedImpl::search_ids(const IdArray& id_array,
} }
case DataType::VARCHAR: { case DataType::VARCHAR: {
res_id_arr->mutable_str_id()->add_data( res_id_arr->mutable_str_id()->add_data(
std::get<std::string>(pk)); std::get<std::string>(std::move(pk)));
break; break;
} }
default: { default: {