2020-09-08 00:59:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-08-20 14:06:57 +00:00
|
|
|
/// These classes should be present in DB namespace (cannot place them into namelesspace)
|
2020-09-08 00:59:13 +00:00
|
|
|
template <typename> struct AbsImpl;
|
2023-04-22 17:21:43 +00:00
|
|
|
template <typename> struct BitCountImpl;
|
2023-04-23 11:31:23 +00:00
|
|
|
template <typename> struct NegateImpl;
|
|
|
|
template <typename> struct SignImpl;
|
2020-09-08 00:59:13 +00:00
|
|
|
template <typename, typename> struct PlusImpl;
|
|
|
|
template <typename, typename> struct MinusImpl;
|
|
|
|
template <typename, typename> struct MultiplyImpl;
|
|
|
|
template <typename, typename> struct DivideFloatingImpl;
|
|
|
|
template <typename, typename> struct DivideIntegralImpl;
|
|
|
|
template <typename, typename> struct DivideIntegralOrZeroImpl;
|
|
|
|
template <typename, typename> struct LeastBaseImpl;
|
|
|
|
template <typename, typename> struct GreatestBaseImpl;
|
|
|
|
template <typename, typename> struct ModuloImpl;
|
2022-11-14 23:15:58 +00:00
|
|
|
template <typename, typename> struct PositiveModuloImpl;
|
2020-09-08 00:59:13 +00:00
|
|
|
template <typename, typename> struct EqualsOp;
|
|
|
|
template <typename, typename> struct NotEqualsOp;
|
|
|
|
template <typename, typename> struct LessOrEqualsOp;
|
|
|
|
template <typename, typename> struct GreaterOrEqualsOp;
|
2022-01-19 06:02:24 +00:00
|
|
|
template <typename, typename> struct BitHammingDistanceImpl;
|
2020-09-08 00:59:13 +00:00
|
|
|
|
|
|
|
template <template <typename, typename> typename Op1, template <typename, typename> typename Op2>
|
|
|
|
struct IsSameOperation
|
|
|
|
{
|
|
|
|
static constexpr bool value = std::is_same_v<Op1<UInt8, UInt8>, Op2<UInt8, UInt8>>;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <template <typename> typename Op>
|
|
|
|
struct IsUnaryOperation
|
|
|
|
{
|
|
|
|
static constexpr bool abs = std::is_same_v<Op<Int8>, AbsImpl<Int8>>;
|
|
|
|
static constexpr bool negate = std::is_same_v<Op<Int8>, NegateImpl<Int8>>;
|
2021-01-26 11:26:15 +00:00
|
|
|
static constexpr bool sign = std::is_same_v<Op<Int8>, SignImpl<Int8>>;
|
2023-04-22 17:21:43 +00:00
|
|
|
static constexpr bool bit_count = std::is_same_v<Op<Int8>, BitCountImpl<Int8>>;
|
2020-09-08 00:59:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <template <typename, typename> typename Op>
|
|
|
|
struct IsOperation
|
|
|
|
{
|
|
|
|
static constexpr bool equals = IsSameOperation<Op, EqualsOp>::value;
|
|
|
|
static constexpr bool not_equals = IsSameOperation<Op, NotEqualsOp>::value;
|
|
|
|
static constexpr bool less_or_equals = IsSameOperation<Op, LessOrEqualsOp>::value;
|
|
|
|
static constexpr bool greater_or_equals = IsSameOperation<Op, GreaterOrEqualsOp>::value;
|
|
|
|
|
|
|
|
static constexpr bool plus = IsSameOperation<Op, PlusImpl>::value;
|
|
|
|
static constexpr bool minus = IsSameOperation<Op, MinusImpl>::value;
|
|
|
|
static constexpr bool multiply = IsSameOperation<Op, MultiplyImpl>::value;
|
|
|
|
static constexpr bool div_floating = IsSameOperation<Op, DivideFloatingImpl>::value;
|
|
|
|
static constexpr bool div_int = IsSameOperation<Op, DivideIntegralImpl>::value;
|
|
|
|
static constexpr bool div_int_or_zero = IsSameOperation<Op, DivideIntegralOrZeroImpl>::value;
|
|
|
|
static constexpr bool modulo = IsSameOperation<Op, ModuloImpl>::value;
|
2022-11-14 23:15:58 +00:00
|
|
|
static constexpr bool positive_modulo = IsSameOperation<Op, PositiveModuloImpl>::value;
|
2020-09-08 00:59:13 +00:00
|
|
|
static constexpr bool least = IsSameOperation<Op, LeastBaseImpl>::value;
|
|
|
|
static constexpr bool greatest = IsSameOperation<Op, GreatestBaseImpl>::value;
|
|
|
|
|
2022-01-19 06:02:24 +00:00
|
|
|
static constexpr bool bit_hamming_distance = IsSameOperation<Op, BitHammingDistanceImpl>::value;
|
|
|
|
|
2020-09-08 00:59:13 +00:00
|
|
|
static constexpr bool division = div_floating || div_int || div_int_or_zero;
|
|
|
|
|
2022-01-01 09:05:29 +00:00
|
|
|
static constexpr bool allow_decimal = plus || minus || multiply || division || least || greatest;
|
2020-09-08 00:59:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|