From 42566cde6f4a67d3106d1e852b4361d43dffa061 Mon Sep 17 00:00:00 2001 From: Mryange Date: Thu, 26 Dec 2024 22:39:02 +0800 Subject: [PATCH 1/2] upd --- be/src/runtime/types.cpp | 6 ++++-- be/src/udf/udf.cpp | 4 +++- be/src/util/cidr.cpp | 4 +++- be/src/util/runtime_profile.cpp | 14 ++++++++------ be/src/util/runtime_profile.h | 5 ++++- be/src/vec/common/string_ref.cpp | 4 +++- be/src/vec/common/string_ref.h | 4 ++-- be/src/vec/common/string_searcher.h | 4 +++- be/src/vec/functions/function.cpp | 6 ++++-- be/src/vec/functions/function_helpers.cpp | 4 +++- be/src/vec/functions/function_tokenize.cpp | 5 ++++- be/src/vec/functions/like.cpp | 15 +++++++++------ be/src/vec/functions/modulo.cpp | 20 ++++++++++++-------- be/src/vec/functions/url/functions_url.h | 4 +++- 14 files changed, 65 insertions(+), 34 deletions(-) diff --git a/be/src/runtime/types.cpp b/be/src/runtime/types.cpp index 7b7154fb38a438..137c6fba6edaea 100644 --- a/be/src/runtime/types.cpp +++ b/be/src/runtime/types.cpp @@ -31,6 +31,7 @@ #include "runtime/primitive_type.h" namespace doris { +#include "common/compile_check_begin.h" TypeDescriptor::TypeDescriptor(const std::vector& types, int* idx) : len(-1), precision(-1), scale(-1) { @@ -262,8 +263,8 @@ TypeDescriptor::TypeDescriptor(const google::protobuf::RepeatedPtrFieldvalue() - total_child_time; // Counters have some margin, set to 0 if it was negative. local_time = std::max(0L, local_time); - _local_time_percent = static_cast(local_time) / total; + _local_time_percent = static_cast(local_time) / static_cast(total); _local_time_percent = std::min(1.0, _local_time_percent) * 100; // Recurse on children @@ -574,7 +575,7 @@ void RuntimeProfile::to_thrift(TRuntimeProfileTree* tree) { } void RuntimeProfile::to_thrift(std::vector* nodes) { - int index = nodes->size(); + size_t index = nodes->size(); nodes->push_back(TRuntimeProfileNode()); TRuntimeProfileNode& node = (*nodes)[index]; node.name = _name; @@ -605,11 +606,11 @@ void RuntimeProfile::to_thrift(std::vector* nodes) { std::lock_guard l(_children_lock); children = _children; } - node.num_children = children.size(); + node.num_children = (int)children.size(); nodes->reserve(nodes->size() + children.size()); - for (int i = 0; i < children.size(); ++i) { - int child_idx = nodes->size(); + for (size_t i = 0; i < children.size(); ++i) { + size_t child_idx = nodes->size(); children[i].first->to_thrift(nodes); // fix up indentation flag (*nodes)[child_idx].indent = children[i].second; @@ -626,7 +627,7 @@ int64_t RuntimeProfile::units_per_second(const RuntimeProfile::Counter* total_co } double secs = static_cast(timer->value()) / 1000.0 / 1000.0 / 1000.0; - return int64_t(total_counter->value() / secs); + return int64_t((double)total_counter->value() / secs); } int64_t RuntimeProfile::counter_sum(const std::vector* counters) { @@ -709,4 +710,5 @@ void RuntimeProfile::print_child_counters(const std::string& prefix, } } +#include "common/compile_check_end.h" } // namespace doris diff --git a/be/src/util/runtime_profile.h b/be/src/util/runtime_profile.h index 7130acbd2f9427..77f169ac578332 100644 --- a/be/src/util/runtime_profile.h +++ b/be/src/util/runtime_profile.h @@ -37,6 +37,7 @@ #include #include +#include "common/cast_set.h" #include "common/compiler_util.h" // IWYU pragma: keep #include "util/binary_cast.hpp" #include "util/container_util.hpp" @@ -44,6 +45,7 @@ #include "util/stopwatch.hpp" namespace doris { +#include "common/compile_check_begin.h" class TRuntimeProfileNode; class TRuntimeProfileTree; @@ -448,7 +450,7 @@ class RuntimeProfile { void get_all_children(std::vector* children); // Returns the number of counters in this profile - int num_counters() const { return _counter_map.size(); } + int num_counters() const { return cast_set(_counter_map.size()); } // Returns name of this profile const std::string& name() const { return _name; } @@ -725,4 +727,5 @@ class ScopedRawTimer { C* _counter = nullptr; }; +#include "common/compile_check_end.h" } // namespace doris diff --git a/be/src/vec/common/string_ref.cpp b/be/src/vec/common/string_ref.cpp index 413c0338c1001e..dc200704f90f46 100644 --- a/be/src/vec/common/string_ref.cpp +++ b/be/src/vec/common/string_ref.cpp @@ -23,6 +23,7 @@ #include "common/compiler_util.h" // IWYU pragma: keep namespace doris { +#include "common/compile_check_begin.h" StringRef StringRef::trim() const { // Remove leading and trailing spaces. @@ -32,7 +33,7 @@ StringRef StringRef::trim() const { ++begin; } - int32_t end = size - 1; + int64_t end = size - 1; while (end > begin && data[end] == ' ') { --end; @@ -93,4 +94,5 @@ bool StringRef::end_with(const StringRef& search_string) const { return 0 == memcmp(data + size - search_string.size, search_string.data, search_string.size); #endif } +#include "common/compile_check_end.h" } // namespace doris diff --git a/be/src/vec/common/string_ref.h b/be/src/vec/common/string_ref.h index e2094ca8f39709..3302fdb2f1d265 100644 --- a/be/src/vec/common/string_ref.h +++ b/be/src/vec/common/string_ref.h @@ -206,11 +206,11 @@ struct StringRef { explicit operator std::string() const { return to_string(); } operator std::string_view() const { return std::string_view {data, size}; } - StringRef substring(int start_pos, int new_len) const { + StringRef substring(int64_t start_pos, int64_t new_len) const { return {data + start_pos, (new_len < 0) ? (size - start_pos) : new_len}; } - StringRef substring(int start_pos) const { return substring(start_pos, size - start_pos); } + StringRef substring(int64_t start_pos) const { return substring(start_pos, size - start_pos); } const char* begin() const { return data; } const char* end() const { return data + size; } diff --git a/be/src/vec/common/string_searcher.h b/be/src/vec/common/string_searcher.h index af76f2100dda2b..c31a3f6f84a72c 100644 --- a/be/src/vec/common/string_searcher.h +++ b/be/src/vec/common/string_searcher.h @@ -32,6 +32,7 @@ #include "vec/common/string_utils/string_utils.h" namespace doris { +#include "common/compile_check_begin.h" // namespace ErrorCodes // { @@ -47,7 +48,7 @@ class StringSearcherBase { #if defined(__SSE2__) || defined(__aarch64__) protected: static constexpr auto n = sizeof(__m128i); - const int page_size = sysconf(_SC_PAGESIZE); //::getPageSize(); + const long page_size = sysconf(_SC_PAGESIZE); //::getPageSize(); bool page_safe(const void* const ptr) const { return ((page_size - 1) & reinterpret_cast(ptr)) <= page_size - n; @@ -416,4 +417,5 @@ struct LibCASCIICaseInsensitiveStringSearcher : public StringSearcherBase { return search(haystack, haystack + haystack_size); } }; +#include "common/compile_check_end.h" } // namespace doris diff --git a/be/src/vec/functions/function.cpp b/be/src/vec/functions/function.cpp index 851e430d2f0407..3ecc2309629344 100644 --- a/be/src/vec/functions/function.cpp +++ b/be/src/vec/functions/function.cpp @@ -39,6 +39,7 @@ #include "vec/utils/util.hpp" namespace doris::vectorized { +#include "common/compile_check_begin.h" ColumnPtr wrap_in_nullable(const ColumnPtr& src, const Block& block, const ColumnNumbers& args, uint32_t result, size_t input_rows_count) { @@ -143,7 +144,7 @@ Status PreparedFunctionImpl::default_implementation_for_constant_arguments( // now all columns are const. Block temporary_block; - size_t arguments_size = args.size(); + uint32_t arguments_size = cast_set(args.size()); for (size_t arg_num = 0; arg_num < arguments_size; ++arg_num) { const ColumnWithTypeAndName& column = block.get_by_position(args[arg_num]); // Columns in const_list --> column_const, others --> nested_column @@ -162,7 +163,7 @@ Status PreparedFunctionImpl::default_implementation_for_constant_arguments( temporary_block.insert(block.get_by_position(result)); ColumnNumbers temporary_argument_numbers(arguments_size); - for (size_t i = 0; i < arguments_size; ++i) { + for (uint32_t i = 0; i < arguments_size; ++i) { temporary_argument_numbers[i] = i; } @@ -364,4 +365,5 @@ bool FunctionBuilderImpl::is_array_nested_type_date_or_datetime_or_decimal( } return false; } +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/functions/function_helpers.cpp b/be/src/vec/functions/function_helpers.cpp index aa93ace35d8c35..bbe35fe16dc43c 100644 --- a/be/src/vec/functions/function_helpers.cpp +++ b/be/src/vec/functions/function_helpers.cpp @@ -39,6 +39,7 @@ #include "vec/functions/function.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" std::tuple create_block_with_nested_columns(const Block& block, const ColumnNumbers& args, @@ -51,7 +52,7 @@ std::tuple create_block_with_nested_columns(const Block& b // just keep one for (size_t i = 0; i < args.size(); ++i) { bool is_in_res = false; - size_t pre_loc = 0; + uint32_t pre_loc = 0; if (need_check_same) { for (int j = 0; j < i; ++j) { @@ -144,4 +145,5 @@ const ColumnConst* check_and_get_column_const_string_or_fixedstring(const IColum return {}; } +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/functions/function_tokenize.cpp b/be/src/vec/functions/function_tokenize.cpp index f0a7c3b68aec49..680b7a64cea7e0 100644 --- a/be/src/vec/functions/function_tokenize.cpp +++ b/be/src/vec/functions/function_tokenize.cpp @@ -29,6 +29,7 @@ #include "olap/rowset/segment_v2/inverted_index/analyzer/analyzer.h" #include "olap/rowset/segment_v2/inverted_index_reader.h" #include "vec/columns/column.h" +#include "vec/columns/column_string.h" #include "vec/common/string_ref.h" #include "vec/core/block.h" #include "vec/core/column_with_type_and_name.h" @@ -36,6 +37,7 @@ #include "vec/data_types/data_type_number.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" Status parse(const std::string& str, std::map& result) { boost::regex pattern( @@ -82,7 +84,7 @@ void FunctionTokenize::_do_tokenize(const ColumnString& src_column_string, } auto reader = doris::segment_v2::inverted_index::InvertedIndexAnalyzer::create_reader( inverted_index_ctx.char_filter_map); - reader->init(tokenize_str.data, tokenize_str.size, true); + reader->init(tokenize_str.data, (ColumnString::Offset)tokenize_str.size, true); std::vector query_tokens = doris::segment_v2::inverted_index::InvertedIndexAnalyzer::get_analyse_result( @@ -174,4 +176,5 @@ Status FunctionTokenize::execute_impl(FunctionContext* /*context*/, Block& block } return Status::RuntimeError("unimplemented function {}", get_name()); } +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/functions/like.cpp b/be/src/vec/functions/like.cpp index d727ba6e850f04..0e18e8a1688b61 100644 --- a/be/src/vec/functions/like.cpp +++ b/be/src/vec/functions/like.cpp @@ -37,6 +37,7 @@ #include "vec/functions/simple_function_factory.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" // A regex to match any regex pattern is equivalent to a substring search. static const RE2 SUBSTRING_RE(R"((?:\.\*)*([^\.\^\{\[\(\|\)\]\}\+\*\?\$\\]*)(?:\.\*)*)"); @@ -384,7 +385,8 @@ Status FunctionLikeBase::vector_substring_fn(const ColumnString& vals, Status FunctionLikeBase::constant_regex_fn_scalar(LikeSearchState* state, const StringRef& val, const StringRef& pattern, unsigned char* result) { if (state->hs_database) { // use hyperscan - auto ret = hs_scan(state->hs_database.get(), val.data, val.size, 0, state->hs_scratch.get(), + auto ret = hs_scan(state->hs_database.get(), val.data, (uint32_t)val.size, 0, + state->hs_scratch.get(), doris::vectorized::LikeSearchState::hs_match_handler, (void*)result); if (ret != HS_SUCCESS && ret != HS_SCAN_TERMINATED) { return Status::RuntimeError(fmt::format("hyperscan error: {}", ret)); @@ -418,7 +420,7 @@ Status FunctionLikeBase::constant_regex_fn(LikeSearchState* state, const ColumnS if (state->hs_database) { // use hyperscan for (size_t i = 0; i < sz; i++) { const auto& str_ref = val.get_data_at(i); - auto ret = hs_scan(state->hs_database.get(), str_ref.data, str_ref.size, 0, + auto ret = hs_scan(state->hs_database.get(), str_ref.data, (uint32_t)str_ref.size, 0, state->hs_scratch.get(), doris::vectorized::LikeSearchState::hs_match_handler, (void*)(result.data() + i)); @@ -447,7 +449,7 @@ Status FunctionLikeBase::regexp_fn(LikeSearchState* state, const ColumnString& v auto sz = val.size(); for (size_t i = 0; i < sz; i++) { const auto& str_ref = val.get_data_at(i); - auto ret = hs_scan(database, str_ref.data, str_ref.size, 0, scratch, + auto ret = hs_scan(database, str_ref.data, (uint32_t)str_ref.size, 0, scratch, doris::vectorized::LikeSearchState::hs_match_handler, (void*)(result.data() + i)); if (ret != HS_SUCCESS && ret != HS_SCAN_TERMINATED) { @@ -766,8 +768,8 @@ void FunctionLike::convert_like_pattern(LikeSearchState* state, const std::strin void FunctionLike::remove_escape_character(std::string* search_string) { std::string tmp_search_string; tmp_search_string.swap(*search_string); - int len = tmp_search_string.length(); - for (int i = 0; i < len;) { + int64_t len = tmp_search_string.length(); + for (int64_t i = 0; i < len;) { if (tmp_search_string[i] == '\\' && i + 1 < len && (tmp_search_string[i + 1] == '%' || tmp_search_string[i + 1] == '_' || tmp_search_string[i + 1] == '\\')) { @@ -796,7 +798,7 @@ bool re2_full_match(const std::string& str, const RE2& re, std::vector inline void throw_if_division_leads_to_FPE(A a, B b) { @@ -63,10 +64,10 @@ struct ModuloImpl { if (!is_null) { for (size_t i = 0; i < size; i++) { if constexpr (std::is_floating_point_v) { - c[i] = std::fmod((double)a[i], (double)b); + c[i] = static_cast(std::fmod((double)a[i], (double)b)); } else { throw_if_division_leads_to_FPE(a[i], b); - c[i] = a[i] % b; + c[i] = static_cast(a[i] % b); } } } @@ -78,10 +79,10 @@ struct ModuloImpl { b += is_null; if constexpr (std::is_floating_point_v) { - return std::fmod((double)a, (double)b); + return static_cast(std::fmod((double)a, (double)b)); } else { throw_if_division_leads_to_FPE(a, b); - return a % b; + return static_cast(a % b); } } @@ -108,10 +109,11 @@ struct PModuloImpl { if (!is_null) { for (size_t i = 0; i < size; i++) { if constexpr (std::is_floating_point_v) { - c[i] = std::fmod(std::fmod((double)a[i], (double)b) + (double)b, double(b)); + c[i] = static_cast( + std::fmod(std::fmod((double)a[i], (double)b) + (double)b, double(b))); } else { throw_if_division_leads_to_FPE(a[i], b); - c[i] = (a[i] % b + b) % b; + c[i] = static_cast((a[i] % b + b) % b); } } } @@ -123,10 +125,11 @@ struct PModuloImpl { b += is_null; if constexpr (std::is_floating_point_v) { - return std::fmod(std::fmod((double)a, (double)b) + (double)b, (double)b); + return static_cast( + std::fmod(std::fmod((double)a, (double)b) + (double)b, (double)b)); } else { throw_if_division_leads_to_FPE(a, b); - return (a % b + b) % b; + return static_cast((a % b + b) % b); } } @@ -154,4 +157,5 @@ void register_function_modulo(SimpleFunctionFactory& factory) { factory.register_alias("mod", "fmod"); } +#include "common/compile_check_end.h" } // namespace doris::vectorized diff --git a/be/src/vec/functions/url/functions_url.h b/be/src/vec/functions/url/functions_url.h index b6736496d24345..73519764c8fdc7 100644 --- a/be/src/vec/functions/url/functions_url.h +++ b/be/src/vec/functions/url/functions_url.h @@ -24,6 +24,7 @@ #include "vec/common/memcpy_small.h" namespace doris::vectorized { +#include "common/compile_check_begin.h" /** URL processing functions. See implementation in separate .cpp files. * All functions are not strictly follow RFC, instead they are maximally simplified for performance reasons. @@ -93,7 +94,7 @@ struct ExtractSubstringImpl { memcpy_small_allow_read_write_overflow15(&res_data[res_offset], start, length); res_offset += length; - res_offsets[i] = res_offset; + res_offsets[i] = (ColumnString::Offset)res_offset; prev_offset = offsets[i]; } } @@ -151,4 +152,5 @@ struct CutSubstringImpl { } }; +#include "common/compile_check_end.h" } // namespace doris::vectorized From f72081cf2c0862346b0734e653889e3af8576967 Mon Sep 17 00:00:00 2001 From: Mryange Date: Thu, 26 Dec 2024 23:30:37 +0800 Subject: [PATCH 2/2] upd --- be/src/vec/functions/function_time_value_to_field.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/be/src/vec/functions/function_time_value_to_field.cpp b/be/src/vec/functions/function_time_value_to_field.cpp index 8c8ec3cf9ab219..c5aaeefd47396a 100644 --- a/be/src/vec/functions/function_time_value_to_field.cpp +++ b/be/src/vec/functions/function_time_value_to_field.cpp @@ -26,6 +26,7 @@ #include "vec/runtime/time_value.h" #include "vec/utils/template_helpers.hpp" namespace doris::vectorized { +#include "common/compile_check_begin.h" template class FunctionTimeValueToField : public IFunction { @@ -62,7 +63,8 @@ class FunctionTimeValueToField : public IFunction { auto& col_res_data = col_res->get_data(); for (size_t i = 0; i < input_rows_count; i++) { - col_res_data[i] = Transform::execute(column_time->get_element(i)); + col_res_data[i] = static_cast( + Transform::execute(column_time->get_element(i))); } block.replace_by_position(result, std::move(col_res)); @@ -91,4 +93,5 @@ void register_function_time_value_field(SimpleFunctionFactory& factory) { factory.register_function>(); } +#include "common/compile_check_end.h" } // namespace doris::vectorized \ No newline at end of file