mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 11:02:08 +00:00
Remove redundant template
This commit is contained in:
parent
11ba22b43f
commit
18b7e38994
@ -302,7 +302,7 @@ MutableColumnPtr ColumnVector<T>::cloneResized(size_t size) const
|
||||
template <typename T>
|
||||
UInt64 ColumnVector<T>::get64(size_t n [[maybe_unused]]) const
|
||||
{
|
||||
if constexpr (IsNumber<T>)
|
||||
if constexpr (is_arithmetic_v<T>)
|
||||
return ext::bit_cast<UInt64>(data[n]);
|
||||
else
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot get the value of {} as UInt64", TypeName<T>);
|
||||
@ -311,7 +311,7 @@ UInt64 ColumnVector<T>::get64(size_t n [[maybe_unused]]) const
|
||||
template <typename T>
|
||||
inline Float64 ColumnVector<T>::getFloat64(size_t n [[maybe_unused]]) const
|
||||
{
|
||||
if constexpr (IsNumber<T>)
|
||||
if constexpr (is_arithmetic_v<T>)
|
||||
return static_cast<Float64>(data[n]);
|
||||
else
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot get the value of {} as Float64", TypeName<T>);
|
||||
@ -320,7 +320,7 @@ inline Float64 ColumnVector<T>::getFloat64(size_t n [[maybe_unused]]) const
|
||||
template <typename T>
|
||||
Float32 ColumnVector<T>::getFloat32(size_t n [[maybe_unused]]) const
|
||||
{
|
||||
if constexpr (IsNumber<T>)
|
||||
if constexpr (is_arithmetic_v<T>)
|
||||
return static_cast<Float32>(data[n]);
|
||||
else
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot get the value of {} as Float32", TypeName<T>);
|
||||
|
@ -125,7 +125,7 @@ private:
|
||||
ColumnVector(std::initializer_list<T> il) : data{il} {}
|
||||
|
||||
public:
|
||||
bool isNumeric() const override { return IsNumber<T>; }
|
||||
bool isNumeric() const override { return is_arithmetic_v<T>; }
|
||||
|
||||
size_t size() const override
|
||||
{
|
||||
@ -252,7 +252,7 @@ public:
|
||||
/// Out of range conversion is permitted.
|
||||
UInt64 NO_SANITIZE_UNDEFINED getUInt(size_t n) const override
|
||||
{
|
||||
if constexpr (IsNumber<T>)
|
||||
if constexpr (is_arithmetic_v<T>)
|
||||
return UInt64(data[n]);
|
||||
else
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot get the value of {} as UInt", TypeName<T>);
|
||||
@ -261,7 +261,7 @@ public:
|
||||
/// Out of range conversion is permitted.
|
||||
Int64 NO_SANITIZE_UNDEFINED getInt(size_t n) const override
|
||||
{
|
||||
if constexpr (IsNumber<T>)
|
||||
if constexpr (is_arithmetic_v<T>)
|
||||
return Int64(data[n]);
|
||||
else
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot get the value of {} as Int", TypeName<T>);
|
||||
@ -269,7 +269,7 @@ public:
|
||||
|
||||
bool getBool(size_t n) const override
|
||||
{
|
||||
if constexpr (IsNumber<T>)
|
||||
if constexpr (is_arithmetic_v<T>)
|
||||
return bool(data[n]);
|
||||
else
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot get the value of {} as bool", TypeName<T>);
|
||||
|
@ -73,25 +73,6 @@ using Int256 = ::Int256;
|
||||
STRONG_TYPEDEF(UInt128, UUID)
|
||||
|
||||
|
||||
/** Note that for types not used in DB, IsNumber is false.
|
||||
*/
|
||||
template <typename T> constexpr bool IsNumber = false;
|
||||
|
||||
template <> inline constexpr bool IsNumber<UInt8> = true;
|
||||
template <> inline constexpr bool IsNumber<UInt16> = true;
|
||||
template <> inline constexpr bool IsNumber<UInt32> = true;
|
||||
template <> inline constexpr bool IsNumber<UInt64> = true;
|
||||
template <> inline constexpr bool IsNumber<UInt128> = true;
|
||||
template <> inline constexpr bool IsNumber<UInt256> = true;
|
||||
template <> inline constexpr bool IsNumber<Int8> = true;
|
||||
template <> inline constexpr bool IsNumber<Int16> = true;
|
||||
template <> inline constexpr bool IsNumber<Int32> = true;
|
||||
template <> inline constexpr bool IsNumber<Int64> = true;
|
||||
template <> inline constexpr bool IsNumber<Int128> = true;
|
||||
template <> inline constexpr bool IsNumber<Int256> = true;
|
||||
template <> inline constexpr bool IsNumber<Float32> = true;
|
||||
template <> inline constexpr bool IsNumber<Float64> = true;
|
||||
|
||||
template <typename T> constexpr const char * TypeName = "";
|
||||
|
||||
template <> inline constexpr const char * TypeName<UInt8> = "UInt8";
|
||||
|
@ -15,7 +15,7 @@ class ColumnVector;
|
||||
template <typename T>
|
||||
class DataTypeNumberBase : public IDataType
|
||||
{
|
||||
static_assert(IsNumber<T>);
|
||||
static_assert(is_arithmetic_v<T>);
|
||||
|
||||
public:
|
||||
static constexpr bool is_parametric = false;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/arithmeticOverflow.h>
|
||||
#include <common/extended_types.h>
|
||||
#include <Common/typeid_cast.h>
|
||||
#include <DataTypes/IDataType.h>
|
||||
#include <DataTypes/DataTypeDecimalBase.h>
|
||||
@ -150,7 +151,7 @@ tryConvertDecimals(const typename FromDataType::FieldType & value, UInt32 scale_
|
||||
}
|
||||
|
||||
template <typename FromDataType, typename ToDataType, typename ReturnType>
|
||||
inline std::enable_if_t<IsDataTypeDecimal<FromDataType> && IsNumber<typename ToDataType::FieldType>, ReturnType>
|
||||
inline std::enable_if_t<IsDataTypeDecimal<FromDataType> && is_arithmetic_v<typename ToDataType::FieldType>, ReturnType>
|
||||
convertFromDecimalImpl(const typename FromDataType::FieldType & value, UInt32 scale, typename ToDataType::FieldType& result)
|
||||
{
|
||||
using FromFieldType = typename FromDataType::FieldType;
|
||||
@ -160,7 +161,7 @@ convertFromDecimalImpl(const typename FromDataType::FieldType & value, UInt32 sc
|
||||
}
|
||||
|
||||
template <typename FromDataType, typename ToDataType>
|
||||
inline std::enable_if_t<IsDataTypeDecimal<FromDataType> && IsNumber<typename ToDataType::FieldType>, typename ToDataType::FieldType>
|
||||
inline std::enable_if_t<IsDataTypeDecimal<FromDataType> && is_arithmetic_v<typename ToDataType::FieldType>, typename ToDataType::FieldType>
|
||||
convertFromDecimal(const typename FromDataType::FieldType & value, UInt32 scale)
|
||||
{
|
||||
typename ToDataType::FieldType result;
|
||||
@ -171,14 +172,14 @@ convertFromDecimal(const typename FromDataType::FieldType & value, UInt32 scale)
|
||||
}
|
||||
|
||||
template <typename FromDataType, typename ToDataType>
|
||||
inline std::enable_if_t<IsDataTypeDecimal<FromDataType> && IsNumber<typename ToDataType::FieldType>, bool>
|
||||
inline std::enable_if_t<IsDataTypeDecimal<FromDataType> && is_arithmetic_v<typename ToDataType::FieldType>, bool>
|
||||
tryConvertFromDecimal(const typename FromDataType::FieldType & value, UInt32 scale, typename ToDataType::FieldType& result)
|
||||
{
|
||||
return convertFromDecimalImpl<FromDataType, ToDataType, bool>(value, scale, result);
|
||||
}
|
||||
|
||||
template <typename FromDataType, typename ToDataType, typename ReturnType>
|
||||
inline std::enable_if_t<IsNumber<typename FromDataType::FieldType> && IsDataTypeDecimal<ToDataType>, ReturnType>
|
||||
inline std::enable_if_t<is_arithmetic_v<typename FromDataType::FieldType> && IsDataTypeDecimal<ToDataType>, ReturnType>
|
||||
convertToDecimalImpl(const typename FromDataType::FieldType & value, UInt32 scale, typename ToDataType::FieldType& result)
|
||||
{
|
||||
using FromFieldType = typename FromDataType::FieldType;
|
||||
@ -225,7 +226,7 @@ convertToDecimalImpl(const typename FromDataType::FieldType & value, UInt32 scal
|
||||
}
|
||||
|
||||
template <typename FromDataType, typename ToDataType>
|
||||
inline std::enable_if_t<IsNumber<typename FromDataType::FieldType> && IsDataTypeDecimal<ToDataType>, typename ToDataType::FieldType>
|
||||
inline std::enable_if_t<is_arithmetic_v<typename FromDataType::FieldType> && IsDataTypeDecimal<ToDataType>, typename ToDataType::FieldType>
|
||||
convertToDecimal(const typename FromDataType::FieldType & value, UInt32 scale)
|
||||
{
|
||||
typename ToDataType::FieldType result;
|
||||
@ -234,7 +235,7 @@ convertToDecimal(const typename FromDataType::FieldType & value, UInt32 scale)
|
||||
}
|
||||
|
||||
template <typename FromDataType, typename ToDataType>
|
||||
inline std::enable_if_t<IsNumber<typename FromDataType::FieldType> && IsDataTypeDecimal<ToDataType>, bool>
|
||||
inline std::enable_if_t<is_arithmetic_v<typename FromDataType::FieldType> && IsDataTypeDecimal<ToDataType>, bool>
|
||||
tryConvertToDecimal(const typename FromDataType::FieldType & value, UInt32 scale, typename ToDataType::FieldType& result)
|
||||
{
|
||||
return convertToDecimalImpl<FromDataType, ToDataType, bool>(value, scale, result);
|
||||
|
@ -9,7 +9,7 @@ namespace DB
|
||||
template <typename T>
|
||||
class SerializationNumber : public SimpleTextSerialization
|
||||
{
|
||||
static_assert(IsNumber<T>);
|
||||
static_assert(is_arithmetic_v<T>);
|
||||
|
||||
public:
|
||||
using FieldType = T;
|
||||
|
@ -252,7 +252,7 @@ public:
|
||||
auto scale = getDecimalScale(*dictionary_attribute.nested_type);
|
||||
return ColumnType::create(size, scale);
|
||||
}
|
||||
else if constexpr (IsNumber<DictionaryAttributeType>)
|
||||
else if constexpr (is_arithmetic_v<DictionaryAttributeType>)
|
||||
{
|
||||
return ColumnType::create(size);
|
||||
}
|
||||
|
@ -505,7 +505,7 @@ class Dispatcher
|
||||
public:
|
||||
static ColumnPtr apply(const IColumn * column, Scale scale_arg)
|
||||
{
|
||||
if constexpr (IsNumber<T>)
|
||||
if constexpr (is_arithmetic_v<T>)
|
||||
return apply(checkAndGetColumn<ColumnVector<T>>(column), scale_arg);
|
||||
else if constexpr (IsDecimalNumber<T>)
|
||||
return apply(checkAndGetColumn<ColumnDecimal<T>>(column), scale_arg);
|
||||
|
Loading…
Reference in New Issue
Block a user