mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-24 02:30:51 +00:00
add comments
This commit is contained in:
parent
53cc2b4856
commit
5d47a858c5
@ -5,6 +5,10 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
/// Working with UInt8: last bit = can be true, previous = can be false (Like dbms/src/Storages/MergeTree/BoolMask.h).
|
||||
/// This function provides "AND" operation for BoolMasks.
|
||||
/// Returns: "can be true" = A."can be true" AND B."can be true"
|
||||
/// "can be false" = A."can be false" OR B."can be false"
|
||||
template <typename A, typename B>
|
||||
struct BitBoolMaskAndImpl
|
||||
{
|
||||
|
@ -5,6 +5,10 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
/// Working with UInt8: last bit = can be true, previous = can be false (Like dbms/src/Storages/MergeTree/BoolMask.h).
|
||||
/// This function provides "OR" operation for BoolMasks.
|
||||
/// Returns: "can be true" = A."can be true" OR B."can be true"
|
||||
/// "can be false" = A."can be false" AND B."can be false"
|
||||
template <typename A, typename B>
|
||||
struct BitBoolMaskOrImpl
|
||||
{
|
||||
|
@ -5,16 +5,18 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
template <typename A>
|
||||
struct BitSwapLastTwoImpl
|
||||
{
|
||||
using ResultType = UInt8;
|
||||
|
||||
static inline ResultType NO_SANITIZE_UNDEFINED apply(A a)
|
||||
/// Working with UInt8: last bit = can be true, previous = can be false (Like dbms/src/Storages/MergeTree/BoolMask.h).
|
||||
/// This function provides "NOT" operation for BoolMasks by swapping last two bits ("can be true" <-> "can be false").
|
||||
template <typename A>
|
||||
struct BitSwapLastTwoImpl
|
||||
{
|
||||
return static_cast<ResultType>(
|
||||
((static_cast<ResultType>(a) & 1) << 1) | ((static_cast<ResultType>(a) >> 1) & 1));
|
||||
}
|
||||
using ResultType = UInt8;
|
||||
|
||||
static inline ResultType NO_SANITIZE_UNDEFINED apply(A a)
|
||||
{
|
||||
return static_cast<ResultType>(
|
||||
((static_cast<ResultType>(a) & 1) << 1) | ((static_cast<ResultType>(a) >> 1) & 1));
|
||||
}
|
||||
|
||||
#if USE_EMBEDDED_COMPILER
|
||||
static constexpr bool compilable = true;
|
||||
@ -29,23 +31,23 @@ struct BitSwapLastTwoImpl
|
||||
);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
struct NameBitSwapLastTwo { static constexpr auto name = "__bitSwapLastTwo"; };
|
||||
using FunctionBitSwapLastTwo = FunctionUnaryArithmetic<BitSwapLastTwoImpl, NameBitSwapLastTwo, true>;
|
||||
struct NameBitSwapLastTwo { static constexpr auto name = "__bitSwapLastTwo"; };
|
||||
using FunctionBitSwapLastTwo = FunctionUnaryArithmetic<BitSwapLastTwoImpl, NameBitSwapLastTwo, true>;
|
||||
|
||||
template <> struct FunctionUnaryArithmeticMonotonicity<NameBitSwapLastTwo>
|
||||
{
|
||||
static bool has() { return false; }
|
||||
static IFunction::Monotonicity get(const Field &, const Field &)
|
||||
template <> struct FunctionUnaryArithmeticMonotonicity<NameBitSwapLastTwo>
|
||||
{
|
||||
return {};
|
||||
static bool has() { return false; }
|
||||
static IFunction::Monotonicity get(const Field &, const Field &)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
void registerFunctionBitSwapLastTwo(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionBitSwapLastTwo>();
|
||||
}
|
||||
};
|
||||
|
||||
void registerFunctionBitSwapLastTwo(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionBitSwapLastTwo>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,9 @@
|
||||
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 <typename A>
|
||||
struct BitWrapperFuncImpl
|
||||
{
|
||||
|
@ -227,8 +227,6 @@ MergeTreeIndexConditionSet::MergeTreeIndexConditionSet(
|
||||
|
||||
const auto & select = query.query->as<ASTSelectQuery &>();
|
||||
|
||||
/// Replace logical functions with bit functions.
|
||||
/// Working with UInt8: last bit = can be true, previous = can be false.
|
||||
if (select.where() && select.prewhere())
|
||||
expression_ast = makeASTFunction(
|
||||
"and",
|
||||
@ -246,6 +244,8 @@ MergeTreeIndexConditionSet::MergeTreeIndexConditionSet(
|
||||
if (useless)
|
||||
return;
|
||||
|
||||
/// Replace logical functions with bit functions.
|
||||
/// Working with UInt8: last bit = can be true, previous = can be false (Like dbms/src/Storages/MergeTree/BoolMask.h).
|
||||
traverseAST(expression_ast);
|
||||
|
||||
auto syntax_analyzer_result = SyntaxAnalyzer(context, {}).analyze(
|
||||
|
Loading…
Reference in New Issue
Block a user