#include #include #include namespace DB { /// Working with UInt8: last bit = can be true, previous = can be false (Like dbms/src/Storages/MergeTree/BoolMask.h). /// This function wraps bool atomic functions /// and transforms their boolean return value to the BoolMask ("can be false" and "can be true" bits). template struct BitWrapperFuncImpl { using ResultType = UInt8; static inline ResultType NO_SANITIZE_UNDEFINED apply(A a) { return a == static_cast(0) ? static_cast(0b10) : static_cast(0b1); } #if USE_EMBEDDED_COMPILER static constexpr bool compilable = false; #endif }; struct NameBitWrapperFunc { static constexpr auto name = "__bitWrapperFunc"; }; using FunctionBitWrapperFunc = FunctionUnaryArithmetic; template <> struct FunctionUnaryArithmeticMonotonicity { static bool has() { return false; } static IFunction::Monotonicity get(const Field &, const Field &) { return {}; } }; void registerFunctionBitWrapperFunc(FunctionFactory & factory) { factory.registerFunction(); } }