mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
fix clang build
This commit is contained in:
parent
15cdd7b2bd
commit
21fe103831
@ -65,7 +65,7 @@ template <typename T> bool inline operator< (T a, const UInt128 b) { return UIn
|
||||
|
||||
template <> constexpr bool IsNumber<UInt128> = true;
|
||||
template <> struct TypeName<UInt128> { static const char * get() { return "UInt128"; } };
|
||||
template <> struct TypeNumber<UInt128> { static constexpr const size_t value = 5; };
|
||||
template <> struct TypeId<UInt128> { static constexpr const size_t value = 5; };
|
||||
|
||||
struct UInt128Hash
|
||||
{
|
||||
|
@ -57,21 +57,21 @@ template <> struct TypeName<Float32> { static const char * get() { return "Float
|
||||
template <> struct TypeName<Float64> { static const char * get() { return "Float64"; } };
|
||||
template <> struct TypeName<String> { static const char * get() { return "String"; } };
|
||||
|
||||
template <typename T> struct TypeNumber;
|
||||
template <typename T> struct TypeId;
|
||||
|
||||
/// 0 reserved for types without number
|
||||
template <> struct TypeNumber<UInt8> { static constexpr const size_t value = 1; };
|
||||
template <> struct TypeNumber<UInt16> { static constexpr const size_t value = 2; };
|
||||
template <> struct TypeNumber<UInt32> { static constexpr const size_t value = 3; };
|
||||
template <> struct TypeNumber<UInt64> { static constexpr const size_t value = 4; };
|
||||
/// 5 reserved for TypeNumber<UInt128>
|
||||
template <> struct TypeNumber<Float32> { static constexpr const size_t value = 7; };
|
||||
template <> struct TypeNumber<Float64> { static constexpr const size_t value = 8; };
|
||||
template <> struct TypeNumber<Int8> { static constexpr const size_t value = 9; };
|
||||
template <> struct TypeNumber<Int16> { static constexpr const size_t value = 10; };
|
||||
template <> struct TypeNumber<Int32> { static constexpr const size_t value = 11; };
|
||||
template <> struct TypeNumber<Int64> { static constexpr const size_t value = 12; };
|
||||
/// 13 reserved for TypeNumber<Int128>
|
||||
template <> struct TypeId<UInt8> { static constexpr const size_t value = 1; };
|
||||
template <> struct TypeId<UInt16> { static constexpr const size_t value = 2; };
|
||||
template <> struct TypeId<UInt32> { static constexpr const size_t value = 3; };
|
||||
template <> struct TypeId<UInt64> { static constexpr const size_t value = 4; };
|
||||
/// 5 reserved for TypeId<UInt128>
|
||||
template <> struct TypeId<Float32> { static constexpr const size_t value = 7; };
|
||||
template <> struct TypeId<Float64> { static constexpr const size_t value = 8; };
|
||||
template <> struct TypeId<Int8> { static constexpr const size_t value = 9; };
|
||||
template <> struct TypeId<Int16> { static constexpr const size_t value = 10; };
|
||||
template <> struct TypeId<Int32> { static constexpr const size_t value = 11; };
|
||||
template <> struct TypeId<Int64> { static constexpr const size_t value = 12; };
|
||||
/// 13 reserved for TypeId<Int128>
|
||||
|
||||
/// Not a data type in database, defined just for convenience.
|
||||
using Strings = std::vector<String>;
|
||||
@ -85,7 +85,7 @@ namespace DB
|
||||
using Int128 = __int128;
|
||||
template <> constexpr bool IsNumber<Int128> = true;
|
||||
template <> struct TypeName<Int128> { static const char * get() { return "Int128"; } };
|
||||
template <> struct TypeNumber<Int128> { static constexpr const size_t value = 13; };
|
||||
template <> struct TypeId<Int128> { static constexpr const size_t value = 13; };
|
||||
|
||||
}
|
||||
|
||||
@ -161,9 +161,9 @@ namespace DB
|
||||
template <> struct TypeName<Dec64> { static const char * get() { return "Dec64"; } };
|
||||
template <> struct TypeName<Dec128> { static const char * get() { return "Dec128"; } };
|
||||
|
||||
template <> struct TypeNumber<Dec32> { static constexpr const size_t value = 16; };
|
||||
template <> struct TypeNumber<Dec64> { static constexpr const size_t value = 17; };
|
||||
template <> struct TypeNumber<Dec128> { static constexpr const size_t value = 18; };
|
||||
template <> struct TypeId<Dec32> { static constexpr const size_t value = 16; };
|
||||
template <> struct TypeId<Dec64> { static constexpr const size_t value = 17; };
|
||||
template <> struct TypeId<Dec128> { static constexpr const size_t value = 18; };
|
||||
|
||||
template <typename T>
|
||||
inline constexpr bool decTrait() { return false; }
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
using FieldType = T;
|
||||
|
||||
const char * getFamilyName() const override { return TypeName<T>::get(); }
|
||||
size_t getTypeNumber() const override { return TypeNumber<T>::value; }
|
||||
size_t getTypeId() const override { return TypeId<T>::value; }
|
||||
|
||||
void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
|
||||
void serializeTextEscaped(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
|
||||
const char * getFamilyName() const override { return "Decimal"; }
|
||||
std::string getName() const override;
|
||||
size_t getTypeNumber() const override { return TypeNumber<T>::value; }
|
||||
size_t getTypeId() const override { return TypeId<T>::value; }
|
||||
|
||||
void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
|
||||
void deserializeText(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
virtual const char * getFamilyName() const = 0;
|
||||
|
||||
/// Unique type number or zero
|
||||
virtual size_t getTypeNumber() const { return 0; }
|
||||
virtual size_t getTypeId() const { return 0; }
|
||||
|
||||
/** Binary serialization for range of values in column - for writing to disk/network, etc.
|
||||
*
|
||||
|
@ -171,62 +171,60 @@ Block createBlockWithNestedColumns(const Block & block, const ColumnNumbers & ar
|
||||
/// Similar function as above. Additionally transform the result type if needed.
|
||||
Block createBlockWithNestedColumns(const Block & block, const ColumnNumbers & args, size_t result);
|
||||
|
||||
template <typename T, template <typename, typename, template <typename, typename> typename> typename Apply,
|
||||
template <typename, typename> typename Op, typename... Args>
|
||||
void callByTypeAndNumber(UInt8 number, bool & done, Args &... args)
|
||||
template <typename T, typename F>
|
||||
bool callByTypeAndNumber(UInt8 number, F && f)
|
||||
{
|
||||
done = true;
|
||||
switch (number)
|
||||
{
|
||||
case TypeNumber<UInt8>::value: Apply<T, UInt8, Op>(args...); break;
|
||||
case TypeNumber<UInt16>::value: Apply<T, UInt16, Op>(args...); break;
|
||||
case TypeNumber<UInt32>::value: Apply<T, UInt32, Op>(args...); break;
|
||||
case TypeNumber<UInt64>::value: Apply<T, UInt64, Op>(args...); break;
|
||||
//case TypeNumber<UInt128>::value: Apply<T, UInt128, Op>(args...); break;
|
||||
case TypeId<UInt8>::value: f(T(), UInt8()); break;
|
||||
case TypeId<UInt16>::value: f(T(), UInt16()); break;
|
||||
case TypeId<UInt32>::value: f(T(), UInt32()); break;
|
||||
case TypeId<UInt64>::value: f(T(), UInt64()); break;
|
||||
//case TypeId<UInt128>::value: f(T(), UInt128()); break;
|
||||
|
||||
case TypeNumber<Int8>::value: Apply<T, Int8, Op>(args...); break;
|
||||
case TypeNumber<Int16>::value: Apply<T, Int16, Op>(args...); break;
|
||||
case TypeNumber<Int32>::value: Apply<T, Int32, Op>(args...); break;
|
||||
case TypeNumber<Int64>::value: Apply<T, Int64, Op>(args...); break;
|
||||
case TypeNumber<Int128>::value: Apply<T, Int128, Op>(args...); break;
|
||||
case TypeId<Int8>::value: f(T(), Int8()); break;
|
||||
case TypeId<Int16>::value: f(T(), Int16()); break;
|
||||
case TypeId<Int32>::value: f(T(), Int32()); break;
|
||||
case TypeId<Int64>::value: f(T(), Int64()); break;
|
||||
case TypeId<Int128>::value: f(T(), Int128()); break;
|
||||
|
||||
case TypeNumber<Dec32>::value: Apply<T, Dec32, Op>(args...); break;
|
||||
case TypeNumber<Dec64>::value: Apply<T, Dec64, Op>(args...); break;
|
||||
case TypeNumber<Dec128>::value: Apply<T, Dec128, Op>(args...); break;
|
||||
case TypeId<Dec32>::value: f(T(), Dec32()); break;
|
||||
case TypeId<Dec64>::value: f(T(), Dec64()); break;
|
||||
case TypeId<Dec128>::value: f(T(), Dec128()); break;
|
||||
default:
|
||||
done = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Unroll template using TypeNumber<T>
|
||||
template <template <typename, typename, template <typename, typename> typename> typename Apply,
|
||||
template <typename, typename> typename Op, typename... Args>
|
||||
inline bool callByNumbers(UInt8 type_num1, UInt8 type_num2, Args &... args)
|
||||
template <typename F>
|
||||
inline bool callByNumbers(UInt8 type_num1, UInt8 type_num2, F && f)
|
||||
{
|
||||
bool done = false;
|
||||
switch (type_num1)
|
||||
{
|
||||
case TypeNumber<UInt8>::value: callByTypeAndNumber<UInt8, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeNumber<UInt16>::value: callByTypeAndNumber<UInt16, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeNumber<UInt32>::value: callByTypeAndNumber<UInt32, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeNumber<UInt64>::value: callByTypeAndNumber<UInt64, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
//case TypeNumber<UInt128>::value: callByTypeAndNumber<UInt128, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeId<UInt8>::value: return callByTypeAndNumber<UInt8>(type_num2, std::forward<F>(f));
|
||||
case TypeId<UInt16>::value: return callByTypeAndNumber<UInt16>(type_num2, std::forward<F>(f));
|
||||
case TypeId<UInt32>::value: return callByTypeAndNumber<UInt32>(type_num2, std::forward<F>(f));
|
||||
case TypeId<UInt64>::value: return callByTypeAndNumber<UInt64>(type_num2, std::forward<F>(f));
|
||||
//case TypeId<UInt128>::value: return callByTypeAndNumber<UInt128>(type_num2, std::forward<F>(f));
|
||||
|
||||
case TypeNumber<Int8>::value: callByTypeAndNumber<Int8, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeNumber<Int16>::value: callByTypeAndNumber<Int16, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeNumber<Int32>::value: callByTypeAndNumber<Int32, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeNumber<Int64>::value: callByTypeAndNumber<Int64, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeNumber<Int128>::value: callByTypeAndNumber<Int128, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeId<Int8>::value: return callByTypeAndNumber<Int8>(type_num2, std::forward<F>(f));
|
||||
case TypeId<Int16>::value: return callByTypeAndNumber<Int16>(type_num2, std::forward<F>(f));
|
||||
case TypeId<Int32>::value: return callByTypeAndNumber<Int32>(type_num2, std::forward<F>(f));
|
||||
case TypeId<Int64>::value: return callByTypeAndNumber<Int64>(type_num2, std::forward<F>(f));
|
||||
case TypeId<Int128>::value: return callByTypeAndNumber<Int128>(type_num2, std::forward<F>(f));
|
||||
|
||||
case TypeNumber<Dec32>::value: callByTypeAndNumber<Dec32, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeNumber<Dec64>::value: callByTypeAndNumber<Dec64, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeNumber<Dec128>::value: callByTypeAndNumber<Dec128, Apply, Op, Args...>(type_num2, done, args...); break;
|
||||
case TypeId<Dec32>::value: return callByTypeAndNumber<Dec32>(type_num2, std::forward<F>(f));
|
||||
case TypeId<Dec64>::value: return callByTypeAndNumber<Dec64>(type_num2, std::forward<F>(f));
|
||||
case TypeId<Dec128>::value: return callByTypeAndNumber<Dec128>(type_num2, std::forward<F>(f));
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
return done;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -216,6 +216,8 @@ template <typename T, typename U>
|
||||
struct DecCompareInt
|
||||
{
|
||||
using Type = typename ConstructDecInt<(!decTrait<U>() || sizeof(T) > sizeof(U)) ? sizeof(T) : sizeof(U)>::Type;
|
||||
using TypeA = Type;
|
||||
using TypeB = Type;
|
||||
};
|
||||
|
||||
///
|
||||
@ -1019,10 +1021,18 @@ private:
|
||||
|
||||
void executeDecimal(Block & block, size_t result, const ColumnWithTypeAndName & col_left, const ColumnWithTypeAndName & col_right)
|
||||
{
|
||||
size_t left_number = col_left.type->getTypeNumber();
|
||||
size_t right_number = col_right.type->getTypeNumber();
|
||||
size_t left_number = col_left.type->getTypeId();
|
||||
size_t right_number = col_right.type->getTypeId();
|
||||
|
||||
if (!callByNumbers<DecimalComparison, Op>(left_number, right_number, block, result, col_left, col_right))
|
||||
auto call = [&](const auto & left, const auto & right)
|
||||
{
|
||||
using LeftDataType = std::decay_t<decltype(left)>;
|
||||
using RightDataType = std::decay_t<decltype(right)>;
|
||||
|
||||
DecimalComparison<LeftDataType, RightDataType, Op>(block, result, col_left, col_right);
|
||||
};
|
||||
|
||||
if (!callByNumbers(left_number, right_number, call))
|
||||
throw Exception("Wrong call for " + getName() + " with " + col_left.type->getName() + " and " + col_right.type->getName(),
|
||||
ErrorCodes::LOGICAL_ERROR);
|
||||
}
|
||||
|
@ -188,7 +188,9 @@ namespace detail
|
||||
#if 1
|
||||
inline void writeSIntText(__int128 x, WriteBuffer & buf)
|
||||
{
|
||||
if (unlikely(-x < 0))
|
||||
static const __int128 max_int128 = __int128(0x8000000000000000ll) << 64;
|
||||
|
||||
if (unlikely(x == max_int128))
|
||||
{
|
||||
buf.write("-170141183460469231731687303715884105728", 40);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user