mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Better [#CLICKHOUSE-2].
This commit is contained in:
parent
28d40e2c9a
commit
d36d7170ed
@ -350,16 +350,12 @@ public:
|
||||
Base::deserialize(buf);
|
||||
}
|
||||
|
||||
template <bool compute = compute_marginal_moments>
|
||||
void publish(IColumn & to, typename std::enable_if<compute>::type * = nullptr) const
|
||||
void publish(IColumn & to) const
|
||||
{
|
||||
static_cast<ColumnFloat64 &>(to).getData().push_back(Op::apply(co_moment, Base::left_m2, Base::right_m2, count));
|
||||
}
|
||||
|
||||
template <bool compute = compute_marginal_moments>
|
||||
void publish(IColumn & to, typename std::enable_if<!compute>::type * = nullptr) const
|
||||
{
|
||||
static_cast<ColumnFloat64 &>(to).getData().push_back(Op::apply(co_moment, count));
|
||||
if constexpr (compute_marginal_moments)
|
||||
static_cast<ColumnFloat64 &>(to).getData().push_back(Op::apply(co_moment, Base::left_m2, Base::right_m2, count));
|
||||
else
|
||||
static_cast<ColumnFloat64 &>(to).getData().push_back(Op::apply(co_moment, count));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -273,81 +273,63 @@ template <> struct AggregateFunctionUniqCombinedTraits<Float64>
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** The structure for the delegation work to add one element to the `uniq` aggregate functions.
|
||||
* Used for partial specialization to add strings.
|
||||
*/
|
||||
template <typename T, typename Data, typename Enable = void>
|
||||
struct OneAdder;
|
||||
|
||||
template <typename T, typename Data>
|
||||
struct OneAdder<T, Data, typename std::enable_if<
|
||||
std::is_same<Data, AggregateFunctionUniqUniquesHashSetData>::value ||
|
||||
std::is_same<Data, AggregateFunctionUniqHLL12Data<T>>::value>::type>
|
||||
struct OneAdder
|
||||
{
|
||||
template <typename T2 = T>
|
||||
static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num,
|
||||
typename std::enable_if<!std::is_same<T2, String>::value>::type * = nullptr)
|
||||
static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num)
|
||||
{
|
||||
const auto & value = static_cast<const ColumnVector<T2> &>(column).getData()[row_num];
|
||||
data.set.insert(AggregateFunctionUniqTraits<T2>::hash(value));
|
||||
}
|
||||
if constexpr (std::is_same<Data, AggregateFunctionUniqUniquesHashSetData>::value
|
||||
|| std::is_same<Data, AggregateFunctionUniqHLL12Data<T>>::value)
|
||||
{
|
||||
if constexpr (!std::is_same<T, String>::value)
|
||||
{
|
||||
const auto & value = static_cast<const ColumnVector<T> &>(column).getData()[row_num];
|
||||
data.set.insert(AggregateFunctionUniqTraits<T>::hash(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
StringRef value = column.getDataAt(row_num);
|
||||
data.set.insert(CityHash_v1_0_2::CityHash64(value.data, value.size));
|
||||
}
|
||||
}
|
||||
else if constexpr (std::is_same<Data, AggregateFunctionUniqCombinedRawData<T>>::value
|
||||
|| std::is_same<Data, AggregateFunctionUniqCombinedLinearCountingData<T>>::value
|
||||
|| std::is_same<Data, AggregateFunctionUniqCombinedBiasCorrectedData<T>>::value
|
||||
|| std::is_same<Data, AggregateFunctionUniqCombinedData<T>>::value)
|
||||
{
|
||||
if constexpr (!std::is_same<T, String>::value)
|
||||
{
|
||||
const auto & value = static_cast<const ColumnVector<T> &>(column).getData()[row_num];
|
||||
data.set.insert(AggregateFunctionUniqCombinedTraits<T>::hash(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
StringRef value = column.getDataAt(row_num);
|
||||
data.set.insert(CityHash_v1_0_2::CityHash64(value.data, value.size));
|
||||
}
|
||||
}
|
||||
else if constexpr (std::is_same<Data, AggregateFunctionUniqExactData<T>>::value)
|
||||
{
|
||||
if constexpr (!std::is_same<T, String>::value)
|
||||
{
|
||||
data.set.insert(static_cast<const ColumnVector<T> &>(column).getData()[row_num]);
|
||||
}
|
||||
else
|
||||
{
|
||||
StringRef value = column.getDataAt(row_num);
|
||||
|
||||
template <typename T2 = T>
|
||||
static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num,
|
||||
typename std::enable_if<std::is_same<T2, String>::value>::type * = nullptr)
|
||||
{
|
||||
StringRef value = column.getDataAt(row_num);
|
||||
data.set.insert(CityHash_v1_0_2::CityHash64(value.data, value.size));
|
||||
}
|
||||
};
|
||||
UInt128 key;
|
||||
SipHash hash;
|
||||
hash.update(value.data, value.size);
|
||||
hash.get128(key.low, key.high);
|
||||
|
||||
template <typename T, typename Data>
|
||||
struct OneAdder<T, Data, typename std::enable_if<
|
||||
std::is_same<Data, AggregateFunctionUniqCombinedRawData<T>>::value ||
|
||||
std::is_same<Data, AggregateFunctionUniqCombinedLinearCountingData<T>>::value ||
|
||||
std::is_same<Data, AggregateFunctionUniqCombinedBiasCorrectedData<T>>::value ||
|
||||
std::is_same<Data, AggregateFunctionUniqCombinedData<T>>::value>::type>
|
||||
{
|
||||
template <typename T2 = T>
|
||||
static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num,
|
||||
typename std::enable_if<!std::is_same<T2, String>::value>::type * = nullptr)
|
||||
{
|
||||
const auto & value = static_cast<const ColumnVector<T2> &>(column).getData()[row_num];
|
||||
data.set.insert(AggregateFunctionUniqCombinedTraits<T2>::hash(value));
|
||||
}
|
||||
|
||||
template <typename T2 = T>
|
||||
static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num,
|
||||
typename std::enable_if<std::is_same<T2, String>::value>::type * = nullptr)
|
||||
{
|
||||
StringRef value = column.getDataAt(row_num);
|
||||
data.set.insert(CityHash_v1_0_2::CityHash64(value.data, value.size));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Data>
|
||||
struct OneAdder<T, Data, typename std::enable_if<
|
||||
std::is_same<Data, AggregateFunctionUniqExactData<T>>::value>::type>
|
||||
{
|
||||
template <typename T2 = T>
|
||||
static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num,
|
||||
typename std::enable_if<!std::is_same<T2, String>::value>::type * = nullptr)
|
||||
{
|
||||
data.set.insert(static_cast<const ColumnVector<T2> &>(column).getData()[row_num]);
|
||||
}
|
||||
|
||||
template <typename T2 = T>
|
||||
static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num,
|
||||
typename std::enable_if<std::is_same<T2, String>::value>::type * = nullptr)
|
||||
{
|
||||
StringRef value = column.getDataAt(row_num);
|
||||
|
||||
UInt128 key;
|
||||
SipHash hash;
|
||||
hash.update(value.data, value.size);
|
||||
hash.get128(key.low, key.high);
|
||||
|
||||
data.set.insert(key);
|
||||
data.set.insert(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -237,17 +237,13 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
template <StreamUnionMode mode2 = mode>
|
||||
BlockExtraInfo doGetBlockExtraInfo(typename std::enable_if<mode2 == StreamUnionMode::ExtraInfo>::type * = nullptr) const
|
||||
BlockExtraInfo doGetBlockExtraInfo() const
|
||||
{
|
||||
return received_payload.extra_info;
|
||||
}
|
||||
|
||||
template <StreamUnionMode mode2 = mode>
|
||||
BlockExtraInfo doGetBlockExtraInfo(typename std::enable_if<mode2 == StreamUnionMode::Basic>::type * = nullptr) const
|
||||
{
|
||||
throw Exception("Method getBlockExtraInfo is not supported for mode StreamUnionMode::Basic",
|
||||
ErrorCodes::NOT_IMPLEMENTED);
|
||||
if constexpr (mode == StreamUnionMode::ExtraInfo)
|
||||
return received_payload.extra_info;
|
||||
else
|
||||
throw Exception("Method getBlockExtraInfo is not supported for mode StreamUnionMode::Basic",
|
||||
ErrorCodes::NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user