未验证 提交 dbf07dfd 编写于 作者: Y yah01 提交者: GitHub

Convert double to int if possible with term expression (#24530) (#24539)

Signed-off-by: Nyah01 <yah2er0ne@outlook.com>
上级 be62f82d
...@@ -1393,7 +1393,7 @@ ExecExprVisitor::ExecTermVisitorImplTemplateJson(TermExpr& expr_raw) -> BitsetTy ...@@ -1393,7 +1393,7 @@ ExecExprVisitor::ExecTermVisitorImplTemplateJson(TermExpr& expr_raw) -> BitsetTy
using Index = index::ScalarIndex<milvus::Json>; using Index = index::ScalarIndex<milvus::Json>;
auto& expr = static_cast<TermExprImpl<ExprValueType>&>(expr_raw); auto& expr = static_cast<TermExprImpl<ExprValueType>&>(expr_raw);
auto pointer = milvus::Json::pointer(expr.column_.nested_path); auto pointer = milvus::Json::pointer(expr.column_.nested_path);
auto index_func = [=](Index* index) { return TargetBitmap{}; }; auto index_func = [](Index* index) { return TargetBitmap{}; };
std::unordered_set<ExprValueType> term_set(expr.terms_.begin(), expr.terms_.end()); std::unordered_set<ExprValueType> term_set(expr.terms_.begin(), expr.terms_.end());
...@@ -1406,6 +1406,16 @@ ExecExprVisitor::ExecTermVisitorImplTemplateJson(TermExpr& expr_raw) -> BitsetTy ...@@ -1406,6 +1406,16 @@ ExecExprVisitor::ExecTermVisitorImplTemplateJson(TermExpr& expr_raw) -> BitsetTy
using GetType = std::conditional_t<std::is_same_v<ExprValueType, std::string>, std::string_view, ExprValueType>; using GetType = std::conditional_t<std::is_same_v<ExprValueType, std::string>, std::string_view, ExprValueType>;
auto x = json.template at<GetType>(pointer); auto x = json.template at<GetType>(pointer);
if (x.error()) { if (x.error()) {
if constexpr (std::is_same_v<GetType, std::int64_t>) {
auto x = json.template at<double>(pointer);
if (x.error()) {
return false;
}
auto value = x.value();
// if the term set is {1}, and the value is 1.1, we should not return true.
return std::floor(value) == value && term_set.find(ExprValueType(value)) != term_set.end();
}
return false; return false;
} }
return term_set.find(ExprValueType(x.value())) != term_set.end(); return term_set.find(ExprValueType(x.value())) != term_set.end();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册