This is an automated email from the ASF dual-hosted git repository. lihaopeng pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 2b2051209dc [Refactor](exec) Remove the unless code in BE (#46122) 2b2051209dc is described below commit 2b2051209dc7bd445a13805f007b4b965b8f7a88 Author: HappenLee <happen...@selectdb.com> AuthorDate: Sun Dec 29 01:24:48 2024 +0800 [Refactor](exec) Remove the unless code in BE (#46122) Remove the unless code: ``` OldCount, TransformerToStringTwoArgument , be/src/util/type_traits.h ``` --- be/src/util/counts.h | 108 ---------------------------- be/src/util/type_traits.h | 40 ----------- be/src/vec/functions/date_time_transforms.h | 30 -------- 3 files changed, 178 deletions(-) diff --git a/be/src/util/counts.h b/be/src/util/counts.h index 968dc00e2ae..9f45eb4d426 100644 --- a/be/src/util/counts.h +++ b/be/src/util/counts.h @@ -30,114 +30,6 @@ namespace doris { -class OldCounts { -public: - OldCounts() = default; - - inline void merge(const OldCounts* other) { - if (other == nullptr || other->_counts.empty()) { - return; - } - - for (auto& cell : other->_counts) { - increment(cell.first, cell.second); - } - } - - void increment(int64_t key, uint32_t i) { - auto item = _counts.find(key); - if (item != _counts.end()) { - item->second += i; - } else { - _counts.emplace(std::make_pair(key, i)); - } - } - - uint32_t serialized_size() const { - return sizeof(uint32_t) + sizeof(int64_t) * _counts.size() + - sizeof(uint32_t) * _counts.size(); - } - - void serialize(uint8_t* writer) const { - uint32_t size = _counts.size(); - memcpy(writer, &size, sizeof(uint32_t)); - writer += sizeof(uint32_t); - for (auto& cell : _counts) { - memcpy(writer, &cell.first, sizeof(int64_t)); - writer += sizeof(int64_t); - memcpy(writer, &cell.second, sizeof(uint32_t)); - writer += sizeof(uint32_t); - } - } - - void unserialize(const uint8_t* type_reader) { - uint32_t size; - memcpy(&size, type_reader, sizeof(uint32_t)); - type_reader += sizeof(uint32_t); - for (uint32_t i = 0; i < size; ++i) { - int64_t key; - uint32_t count; - memcpy(&key, type_reader, sizeof(int64_t)); - type_reader += sizeof(int64_t); - memcpy(&count, type_reader, sizeof(uint32_t)); - type_reader += sizeof(uint32_t); - _counts.emplace(std::make_pair(key, count)); - } - } - - double get_percentile(std::vector<std::pair<int64_t, uint32_t>>& counts, - double position) const { - long lower = long(std::floor(position)); - long higher = long(std::ceil(position)); - - auto iter = counts.begin(); - for (; iter != counts.end() && iter->second < lower + 1; ++iter) - ; - - int64_t lower_key = iter->first; - if (higher == lower) { - return lower_key; - } - - if (iter->second < higher + 1) { - iter++; - } - - int64_t higher_key = iter->first; - if (lower_key == higher_key) { - return lower_key; - } - - return (higher - position) * lower_key + (position - lower) * higher_key; - } - - double terminate(double quantile) const { - if (_counts.empty()) { - // Although set null here, but the value is 0.0 and the call method just - // get val in aggregate_function_percentile_approx.h - return 0.0; - } - - std::vector<std::pair<int64_t, uint32_t>> elems(_counts.begin(), _counts.end()); - sort(elems.begin(), elems.end(), - [](const std::pair<int64_t, uint32_t> l, const std::pair<int64_t, uint32_t> r) { - return l.first < r.first; - }); - - long total = 0; - for (auto& cell : elems) { - total += cell.second; - cell.second = total; - } - - long max_position = total - 1; - double position = max_position * quantile; - return get_percentile(elems, position); - } - -private: - std::unordered_map<int64_t, uint32_t> _counts; -}; template <typename Ty> class Counts { public: diff --git a/be/src/util/type_traits.h b/be/src/util/type_traits.h deleted file mode 100644 index 9f41234d7e1..00000000000 --- a/be/src/util/type_traits.h +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#pragma once - -#include <complex> -#include <type_traits> - -namespace doris { - -template <class T, template <class...> class Primary> -struct is_specialization_of : std::false_type {}; - -template <template <class...> class Primary, class... Args> -struct is_specialization_of<Primary<Args...>, Primary> : std::true_type {}; - -template <class T, template <class...> class Primary> -constexpr bool is_specialization_of_v = is_specialization_of<T, Primary>::value; - -template <class T> -using is_complex = is_specialization_of<T, std::complex>; - -template <class T> -constexpr bool is_complex_v = is_specialization_of_v<T, std::complex>; - -} // namespace doris diff --git a/be/src/vec/functions/date_time_transforms.h b/be/src/vec/functions/date_time_transforms.h index c23fe147400..b65840445ca 100644 --- a/be/src/vec/functions/date_time_transforms.h +++ b/be/src/vec/functions/date_time_transforms.h @@ -24,7 +24,6 @@ #include "runtime/runtime_state.h" #include "udf/udf.h" #include "util/binary_cast.hpp" -#include "util/type_traits.h" #include "vec/columns/column_nullable.h" #include "vec/columns/column_string.h" #include "vec/columns/column_vector.h" @@ -340,35 +339,6 @@ struct TransformerToStringOneArgument { } }; -template <typename Transform> -struct TransformerToStringTwoArgument { - static void vector_constant(FunctionContext* context, - const PaddedPODArray<typename Transform::FromType>& ts, - const StringRef& format, ColumnString::Chars& res_data, - ColumnString::Offsets& res_offsets, - PaddedPODArray<UInt8>& null_map) { - auto len = ts.size(); - res_offsets.resize(len); - res_data.reserve(len * format.size + len); - null_map.resize_fill(len, false); - - size_t offset = 0; - for (int i = 0; i < len; ++i) { - const auto& t = ts[i]; - size_t new_offset; - bool is_null; - if constexpr (is_specialization_of_v<Transform, FromUnixTimeImpl>) { - std::tie(new_offset, is_null) = Transform::execute( - t, format, res_data, offset, context->state()->timezone_obj()); - } else { - std::tie(new_offset, is_null) = Transform::execute(t, format, res_data, offset); - } - res_offsets[i] = cast_set<UInt32>(new_offset); - null_map[i] = is_null; - } - } -}; - template <typename FromType, typename ToType, typename Transform> struct Transformer { static void vector(const PaddedPODArray<FromType>& vec_from, PaddedPODArray<ToType>& vec_to, --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org