| 1 | #include <Functions/FunctionFactory.h> |
|---|---|
| 2 | #include <Functions/FunctionBinaryArithmetic.h> |
| 3 | #include <Core/Defines.h> |
| 4 | |
| 5 | |
| 6 | namespace DB |
| 7 | { |
| 8 | |
| 9 | template <typename A, typename B> |
| 10 | struct BitTestImpl |
| 11 | { |
| 12 | using ResultType = UInt8; |
| 13 | |
| 14 | template <typename Result = ResultType> |
| 15 | NO_SANITIZE_UNDEFINED static inline Result apply(A a, B b) |
| 16 | { |
| 17 | return (typename NumberTraits::ToInteger<A>::Type(a) >> typename NumberTraits::ToInteger<B>::Type(b)) & 1; |
| 18 | } |
| 19 | |
| 20 | #if USE_EMBEDDED_COMPILER |
| 21 | static constexpr bool compilable = false; /// TODO |
| 22 | #endif |
| 23 | }; |
| 24 | |
| 25 | struct NameBitTest { static constexpr auto name = "bitTest"; }; |
| 26 | using FunctionBitTest = FunctionBinaryArithmetic<BitTestImpl, NameBitTest>; |
| 27 | |
| 28 | void registerFunctionBitTest(FunctionFactory & factory) |
| 29 | { |
| 30 | factory.registerFunction<FunctionBitTest>(); |
| 31 | } |
| 32 | |
| 33 | } |
| 34 |