enhance: optimize term expr performance (#45491)

issue: https://github.com/milvus-io/milvus/issues/45641

---------

Signed-off-by: sunby <sunbingyi1992@gmail.com>
This commit is contained in:
Bingyi Sun 2025-11-21 11:01:05 +08:00 committed by GitHub
parent 3202847092
commit 275a5b9afc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -838,6 +838,7 @@ PhyTermFilterExpr::ExecVisitorImplForIndex() {
return nullptr;
}
if (!arg_inited_) {
std::vector<IndexInnerType> vals;
for (auto& val : expr_->vals_) {
if constexpr (std::is_same_v<T, double>) {
@ -850,17 +851,23 @@ PhyTermFilterExpr::ExecVisitorImplForIndex() {
// Generic overflow handling for all types
bool overflowed = false;
auto converted_val = GetValueFromProtoWithOverflow<T>(val, overflowed);
auto converted_val =
GetValueFromProtoWithOverflow<T>(val, overflowed);
if (!overflowed) {
vals.emplace_back(converted_val);
}
}
arg_set_ = std::make_shared<FlatVectorElement<IndexInnerType>>(vals);
arg_inited_ = true;
}
auto execute_sub_batch = [](Index* index_ptr,
const std::vector<IndexInnerType>& vals) {
TermIndexFunc<T> func;
return func(index_ptr, vals.size(), vals.data());
};
auto res = ProcessIndexChunks<T>(execute_sub_batch, vals);
auto args =
std::dynamic_pointer_cast<FlatVectorElement<IndexInnerType>>(arg_set_);
auto res = ProcessIndexChunks<T>(execute_sub_batch, args->values_);
AssertInfo(res->size() == real_batch_size,
"internal error: expr processed rows {} not equal "
"expect batch size {}",