diff --git a/internal/core/src/exec/expression/TermExpr.cpp b/internal/core/src/exec/expression/TermExpr.cpp index a51244b891..ece522624f 100644 --- a/internal/core/src/exec/expression/TermExpr.cpp +++ b/internal/core/src/exec/expression/TermExpr.cpp @@ -838,29 +838,36 @@ PhyTermFilterExpr::ExecVisitorImplForIndex() { return nullptr; } - std::vector vals; - for (auto& val : expr_->vals_) { - if constexpr (std::is_same_v) { - if (val.has_int64_val()) { - // only json field will cast int to double because other fields are casted in proxy - vals.emplace_back(static_cast(val.int64_val())); - continue; + if (!arg_inited_) { + std::vector vals; + for (auto& val : expr_->vals_) { + if constexpr (std::is_same_v) { + if (val.has_int64_val()) { + // only json field will cast int to double because other fields are casted in proxy + vals.emplace_back(static_cast(val.int64_val())); + continue; + } + } + + // Generic overflow handling for all types + bool overflowed = false; + auto converted_val = + GetValueFromProtoWithOverflow(val, overflowed); + if (!overflowed) { + vals.emplace_back(converted_val); } } - - // Generic overflow handling for all types - bool overflowed = false; - auto converted_val = GetValueFromProtoWithOverflow(val, overflowed); - if (!overflowed) { - vals.emplace_back(converted_val); - } + arg_set_ = std::make_shared>(vals); + arg_inited_ = true; } auto execute_sub_batch = [](Index* index_ptr, const std::vector& vals) { TermIndexFunc func; return func(index_ptr, vals.size(), vals.data()); }; - auto res = ProcessIndexChunks(execute_sub_batch, vals); + auto args = + std::dynamic_pointer_cast>(arg_set_); + auto res = ProcessIndexChunks(execute_sub_batch, args->values_); AssertInfo(res->size() == real_batch_size, "internal error: expr processed rows {} not equal " "expect batch size {}",