mirror of https://github.com/milvus-io/milvus.git
Convert double to int if possible with term expression (#24530)
Signed-off-by: yah01 <yah2er0ne@outlook.com>pull/24549/head
parent
f7924724b0
commit
852e5ce904
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/utility/binary.hpp>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <deque>
|
||||
#include <optional>
|
||||
|
@ -1743,7 +1745,7 @@ ExecExprVisitor::ExecTermVisitorImplTemplateJson(TermExpr& expr_raw)
|
|||
using Index = index::ScalarIndex<milvus::Json>;
|
||||
auto& expr = static_cast<TermExprImpl<ExprValueType>&>(expr_raw);
|
||||
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());
|
||||
|
@ -1761,6 +1763,17 @@ ExecExprVisitor::ExecTermVisitorImplTemplateJson(TermExpr& expr_raw)
|
|||
ExprValueType>;
|
||||
auto x = json.template at<GetType>(pointer);
|
||||
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 term_set.find(ExprValueType(x.value())) != term_set.end();
|
||||
|
|
Loading…
Reference in New Issue