mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 13:42:02 +00:00
a1b0dede07
* made index parser * added index parsing * some fixes * added index interface and factory * fixed compilation * ptrs * added indexParts * indextypes * index condition * IndexCondition * added indexes in selectexecutor * fix * changed comment * fix * added granularity * comments * fix * fix * added writing indexes * removed indexpart class * fix * added setSkipIndexes * add rw for MergeTreeIndexes * fixes * upd error * fix * fix * reading * test index * fixed nullptr error * fixed * fix * unique names * asts -> exprlist * minmax index * fix * fixed select * fixed merging * fixed mutation * working minmax * removed test index * fixed style * added indexes to checkDataPart * added tests for minmax index * fixed constructor * fix style * fixed includes * fixed setSkipIndexes * added indexes meta to zookeeper * added parsing * removed throw * alter cmds parse * fix * added alter * fix * alters fix * fix alters * fix "after" * fixed alter * alter fix + test * fixes * upd setSkipIndexes * fixed alter bug with drop all indices * fix metadata editing * new test and repl fix * rm test files * fixed repl alter * fix * fix * indices * MTReadStream * upd test for bug * fix * added useful parsers and ast classes * fix * fix comments * replaced columns * fix * fixed parsing * fixed printing * fix err * basic IndicesDescription * go to IndicesDescr * moved indices * go to indicesDescr * fix test minmax_index* * fixed MT alter * fixed bug with replMT indices storing in zk * rename * refactoring * docs ru * docs ru * docs en * refactor * rename tests * fix docs * refactoring * fix * fix * fix * fixed style * unique idx * unique * fix * better minmax calculation * upd * added getBlock * unique_condition * added termForAST * unique * fixed not * uniqueCondition::mayBeTrueOnGranule * fix * fixed bug with double column * is always true * fix * key set * spaces * test * tests * fix * unique * fix * fix * fixed bug with duplicate column * removed unused data * fix * fixes * __bitSwapLastTwo * fix
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
#include <Functions/FunctionFactory.h>
|
|
#include <Functions/FunctionUnaryArithmetic.h>
|
|
#include <DataTypes/NumberTraits.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
template <typename A>
|
|
struct BitSwapLastTwoImpl
|
|
{
|
|
using ResultType = UInt8;
|
|
|
|
static inline ResultType 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;
|
|
|
|
static inline llvm::Value * compile(llvm::IRBuilder<> & b, llvm::Value * arg, bool)
|
|
{
|
|
if (!arg->getType()->isIntegerTy())
|
|
throw Exception("__bitSwapLastTwo expected an integral type", ErrorCodes::LOGICAL_ERROR);
|
|
return b.CreateOr(
|
|
b.CreateShl(b.CreateAnd(arg, 1), 1),
|
|
b.CreateAnd(b.CreateLShr(arg, 1), 1)
|
|
);
|
|
}
|
|
#endif
|
|
};
|
|
|
|
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 &)
|
|
{
|
|
return {};
|
|
}
|
|
};
|
|
|
|
void registerFunctionBitSwapLastTwo(FunctionFactory & factory)
|
|
{
|
|
factory.registerFunction<FunctionBitSwapLastTwo>();
|
|
}
|
|
|
|
}
|