From 21fe1038310409700ca60950d2ea318993269a0d Mon Sep 17 00:00:00 2001 From: chertus Date: Tue, 14 Aug 2018 22:16:56 +0300 Subject: [PATCH] fix clang build --- dbms/src/Common/UInt128.h | 2 +- dbms/src/Core/Types.h | 34 ++++++------ dbms/src/DataTypes/DataTypeNumberBase.h | 2 +- dbms/src/DataTypes/DataTypesDecimal.h | 2 +- dbms/src/DataTypes/IDataType.h | 2 +- dbms/src/Functions/FunctionHelpers.h | 70 ++++++++++++------------ dbms/src/Functions/FunctionsComparison.h | 16 +++++- dbms/src/IO/WriteIntText.h | 4 +- 8 files changed, 71 insertions(+), 61 deletions(-) diff --git a/dbms/src/Common/UInt128.h b/dbms/src/Common/UInt128.h index 87623cd7173..b27e6b068e2 100644 --- a/dbms/src/Common/UInt128.h +++ b/dbms/src/Common/UInt128.h @@ -65,7 +65,7 @@ template bool inline operator< (T a, const UInt128 b) { return UIn template <> constexpr bool IsNumber = true; template <> struct TypeName { static const char * get() { return "UInt128"; } }; -template <> struct TypeNumber { static constexpr const size_t value = 5; }; +template <> struct TypeId { static constexpr const size_t value = 5; }; struct UInt128Hash { diff --git a/dbms/src/Core/Types.h b/dbms/src/Core/Types.h index 672300d3628..178d3ab1ca1 100644 --- a/dbms/src/Core/Types.h +++ b/dbms/src/Core/Types.h @@ -57,21 +57,21 @@ template <> struct TypeName { static const char * get() { return "Float template <> struct TypeName { static const char * get() { return "Float64"; } }; template <> struct TypeName { static const char * get() { return "String"; } }; -template struct TypeNumber; +template struct TypeId; /// 0 reserved for types without number -template <> struct TypeNumber { static constexpr const size_t value = 1; }; -template <> struct TypeNumber { static constexpr const size_t value = 2; }; -template <> struct TypeNumber { static constexpr const size_t value = 3; }; -template <> struct TypeNumber { static constexpr const size_t value = 4; }; -/// 5 reserved for TypeNumber -template <> struct TypeNumber { static constexpr const size_t value = 7; }; -template <> struct TypeNumber { static constexpr const size_t value = 8; }; -template <> struct TypeNumber { static constexpr const size_t value = 9; }; -template <> struct TypeNumber { static constexpr const size_t value = 10; }; -template <> struct TypeNumber { static constexpr const size_t value = 11; }; -template <> struct TypeNumber { static constexpr const size_t value = 12; }; -/// 13 reserved for TypeNumber +template <> struct TypeId { static constexpr const size_t value = 1; }; +template <> struct TypeId { static constexpr const size_t value = 2; }; +template <> struct TypeId { static constexpr const size_t value = 3; }; +template <> struct TypeId { static constexpr const size_t value = 4; }; +/// 5 reserved for TypeId +template <> struct TypeId { static constexpr const size_t value = 7; }; +template <> struct TypeId { static constexpr const size_t value = 8; }; +template <> struct TypeId { static constexpr const size_t value = 9; }; +template <> struct TypeId { static constexpr const size_t value = 10; }; +template <> struct TypeId { static constexpr const size_t value = 11; }; +template <> struct TypeId { static constexpr const size_t value = 12; }; +/// 13 reserved for TypeId /// Not a data type in database, defined just for convenience. using Strings = std::vector; @@ -85,7 +85,7 @@ namespace DB using Int128 = __int128; template <> constexpr bool IsNumber = true; template <> struct TypeName { static const char * get() { return "Int128"; } }; -template <> struct TypeNumber { static constexpr const size_t value = 13; }; +template <> struct TypeId { static constexpr const size_t value = 13; }; } @@ -161,9 +161,9 @@ namespace DB template <> struct TypeName { static const char * get() { return "Dec64"; } }; template <> struct TypeName { static const char * get() { return "Dec128"; } }; - template <> struct TypeNumber { static constexpr const size_t value = 16; }; - template <> struct TypeNumber { static constexpr const size_t value = 17; }; - template <> struct TypeNumber { static constexpr const size_t value = 18; }; + template <> struct TypeId { static constexpr const size_t value = 16; }; + template <> struct TypeId { static constexpr const size_t value = 17; }; + template <> struct TypeId { static constexpr const size_t value = 18; }; template inline constexpr bool decTrait() { return false; } diff --git a/dbms/src/DataTypes/DataTypeNumberBase.h b/dbms/src/DataTypes/DataTypeNumberBase.h index 71106946258..ca365bfaa78 100644 --- a/dbms/src/DataTypes/DataTypeNumberBase.h +++ b/dbms/src/DataTypes/DataTypeNumberBase.h @@ -16,7 +16,7 @@ public: using FieldType = T; const char * getFamilyName() const override { return TypeName::get(); } - size_t getTypeNumber() const override { return TypeNumber::value; } + size_t getTypeId() const override { return TypeId::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; diff --git a/dbms/src/DataTypes/DataTypesDecimal.h b/dbms/src/DataTypes/DataTypesDecimal.h index e38e755f05a..57987fecc63 100644 --- a/dbms/src/DataTypes/DataTypesDecimal.h +++ b/dbms/src/DataTypes/DataTypesDecimal.h @@ -99,7 +99,7 @@ public: const char * getFamilyName() const override { return "Decimal"; } std::string getName() const override; - size_t getTypeNumber() const override { return TypeNumber::value; } + size_t getTypeId() const override { return TypeId::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; diff --git a/dbms/src/DataTypes/IDataType.h b/dbms/src/DataTypes/IDataType.h index b303c1454fa..f0b2f267077 100644 --- a/dbms/src/DataTypes/IDataType.h +++ b/dbms/src/DataTypes/IDataType.h @@ -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. * diff --git a/dbms/src/Functions/FunctionHelpers.h b/dbms/src/Functions/FunctionHelpers.h index 5dbfd6a5054..a4c7765c05f 100644 --- a/dbms/src/Functions/FunctionHelpers.h +++ b/dbms/src/Functions/FunctionHelpers.h @@ -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> typename Apply, - template typename Op, typename... Args> -void callByTypeAndNumber(UInt8 number, bool & done, Args &... args) +template +bool callByTypeAndNumber(UInt8 number, F && f) { - done = true; switch (number) { - case TypeNumber::value: Apply(args...); break; - case TypeNumber::value: Apply(args...); break; - case TypeNumber::value: Apply(args...); break; - case TypeNumber::value: Apply(args...); break; - //case TypeNumber::value: Apply(args...); break; + case TypeId::value: f(T(), UInt8()); break; + case TypeId::value: f(T(), UInt16()); break; + case TypeId::value: f(T(), UInt32()); break; + case TypeId::value: f(T(), UInt64()); break; + //case TypeId::value: f(T(), UInt128()); break; - case TypeNumber::value: Apply(args...); break; - case TypeNumber::value: Apply(args...); break; - case TypeNumber::value: Apply(args...); break; - case TypeNumber::value: Apply(args...); break; - case TypeNumber::value: Apply(args...); break; + case TypeId::value: f(T(), Int8()); break; + case TypeId::value: f(T(), Int16()); break; + case TypeId::value: f(T(), Int32()); break; + case TypeId::value: f(T(), Int64()); break; + case TypeId::value: f(T(), Int128()); break; - case TypeNumber::value: Apply(args...); break; - case TypeNumber::value: Apply(args...); break; - case TypeNumber::value: Apply(args...); break; + case TypeId::value: f(T(), Dec32()); break; + case TypeId::value: f(T(), Dec64()); break; + case TypeId::value: f(T(), Dec128()); break; default: - done = false; + return false; } + + return true; } /// Unroll template using TypeNumber -template