remove unused code and opt int_div (#8966)
This commit is contained in:
@ -20,21 +20,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/compiler_util.h"
|
||||
#include "common/logging.h"
|
||||
#include "common/status.h"
|
||||
#include "runtime/decimalv2_value.h"
|
||||
#include "type_traits"
|
||||
#include "vec/columns/column_nullable.h"
|
||||
#include "vec/common/exception.h"
|
||||
#include "vec/data_types/number_traits.h"
|
||||
|
||||
namespace doris::vectorized {
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
template <typename A, typename B>
|
||||
struct DivideIntegralImpl {
|
||||
using ResultType = typename NumberTraits::ResultOfIntegerDivision<A, B>::Type;
|
||||
@ -42,14 +32,7 @@ struct DivideIntegralImpl {
|
||||
template <typename Result = ResultType>
|
||||
static inline Result apply(A a, B b, NullMap& null_map, size_t index) {
|
||||
null_map[index] = b == 0;
|
||||
|
||||
/// Otherwise overflow may occur due to integer promotion. Example: int8_t(-1) / uint64_t(2).
|
||||
/// NOTE: overflow is still possible when dividing large signed number to large unsigned number or vice-versa. But it's less harmful.
|
||||
if constexpr (std::is_integral_v<A> && std::is_integral_v<B> &&
|
||||
(std::is_signed_v<A> || std::is_signed_v<B>))
|
||||
return std::make_signed_t<A>(a) / (std::make_signed_t<B>(b) + (b == 0));
|
||||
else
|
||||
return a / (b + (b == 0));
|
||||
return a / (b + null_map[index]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user