From bc5be6380dfab60cd1e56a9297f94f04a303da46 Mon Sep 17 00:00:00 2001 From: zhagnlu <1542303831@qq.com> Date: Tue, 3 Jun 2025 10:08:31 +0800 Subject: [PATCH] fix: Add explicit move semantics to get_batch_view interface (#42402) pr: #42403 Signed-off-by: luzhang Co-authored-by: luzhang --- internal/core/src/exec/expression/UnaryExpr.h | 67 +++++++++++++++---- .../src/segcore/ChunkedSegmentSealedImpl.cpp | 2 +- internal/core/src/segcore/SegmentInterface.h | 2 +- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/internal/core/src/exec/expression/UnaryExpr.h b/internal/core/src/exec/expression/UnaryExpr.h index 5be7bcf2b5..10267a8982 100644 --- a/internal/core/src/exec/expression/UnaryExpr.h +++ b/internal/core/src/exec/expression/UnaryExpr.h @@ -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 || - std::is_same_v) { + 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 || + std::is_same_v) { + 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( src, size, val); @@ -139,9 +180,9 @@ struct UnaryElementFunc { res.inplace_compare_val( src, size, val); } else { - PanicInfo( - OpTypeInvalid, - fmt::format("unsupported op_type:{} for UnaryElementFunc", op)); + PanicInfo(OpTypeInvalid, + "unsupported op_type:{} for UnaryElementFunc", + op); } } }; diff --git a/internal/core/src/segcore/ChunkedSegmentSealedImpl.cpp b/internal/core/src/segcore/ChunkedSegmentSealedImpl.cpp index 100aabd807..885ca5d7f0 100644 --- a/internal/core/src/segcore/ChunkedSegmentSealedImpl.cpp +++ b/internal/core/src/segcore/ChunkedSegmentSealedImpl.cpp @@ -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"); diff --git a/internal/core/src/segcore/SegmentInterface.h b/internal/core/src/segcore/SegmentInterface.h index af04786e78..5cfa55f421 100644 --- a/internal/core/src/segcore/SegmentInterface.h +++ b/internal/core/src/segcore/SegmentInterface.h @@ -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