fix: Add explicit move semantics to get_batch_view interface (#42402)

pr: #42403

Signed-off-by: luzhang <luzhang@zilliz.com>
Co-authored-by: luzhang <luzhang@zilliz.com>
This commit is contained in:
zhagnlu 2025-06-03 10:08:31 +08:00 committed by GitHub
parent ad8067f76e
commit bc5be6380d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 56 additions and 15 deletions

View File

@ -86,13 +86,8 @@ struct UnaryElementFunc {
// This is the original code, which is kept for the documentation purposes
// also, for iterative filter
if constexpr (filter_type == FilterType::random ||
std::is_same_v<T, std::string_view> ||
std::is_same_v<T, std::string>) {
if constexpr (filter_type == FilterType::random) {
for (int i = 0; i < size; ++i) {
if (has_bitmap_input && !bitmap_input[i + start_cursor]) {
continue;
}
auto offset = (offsets != nullptr) ? offsets[i] : i;
if constexpr (op == proto::plan::OpType::Equal) {
res[i] = src[offset] == val;
@ -111,15 +106,61 @@ struct UnaryElementFunc {
op == proto::plan::OpType::InnerMatch) {
res[i] = milvus::query::Match(src[offset], val, op);
} else {
PanicInfo(
OpTypeInvalid,
fmt::format(
"unsupported op_type:{} for UnaryElementFunc", op));
PanicInfo(OpTypeInvalid,
"unsupported op_type:{} for UnaryElementFunc",
op);
}
}
return;
}
if (has_bitmap_input) {
if constexpr (std::is_same_v<T, std::string_view> ||
std::is_same_v<T, std::string>) {
for (int i = 0; i < size; ++i) {
if (!bitmap_input[i + start_cursor]) {
continue;
}
if constexpr (op == proto::plan::OpType::Equal) {
res[i] = src[i] == val;
} else if constexpr (op == proto::plan::OpType::NotEqual) {
res[i] = src[i] != val;
} else if constexpr (op ==
proto::plan::OpType::GreaterThan) {
res[i] = src[i] > val;
} else if constexpr (op == proto::plan::OpType::LessThan) {
res[i] = src[i] < val;
} else if constexpr (op ==
proto::plan::OpType::GreaterEqual) {
res[i] = src[i] >= val;
} else if constexpr (op == proto::plan::OpType::LessEqual) {
res[i] = src[i] <= val;
} else if constexpr (op ==
proto::plan::OpType::PrefixMatch ||
op == proto::plan::OpType::
PostfixMatch ||
op ==
proto::plan::OpType::InnerMatch) {
res[i] = milvus::query::Match(src[i], val, op);
} else {
PanicInfo(OpTypeInvalid,
"unsupported op_type:{} for UnaryElementFunc",
op);
}
}
return;
}
}
if constexpr (op == proto::plan::OpType::PrefixMatch ||
op == proto::plan::OpType::PostfixMatch ||
op == proto::plan::OpType::InnerMatch) {
for (int i = 0; i < size; ++i) {
res[i] = milvus::query::Match(src[i], val, op);
}
return;
}
if constexpr (op == proto::plan::OpType::Equal) {
res.inplace_compare_val<T, milvus::bitset::CompareOpType::EQ>(
src, size, val);
@ -139,9 +180,9 @@ struct UnaryElementFunc {
res.inplace_compare_val<T, milvus::bitset::CompareOpType::LE>(
src, size, val);
} else {
PanicInfo(
OpTypeInvalid,
fmt::format("unsupported op_type:{} for UnaryElementFunc", op));
PanicInfo(OpTypeInvalid,
"unsupported op_type:{} for UnaryElementFunc",
op);
}
}
};

View File

@ -736,7 +736,7 @@ ChunkedSegmentSealedImpl::get_chunk_buffer(FieldId field_id,
}
return std::make_pair(
field_data->GetBatchBuffer(chunk_id, start_offset, length),
valid_data);
std::move(valid_data));
}
PanicInfo(ErrorCode::UnexpectedError,
"get_chunk_buffer only used for variable column field");

View File

@ -213,7 +213,7 @@ class SegmentInternalInterface : public SegmentInterface {
}
}
}
return std::make_pair(res, chunk_info.second);
return std::make_pair(std::move(res), std::move(chunk_info.second));
}
template <typename ViewType>