fix: Fix modulo for long type (#39722)

issue: #39640

Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
pull/39807/head
cai.zhang 2025-02-11 20:04:46 +08:00 committed by GitHub
parent 5cdd906d4b
commit 9e6e477c5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 13 deletions

View File

@ -148,7 +148,7 @@ struct ArithCompareOperator {
} else if constexpr (AOp == ArithOpType::Div) { } else if constexpr (AOp == ArithOpType::Div) {
return CompareOperator<CmpOp>::compare(left / right, value); return CompareOperator<CmpOp>::compare(left / right, value);
} else if constexpr (AOp == ArithOpType::Mod) { } else if constexpr (AOp == ArithOpType::Mod) {
return CompareOperator<CmpOp>::compare(fmod(left, right), value); return CompareOperator<CmpOp>::compare(long(left) % long(right), value);
} else { } else {
// unimplemented // unimplemented
static_assert(always_false_v<T>, "unimplemented"); static_assert(always_false_v<T>, "unimplemented");

View File

@ -122,7 +122,7 @@ struct ArithOpElementFunc {
res[i] = (src[offset] / right_operand) == val; res[i] = (src[offset] / right_operand) == val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(src[offset], right_operand)) == val; res[i] = (long(src[offset]) % long(right_operand)) == val;
} else { } else {
PanicInfo(OpTypeInvalid, PanicInfo(OpTypeInvalid,
fmt::format("unsupported arith type:{} for " fmt::format("unsupported arith type:{} for "
@ -143,7 +143,7 @@ struct ArithOpElementFunc {
res[i] = (src[offset] / right_operand) != val; res[i] = (src[offset] / right_operand) != val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(src[offset], right_operand)) != val; res[i] = (long(src[offset]) % long(right_operand)) != val;
} else { } else {
PanicInfo(OpTypeInvalid, PanicInfo(OpTypeInvalid,
fmt::format("unsupported arith type:{} for " fmt::format("unsupported arith type:{} for "
@ -165,7 +165,7 @@ struct ArithOpElementFunc {
res[i] = (src[offset] / right_operand) > val; res[i] = (src[offset] / right_operand) > val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(src[offset], right_operand)) > val; res[i] = (long(src[offset]) % long(right_operand)) > val;
} else { } else {
PanicInfo(OpTypeInvalid, PanicInfo(OpTypeInvalid,
fmt::format("unsupported arith type:{} for " fmt::format("unsupported arith type:{} for "
@ -187,7 +187,7 @@ struct ArithOpElementFunc {
res[i] = (src[offset] / right_operand) >= val; res[i] = (src[offset] / right_operand) >= val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(src[offset], right_operand)) >= val; res[i] = (long(src[offset]) % long(right_operand)) >= val;
} else { } else {
PanicInfo(OpTypeInvalid, PanicInfo(OpTypeInvalid,
fmt::format("unsupported arith type:{} for " fmt::format("unsupported arith type:{} for "
@ -208,7 +208,7 @@ struct ArithOpElementFunc {
res[i] = (src[offset] / right_operand) < val; res[i] = (src[offset] / right_operand) < val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(src[offset], right_operand)) < val; res[i] = (long(src[offset]) % long(right_operand)) < val;
} else { } else {
PanicInfo(OpTypeInvalid, PanicInfo(OpTypeInvalid,
fmt::format("unsupported arith type:{} for " fmt::format("unsupported arith type:{} for "
@ -229,7 +229,7 @@ struct ArithOpElementFunc {
res[i] = (src[offset] / right_operand) <= val; res[i] = (src[offset] / right_operand) <= val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(src[offset], right_operand)) <= val; res[i] = (long(src[offset]) % long(right_operand)) <= val;
} else { } else {
PanicInfo(OpTypeInvalid, PanicInfo(OpTypeInvalid,
fmt::format("unsupported arith type:{} for " fmt::format("unsupported arith type:{} for "
@ -309,7 +309,7 @@ struct ArithOpIndexFunc {
res[i] = (raw.value() / right_operand) == val; res[i] = (raw.value() / right_operand) == val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(raw.value(), right_operand)) == val; res[i] = (long(raw.value()) % long(right_operand)) == val;
} else { } else {
PanicInfo( PanicInfo(
OpTypeInvalid, OpTypeInvalid,
@ -331,7 +331,7 @@ struct ArithOpIndexFunc {
res[i] = (raw.value() / right_operand) != val; res[i] = (raw.value() / right_operand) != val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(raw.value(), right_operand)) != val; res[i] = (long(raw.value()) % long(right_operand)) != val;
} else { } else {
PanicInfo( PanicInfo(
OpTypeInvalid, OpTypeInvalid,
@ -353,7 +353,7 @@ struct ArithOpIndexFunc {
res[i] = (raw.value() / right_operand) > val; res[i] = (raw.value() / right_operand) > val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(raw.value(), right_operand)) > val; res[i] = (long(raw.value()) % long(right_operand)) > val;
} else { } else {
PanicInfo( PanicInfo(
OpTypeInvalid, OpTypeInvalid,
@ -375,7 +375,7 @@ struct ArithOpIndexFunc {
res[i] = (raw.value() / right_operand) >= val; res[i] = (raw.value() / right_operand) >= val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(raw.value(), right_operand)) >= val; res[i] = (long(raw.value()) % long(right_operand)) >= val;
} else { } else {
PanicInfo( PanicInfo(
OpTypeInvalid, OpTypeInvalid,
@ -397,7 +397,7 @@ struct ArithOpIndexFunc {
res[i] = (raw.value() / right_operand) < val; res[i] = (raw.value() / right_operand) < val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(raw.value(), right_operand)) < val; res[i] = (long(raw.value()) % long(right_operand)) < val;
} else { } else {
PanicInfo( PanicInfo(
OpTypeInvalid, OpTypeInvalid,
@ -419,7 +419,7 @@ struct ArithOpIndexFunc {
res[i] = (raw.value() / right_operand) <= val; res[i] = (raw.value() / right_operand) <= val;
} else if constexpr (arith_op == } else if constexpr (arith_op ==
proto::plan::ArithOpType::Mod) { proto::plan::ArithOpType::Mod) {
res[i] = (fmod(raw.value(), right_operand)) <= val; res[i] = (long(raw.value()) % long(right_operand)) <= val;
} else { } else {
PanicInfo( PanicInfo(
OpTypeInvalid, OpTypeInvalid,