@@ -810,29 +810,36 @@ PhyTermFilterExpr::ExecVisitorImplForIndex() {
810810 return nullptr ;
811811 }
812812
813- std::vector<IndexInnerType> vals;
814- for (auto & val : expr_->vals_ ) {
815- if constexpr (std::is_same_v<T, double >) {
816- if (val.has_int64_val ()) {
817- // only json field will cast int to double because other fields are casted in proxy
818- vals.emplace_back (static_cast <double >(val.int64_val ()));
819- continue ;
813+ if (!arg_inited_) {
814+ std::vector<IndexInnerType> vals;
815+ for (auto & val : expr_->vals_ ) {
816+ if constexpr (std::is_same_v<T, double >) {
817+ if (val.has_int64_val ()) {
818+ // only json field will cast int to double because other fields are casted in proxy
819+ vals.emplace_back (static_cast <double >(val.int64_val ()));
820+ continue ;
821+ }
820822 }
821- }
822823
823- // Generic overflow handling for all types
824- bool overflowed = false ;
825- auto converted_val = GetValueFromProtoWithOverflow<T>(val, overflowed);
826- if (!overflowed) {
827- vals.emplace_back (converted_val);
824+ // Generic overflow handling for all types
825+ bool overflowed = false ;
826+ auto converted_val =
827+ GetValueFromProtoWithOverflow<T>(val, overflowed);
828+ if (!overflowed) {
829+ vals.emplace_back (converted_val);
830+ }
828831 }
832+ arg_set_ = std::make_shared<FlatVectorElement<IndexInnerType>>(vals);
833+ arg_inited_ = true ;
829834 }
830835 auto execute_sub_batch = [](Index* index_ptr,
831836 const std::vector<IndexInnerType>& vals) {
832837 TermIndexFunc<T> func;
833838 return func (index_ptr, vals.size (), vals.data ());
834839 };
835- auto res = ProcessIndexChunks<T>(execute_sub_batch, vals);
840+ auto args =
841+ std::dynamic_pointer_cast<FlatVectorElement<IndexInnerType>>(arg_set_);
842+ auto res = ProcessIndexChunks<T>(execute_sub_batch, args->values_ );
836843 AssertInfo (res->size () == real_batch_size,
837844 " internal error: expr processed rows {} not equal "
838845 " expect batch size {}" ,
0 commit comments