This is an automated email from the ASF dual-hosted git repository. yiguolei 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 4692d6764c [refactor](remove string val) remove string val structure, it is same with string ref (#17461) 4692d6764c is described below commit 4692d6764c599165891321edaeb3e4d6e066bc24 Author: yiguolei <676222...@qq.com> AuthorDate: Wed Mar 8 10:42:20 2023 +0800 [refactor](remove string val) remove string val structure, it is same with string ref (#17461) remove stringval, decimalv2val, bigintval --- be/src/exprs/function_filter.h | 6 +- be/src/exprs/math_functions.cpp | 6 +- be/src/exprs/math_functions.h | 3 +- be/src/exprs/string_functions.cpp | 18 +- be/src/exprs/string_functions.h | 6 +- be/src/olap/like_column_predicate.cpp | 183 ++++++++++---------- be/src/olap/like_column_predicate.h | 119 ++++++------- be/src/olap/reader.cpp | 7 +- be/src/olap/rowset/segment_v2/segment_iterator.cpp | 3 +- be/src/runtime/decimalv2_value.h | 6 - be/src/runtime/tablets_channel.cpp | 2 - be/src/runtime/tablets_channel.h | 2 - be/src/udf/udf.cpp | 8 +- be/src/udf/udf.h | 184 +-------------------- be/src/util/bitmap_value.h | 16 +- be/src/util/counts.h | 8 +- be/src/util/simd/vstring_function.h | 65 ++++---- .../aggregate_function_approx_count_distinct.h | 4 +- .../aggregate_function_percentile_approx.h | 7 +- be/src/vec/common/string_ref.h | 13 -- be/src/vec/exec/scan/new_olap_scan_node.cpp | 4 +- be/src/vec/exec/scan/new_olap_scan_node.h | 2 +- be/src/vec/exec/scan/vscan_node.cpp | 2 +- be/src/vec/exec/scan/vscan_node.h | 2 +- be/src/vec/functions/function_bitmap_min_or_max.h | 4 +- be/src/vec/functions/function_conv.cpp | 8 +- be/src/vec/functions/function_regexp.cpp | 32 ++-- be/src/vec/functions/function_string.cpp | 4 +- be/src/vec/functions/function_string.h | 91 +++++----- be/src/vec/olap/block_reader.cpp | 4 +- be/src/vec/runtime/vdatetime_value.h | 7 - be/src/vec/runtime/vorc_writer.cpp | 69 ++++---- be/test/util/counts_test.cpp | 10 +- 33 files changed, 335 insertions(+), 570 deletions(-) diff --git a/be/src/exprs/function_filter.h b/be/src/exprs/function_filter.h index ba240498a5..adaaa85aeb 100644 --- a/be/src/exprs/function_filter.h +++ b/be/src/exprs/function_filter.h @@ -26,7 +26,7 @@ namespace doris { class FunctionFilter { public: FunctionFilter(bool opposite, const std::string& col_name, doris::FunctionContext* fn_ctx, - doris::StringVal string_param) + doris::StringRef string_param) : _opposite(opposite), _col_name(col_name), _fn_ctx(fn_ctx), @@ -36,8 +36,8 @@ public: std::string _col_name; // these pointer's life time controlled by scan node doris::FunctionContext* _fn_ctx; - doris::StringVal - _string_param; // only one param from conjunct, because now only support like predicate + // only one param from conjunct, because now only support like predicate + doris::StringRef _string_param; }; } // namespace doris diff --git a/be/src/exprs/math_functions.cpp b/be/src/exprs/math_functions.cpp index 6648a3727a..04ca6f57c1 100644 --- a/be/src/exprs/math_functions.cpp +++ b/be/src/exprs/math_functions.cpp @@ -100,7 +100,7 @@ double MathFunctions::my_double_round(double value, int64_t dec, bool dec_unsign return tmp2; } -StringVal MathFunctions::decimal_to_base(FunctionContext* ctx, int64_t src_num, int8_t dest_base) { +StringRef MathFunctions::decimal_to_base(FunctionContext* ctx, int64_t src_num, int8_t dest_base) { // Max number of digits of any base (base 2 gives max digits), plus sign. const size_t max_digits = sizeof(uint64_t) * 8 + 1; char buf[max_digits]; @@ -127,8 +127,8 @@ StringVal MathFunctions::decimal_to_base(FunctionContext* ctx, int64_t src_num, buf[buf_index] = '-'; ++result_len; } - StringVal result = ctx->create_temp_string_val(result_len); - memcpy(result.ptr, buf + max_digits - result_len, result_len); + StringRef result = ctx->create_temp_string_val(result_len); + memcpy(const_cast<char*>(result.data), buf + max_digits - result_len, result_len); return result; } diff --git a/be/src/exprs/math_functions.h b/be/src/exprs/math_functions.h index 8d1563a17e..108a690660 100644 --- a/be/src/exprs/math_functions.h +++ b/be/src/exprs/math_functions.h @@ -23,6 +23,7 @@ #include <stdint.h> #include "util/string_parser.hpp" +#include "vec/common/string_ref.h" namespace doris { @@ -32,7 +33,7 @@ public: // Converts src_num in decimal to dest_base, // and fills expr_val.string_val with the result. - static doris::StringVal decimal_to_base(doris::FunctionContext* ctx, int64_t src_num, + static doris::StringRef decimal_to_base(doris::FunctionContext* ctx, int64_t src_num, int8_t dest_base); // Converts src_num representing a number in src_base but encoded in decimal diff --git a/be/src/exprs/string_functions.cpp b/be/src/exprs/string_functions.cpp index a9b4b737e8..ac80e21b9b 100644 --- a/be/src/exprs/string_functions.cpp +++ b/be/src/exprs/string_functions.cpp @@ -32,10 +32,10 @@ namespace doris { // This function sets options in the RE2 library before pattern matching. -bool StringFunctions::set_re2_options(const StringVal& match_parameter, std::string* error_str, +bool StringFunctions::set_re2_options(const StringRef& match_parameter, std::string* error_str, re2::RE2::Options* opts) { - for (int i = 0; i < match_parameter.len; i++) { - char match = match_parameter.ptr[i]; + for (int i = 0; i < match_parameter.size; i++) { + char match = match_parameter.data[i]; switch (match) { case 'i': opts->set_case_sensitive(false); @@ -62,10 +62,10 @@ bool StringFunctions::set_re2_options(const StringVal& match_parameter, std::str } // The caller owns the returned regex. Returns nullptr if the pattern could not be compiled. -bool StringFunctions::compile_regex(const StringVal& pattern, std::string* error_str, - const StringVal& match_parameter, +bool StringFunctions::compile_regex(const StringRef& pattern, std::string* error_str, + const StringRef& match_parameter, std::unique_ptr<re2::RE2>& re) { - re2::StringPiece pattern_sp(reinterpret_cast<char*>(pattern.ptr), pattern.len); + re2::StringPiece pattern_sp(pattern.data, pattern.size); re2::RE2::Options options; // Disable error logging in case e.g. every row causes an error options.set_log_errors(false); @@ -73,15 +73,15 @@ bool StringFunctions::compile_regex(const StringVal& pattern, std::string* error // Return the leftmost longest match (rather than the first match). // options.set_longest_match(true); options.set_dot_nl(true); - if (!match_parameter.is_null && + if (match_parameter.size > 0 && !StringFunctions::set_re2_options(match_parameter, error_str, &options)) { return false; } re.reset(new re2::RE2(pattern_sp, options)); if (!re->ok()) { std::stringstream ss; - ss << "Could not compile regexp pattern: " - << std::string(reinterpret_cast<char*>(pattern.ptr), pattern.len) << std::endl + ss << "Could not compile regexp pattern: " << std::string(pattern.data, pattern.size) + << std::endl << "Error: " << re->error(); *error_str = ss.str(); re.reset(); diff --git a/be/src/exprs/string_functions.h b/be/src/exprs/string_functions.h index 14515b8dc5..e8527eb614 100644 --- a/be/src/exprs/string_functions.h +++ b/be/src/exprs/string_functions.h @@ -34,11 +34,11 @@ namespace doris { class StringFunctions { public: - static bool set_re2_options(const doris::StringVal& match_parameter, std::string* error_str, + static bool set_re2_options(const doris::StringRef& match_parameter, std::string* error_str, re2::RE2::Options* opts); // The caller owns the returned regex. Returns nullptr if the pattern could not be compiled. - static bool compile_regex(const StringVal& pattern, std::string* error_str, - const StringVal& match_parameter, std::unique_ptr<re2::RE2>& re); + static bool compile_regex(const StringRef& pattern, std::string* error_str, + const StringRef& match_parameter, std::unique_ptr<re2::RE2>& re); }; } // namespace doris diff --git a/be/src/olap/like_column_predicate.cpp b/be/src/olap/like_column_predicate.cpp index d2057534c9..049a419fbf 100644 --- a/be/src/olap/like_column_predicate.cpp +++ b/be/src/olap/like_column_predicate.cpp @@ -23,117 +23,55 @@ namespace doris { -template <> -LikeColumnPredicate<true>::LikeColumnPredicate(bool opposite, uint32_t column_id, - doris::FunctionContext* fn_ctx, doris::StringVal val) - : ColumnPredicate(column_id, opposite), pattern(reinterpret_cast<char*>(val.ptr), val.len) { - _state = reinterpret_cast<StateType*>( - fn_ctx->get_function_state(doris::FunctionContext::THREAD_LOCAL)); - _state->search_state.clone(_like_state); -} - -template <> -LikeColumnPredicate<false>::LikeColumnPredicate(bool opposite, uint32_t column_id, - doris::FunctionContext* fn_ctx, - doris::StringVal val) +LikeColumnPredicate::LikeColumnPredicate(bool opposite, uint32_t column_id, + doris::FunctionContext* fn_ctx, doris::StringRef val) : ColumnPredicate(column_id, opposite), pattern(val) { _state = reinterpret_cast<StateType*>( fn_ctx->get_function_state(doris::FunctionContext::THREAD_LOCAL)); + _state->search_state.clone(_like_state); } -template <bool is_vectorized> -void LikeColumnPredicate<is_vectorized>::evaluate_vec(const vectorized::IColumn& column, - uint16_t size, bool* flags) const { +void LikeColumnPredicate::evaluate_vec(const vectorized::IColumn& column, uint16_t size, + bool* flags) const { _evaluate_vec<false>(column, size, flags); } -template <bool is_vectorized> -void LikeColumnPredicate<is_vectorized>::evaluate_and_vec(const vectorized::IColumn& column, - uint16_t size, bool* flags) const { +void LikeColumnPredicate::evaluate_and_vec(const vectorized::IColumn& column, uint16_t size, + bool* flags) const { _evaluate_vec<true>(column, size, flags); } -template <bool is_vectorized> -uint16_t LikeColumnPredicate<is_vectorized>::evaluate(const vectorized::IColumn& column, - uint16_t* sel, uint16_t size) const { +uint16_t LikeColumnPredicate::evaluate(const vectorized::IColumn& column, uint16_t* sel, + uint16_t size) const { uint16_t new_size = 0; - if constexpr (is_vectorized) { - if (column.is_nullable()) { - auto* nullable_col = - vectorized::check_and_get_column<vectorized::ColumnNullable>(column); - auto& null_map_data = nullable_col->get_null_map_column().get_data(); - auto& nested_col = nullable_col->get_nested_column(); - if (nested_col.is_column_dictionary()) { - auto* nested_col_ptr = vectorized::check_and_get_column< - vectorized::ColumnDictionary<vectorized::Int32>>(nested_col); - auto& data_array = nested_col_ptr->get_data(); - if (!nullable_col->has_null()) { - for (uint16_t i = 0; i != size; i++) { - uint16_t idx = sel[i]; - sel[new_size] = idx; - StringRef cell_value = nested_col_ptr->get_shrink_value(data_array[idx]); - unsigned char flag = 0; - (_state->scalar_function)( - const_cast<vectorized::LikeSearchState*>(&_like_state), - StringRef(cell_value.data, cell_value.size), pattern, &flag); - new_size += _opposite ^ flag; - } - } else { - for (uint16_t i = 0; i != size; i++) { - uint16_t idx = sel[i]; - sel[new_size] = idx; - if (null_map_data[idx]) { - new_size += _opposite; - continue; - } - - StringRef cell_value = nested_col_ptr->get_shrink_value(data_array[idx]); - unsigned char flag = 0; - (_state->scalar_function)( - const_cast<vectorized::LikeSearchState*>(&_like_state), - StringRef(cell_value.data, cell_value.size), pattern, &flag); - new_size += _opposite ^ flag; - } + if (column.is_nullable()) { + auto* nullable_col = vectorized::check_and_get_column<vectorized::ColumnNullable>(column); + auto& null_map_data = nullable_col->get_null_map_column().get_data(); + auto& nested_col = nullable_col->get_nested_column(); + if (nested_col.is_column_dictionary()) { + auto* nested_col_ptr = vectorized::check_and_get_column< + vectorized::ColumnDictionary<vectorized::Int32>>(nested_col); + auto& data_array = nested_col_ptr->get_data(); + if (!nullable_col->has_null()) { + for (uint16_t i = 0; i != size; i++) { + uint16_t idx = sel[i]; + sel[new_size] = idx; + StringRef cell_value = nested_col_ptr->get_shrink_value(data_array[idx]); + unsigned char flag = 0; + (_state->scalar_function)( + const_cast<vectorized::LikeSearchState*>(&_like_state), + StringRef(cell_value.data, cell_value.size), pattern, &flag); + new_size += _opposite ^ flag; } } else { - auto* str_col = vectorized::check_and_get_column< - vectorized::PredicateColumnType<TYPE_STRING>>(nested_col); - if (!nullable_col->has_null()) { - vectorized::ColumnUInt8::Container res(size, 0); - (_state->predicate_like_function)( - const_cast<vectorized::LikeSearchState*>(&_like_state), *str_col, - pattern, res, sel, size); - for (uint16_t i = 0; i != size; i++) { - uint16_t idx = sel[i]; - sel[new_size] = idx; - new_size += _opposite ^ res[i]; - } - } else { - for (uint16_t i = 0; i != size; i++) { - uint16_t idx = sel[i]; - sel[new_size] = idx; - if (null_map_data[idx]) { - new_size += _opposite; - continue; - } - - StringRef cell_value = str_col->get_data()[idx]; - unsigned char flag = 0; - (_state->scalar_function)( - const_cast<vectorized::LikeSearchState*>(&_like_state), - StringRef(cell_value.data, cell_value.size), pattern, &flag); - new_size += _opposite ^ flag; - } - } - } - } else { - if (column.is_column_dictionary()) { - auto* nested_col_ptr = vectorized::check_and_get_column< - vectorized::ColumnDictionary<vectorized::Int32>>(column); - auto& data_array = nested_col_ptr->get_data(); for (uint16_t i = 0; i != size; i++) { uint16_t idx = sel[i]; sel[new_size] = idx; + if (null_map_data[idx]) { + new_size += _opposite; + continue; + } + StringRef cell_value = nested_col_ptr->get_shrink_value(data_array[idx]); unsigned char flag = 0; (_state->scalar_function)( @@ -141,9 +79,12 @@ uint16_t LikeColumnPredicate<is_vectorized>::evaluate(const vectorized::IColumn& StringRef(cell_value.data, cell_value.size), pattern, &flag); new_size += _opposite ^ flag; } - } else { - auto* str_col = vectorized::check_and_get_column< - vectorized::PredicateColumnType<TYPE_STRING>>(column); + } + } else { + auto* str_col = + vectorized::check_and_get_column<vectorized::PredicateColumnType<TYPE_STRING>>( + nested_col); + if (!nullable_col->has_null()) { vectorized::ColumnUInt8::Container res(size, 0); (_state->predicate_like_function)( const_cast<vectorized::LikeSearchState*>(&_like_state), *str_col, pattern, @@ -153,13 +94,55 @@ uint16_t LikeColumnPredicate<is_vectorized>::evaluate(const vectorized::IColumn& sel[new_size] = idx; new_size += _opposite ^ res[i]; } + } else { + for (uint16_t i = 0; i != size; i++) { + uint16_t idx = sel[i]; + sel[new_size] = idx; + if (null_map_data[idx]) { + new_size += _opposite; + continue; + } + + StringRef cell_value = str_col->get_data()[idx]; + unsigned char flag = 0; + (_state->scalar_function)( + const_cast<vectorized::LikeSearchState*>(&_like_state), + StringRef(cell_value.data, cell_value.size), pattern, &flag); + new_size += _opposite ^ flag; + } + } + } + } else { + if (column.is_column_dictionary()) { + auto* nested_col_ptr = vectorized::check_and_get_column< + vectorized::ColumnDictionary<vectorized::Int32>>(column); + auto& data_array = nested_col_ptr->get_data(); + for (uint16_t i = 0; i != size; i++) { + uint16_t idx = sel[i]; + sel[new_size] = idx; + StringRef cell_value = nested_col_ptr->get_shrink_value(data_array[idx]); + unsigned char flag = 0; + (_state->scalar_function)(const_cast<vectorized::LikeSearchState*>(&_like_state), + StringRef(cell_value.data, cell_value.size), pattern, + &flag); + new_size += _opposite ^ flag; + } + } else { + auto* str_col = + vectorized::check_and_get_column<vectorized::PredicateColumnType<TYPE_STRING>>( + column); + vectorized::ColumnUInt8::Container res(size, 0); + (_state->predicate_like_function)( + const_cast<vectorized::LikeSearchState*>(&_like_state), *str_col, pattern, res, + sel, size); + for (uint16_t i = 0; i != size; i++) { + uint16_t idx = sel[i]; + sel[new_size] = idx; + new_size += _opposite ^ res[i]; } } } return new_size; } -template class LikeColumnPredicate<true>; -template class LikeColumnPredicate<false>; - } //namespace doris diff --git a/be/src/olap/like_column_predicate.h b/be/src/olap/like_column_predicate.h index 941c00723d..11e4c9f07f 100644 --- a/be/src/olap/like_column_predicate.h +++ b/be/src/olap/like_column_predicate.h @@ -25,11 +25,10 @@ namespace doris { -template <bool is_vectorized> class LikeColumnPredicate : public ColumnPredicate { public: LikeColumnPredicate(bool opposite, uint32_t column_id, doris::FunctionContext* fn_ctx, - doris::StringVal val); + doris::StringRef val); ~LikeColumnPredicate() override = default; PredicateType type() const override { return PredicateType::EQ; } @@ -47,12 +46,7 @@ public: bool* flags) const override; std::string get_search_str() const override { - if constexpr (std::is_same_v<PatternType, StringRef>) { - return std::string(reinterpret_cast<const char*>(pattern.data), pattern.size); - } else if constexpr (std::is_same_v<PatternType, StringVal>) { - return std::string(reinterpret_cast<const char*>(pattern.ptr), pattern.len); - } - DCHECK(false); + return std::string(reinterpret_cast<const char*>(pattern.data), pattern.size); } bool is_opposite() const { return _opposite; } @@ -70,68 +64,66 @@ public: private: template <bool is_and> void _evaluate_vec(const vectorized::IColumn& column, uint16_t size, bool* flags) const { - if constexpr (is_vectorized) { - if (column.is_nullable()) { - auto* nullable_col = - vectorized::check_and_get_column<vectorized::ColumnNullable>(column); - auto& null_map_data = nullable_col->get_null_map_column().get_data(); - auto& nested_col = nullable_col->get_nested_column(); - if (nested_col.is_column_dictionary()) { - auto* nested_col_ptr = vectorized::check_and_get_column< - vectorized::ColumnDictionary<vectorized::Int32>>(nested_col); - auto& data_array = nested_col_ptr->get_data(); - for (uint16_t i = 0; i < size; i++) { - if (null_map_data[i]) { - if constexpr (is_and) { - flags[i] &= _opposite; - } else { - flags[i] = _opposite; - } - continue; - } - - StringRef cell_value = nested_col_ptr->get_shrink_value(data_array[i]); + if (column.is_nullable()) { + auto* nullable_col = + vectorized::check_and_get_column<vectorized::ColumnNullable>(column); + auto& null_map_data = nullable_col->get_null_map_column().get_data(); + auto& nested_col = nullable_col->get_nested_column(); + if (nested_col.is_column_dictionary()) { + auto* nested_col_ptr = vectorized::check_and_get_column< + vectorized::ColumnDictionary<vectorized::Int32>>(nested_col); + auto& data_array = nested_col_ptr->get_data(); + for (uint16_t i = 0; i < size; i++) { + if (null_map_data[i]) { if constexpr (is_and) { - unsigned char flag = 0; - (_state->scalar_function)( - const_cast<vectorized::LikeSearchState*>(&_like_state), - StringRef(cell_value.data, cell_value.size), pattern, &flag); - flags[i] &= _opposite ^ flag; + flags[i] &= _opposite; } else { - unsigned char flag = 0; - (_state->scalar_function)( - const_cast<vectorized::LikeSearchState*>(&_like_state), - StringRef(cell_value.data, cell_value.size), pattern, &flag); - flags[i] = _opposite ^ flag; + flags[i] = _opposite; } + continue; + } + + StringRef cell_value = nested_col_ptr->get_shrink_value(data_array[i]); + if constexpr (is_and) { + unsigned char flag = 0; + (_state->scalar_function)( + const_cast<vectorized::LikeSearchState*>(&_like_state), + StringRef(cell_value.data, cell_value.size), pattern, &flag); + flags[i] &= _opposite ^ flag; + } else { + unsigned char flag = 0; + (_state->scalar_function)( + const_cast<vectorized::LikeSearchState*>(&_like_state), + StringRef(cell_value.data, cell_value.size), pattern, &flag); + flags[i] = _opposite ^ flag; } - } else { - LOG(FATAL) << "vectorized (not) like predicates should be dict column"; } } else { - if (column.is_column_dictionary()) { - auto* nested_col_ptr = vectorized::check_and_get_column< - vectorized::ColumnDictionary<vectorized::Int32>>(column); - auto& data_array = nested_col_ptr->get_data(); - for (uint16_t i = 0; i < size; i++) { - StringRef cell_value = nested_col_ptr->get_shrink_value(data_array[i]); - if constexpr (is_and) { - unsigned char flag = 0; - (_state->scalar_function)( - const_cast<vectorized::LikeSearchState*>(&_like_state), - StringRef(cell_value.data, cell_value.size), pattern, &flag); - flags[i] &= _opposite ^ flag; - } else { - unsigned char flag = 0; - (_state->scalar_function)( - const_cast<vectorized::LikeSearchState*>(&_like_state), - StringRef(cell_value.data, cell_value.size), pattern, &flag); - flags[i] = _opposite ^ flag; - } + LOG(FATAL) << "vectorized (not) like predicates should be dict column"; + } + } else { + if (column.is_column_dictionary()) { + auto* nested_col_ptr = vectorized::check_and_get_column< + vectorized::ColumnDictionary<vectorized::Int32>>(column); + auto& data_array = nested_col_ptr->get_data(); + for (uint16_t i = 0; i < size; i++) { + StringRef cell_value = nested_col_ptr->get_shrink_value(data_array[i]); + if constexpr (is_and) { + unsigned char flag = 0; + (_state->scalar_function)( + const_cast<vectorized::LikeSearchState*>(&_like_state), + StringRef(cell_value.data, cell_value.size), pattern, &flag); + flags[i] &= _opposite ^ flag; + } else { + unsigned char flag = 0; + (_state->scalar_function)( + const_cast<vectorized::LikeSearchState*>(&_like_state), + StringRef(cell_value.data, cell_value.size), pattern, &flag); + flags[i] = _opposite ^ flag; } - } else { - LOG(FATAL) << "vectorized (not) like predicates should be dict column"; } + } else { + LOG(FATAL) << "vectorized (not) like predicates should be dict column"; } } } @@ -143,9 +135,8 @@ private: std::string _origin; // lifetime controlled by scan node - using PatternType = std::conditional_t<is_vectorized, StringRef, StringVal>; using StateType = vectorized::LikeState; - PatternType pattern; + StringRef pattern; StateType* _state; diff --git a/be/src/olap/reader.cpp b/be/src/olap/reader.cpp index bebed4e963..7d03696bc7 100644 --- a/be/src/olap/reader.cpp +++ b/be/src/olap/reader.cpp @@ -483,8 +483,7 @@ void TabletReader::_init_conditions_param(const ReaderParams& read_params) { // Function filter push down to storage engine auto is_like_predicate = [](ColumnPredicate* _pred) { - if (dynamic_cast<LikeColumnPredicate<false>*>(_pred) || - dynamic_cast<LikeColumnPredicate<true>*>(_pred)) { + if (dynamic_cast<LikeColumnPredicate*>(_pred)) { return true; } @@ -578,8 +577,8 @@ ColumnPredicate* TabletReader::_parse_to_predicate(const FunctionFilter& functio } // currently only support like predicate - return new LikeColumnPredicate<false>(function_filter._opposite, index, function_filter._fn_ctx, - function_filter._string_param); + return new LikeColumnPredicate(function_filter._opposite, index, function_filter._fn_ctx, + function_filter._string_param); } Status TabletReader::_init_delete_condition(const ReaderParams& read_params) { diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp index 5164561e6f..dfdb340027 100644 --- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp +++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp @@ -570,8 +570,7 @@ bool SegmentIterator::_check_apply_by_inverted_index(ColumnPredicate* pred, bool } // Function filter no apply inverted index - if (dynamic_cast<LikeColumnPredicate<false>*>(pred) || - dynamic_cast<LikeColumnPredicate<true>*>(pred)) { + if (dynamic_cast<LikeColumnPredicate*>(pred)) { return false; } diff --git a/be/src/runtime/decimalv2_value.h b/be/src/runtime/decimalv2_value.h index 44d93c7e11..ddce791e45 100644 --- a/be/src/runtime/decimalv2_value.h +++ b/be/src/runtime/decimalv2_value.h @@ -237,12 +237,6 @@ public: MAX_FRAC_VALUE / get_scale_base(9 - scale) * get_scale_base(9 - scale)); } - static DecimalV2Value from_decimal_val(const DecimalV2Val& val) { - return DecimalV2Value(val.value()); - } - - void to_decimal_val(DecimalV2Val* value) const { value->val = _value; } - // Solve Square root for int128 static DecimalV2Value sqrt(const DecimalV2Value& v); diff --git a/be/src/runtime/tablets_channel.cpp b/be/src/runtime/tablets_channel.cpp index 833b4d995c..af423d0269 100644 --- a/be/src/runtime/tablets_channel.cpp +++ b/be/src/runtime/tablets_channel.cpp @@ -48,7 +48,6 @@ TabletsChannel::~TabletsChannel() { for (auto& it : _tablet_writers) { delete it.second; } - delete _row_desc; delete _schema; } @@ -65,7 +64,6 @@ Status TabletsChannel::open(const PTabletWriterOpenRequest& request) { _schema = new OlapTableSchemaParam(); RETURN_IF_ERROR(_schema->init(request.schema())); _tuple_desc = _schema->tuple_desc(); - _row_desc = new RowDescriptor(_tuple_desc, false); _num_remaining_senders = request.num_senders(); _next_seqs.resize(_num_remaining_senders, 0); diff --git a/be/src/runtime/tablets_channel.h b/be/src/runtime/tablets_channel.h index 3f9fdce635..e5d0c03718 100644 --- a/be/src/runtime/tablets_channel.h +++ b/be/src/runtime/tablets_channel.h @@ -136,8 +136,6 @@ private: OlapTableSchemaParam* _schema = nullptr; TupleDescriptor* _tuple_desc = nullptr; - // row_desc used to construct - RowDescriptor* _row_desc = nullptr; // next sequence we expect int _num_remaining_senders = 0; diff --git a/be/src/udf/udf.cpp b/be/src/udf/udf.cpp index d547e60432..c53f3eaf0d 100644 --- a/be/src/udf/udf.cpp +++ b/be/src/udf/udf.cpp @@ -37,6 +37,7 @@ #include "runtime/types.h" #include "udf/udf_internal.h" #include "util/debug_util.h" +#include "vec/common/string_ref.h" namespace doris { @@ -165,12 +166,9 @@ void* FunctionContext::get_function_state(FunctionStateScope scope) const { } } -StringVal FunctionContext::create_temp_string_val(int64_t len) { +StringRef FunctionContext::create_temp_string_val(int64_t len) { this->impl()->string_result().resize(len); - return StringVal((uint8_t*)this->impl()->string_result().c_str(), len); + return StringRef((uint8_t*)this->impl()->string_result().c_str(), len); } -std::ostream& operator<<(std::ostream& os, const StringVal& string_val) { - return os << string_val.to_string(); -} } // namespace doris diff --git a/be/src/udf/udf.h b/be/src/udf/udf.h index 093048372c..0a7c5b26dc 100644 --- a/be/src/udf/udf.h +++ b/be/src/udf/udf.h @@ -41,9 +41,8 @@ struct TypeDescriptor; // object containing a boolean to store if the value is nullptr and the value itself. The // value is unspecified if the nullptr boolean is set. struct AnyVal; -struct StringVal; +struct StringRef; struct DateTimeVal; -struct DecimalV2Val; // The FunctionContext is passed to every UDF/UDA and is the interface for the UDF to the // rest of the system. It contains APIs to examine the system state, report errors @@ -127,8 +126,8 @@ public: // Init() or Close() functions. doris::ColumnPtrWrapper* get_constant_col(int arg_idx) const; - // Creates a StringVal, which memory is available when this function context is used next time - StringVal create_temp_string_val(int64_t len); + // Creates a StringRef, which memory is available when this function context is used next time + StringRef create_temp_string_val(int64_t len); ~FunctionContext() = default; @@ -156,62 +155,6 @@ struct AnyVal { AnyVal(bool is_null) : is_null(is_null) {} }; -struct BigIntVal : public AnyVal { - int64_t val; - - BigIntVal() : val(0) {} - - BigIntVal(int64_t val) : val(val) {} - - static BigIntVal null() { - BigIntVal result; - result.is_null = true; - return result; - } - - bool operator==(const BigIntVal& other) const { - if (is_null && other.is_null) { - return true; - } - - if (is_null || other.is_null) { - return false; - } - - return val == other.val; - } - - bool operator!=(const BigIntVal& other) const { return !(*this == other); } -}; - -struct DoubleVal : public AnyVal { - double val; - - DoubleVal() : val(0.0) {} - - DoubleVal(double val) : val(val) {} - - static DoubleVal null() { - DoubleVal result; - result.is_null = true; - return result; - } - - bool operator==(const DoubleVal& other) const { - if (is_null && other.is_null) { - return true; - } - - if (is_null || other.is_null) { - return false; - } - - return val == other.val; - } - - bool operator!=(const DoubleVal& other) const { return !(*this == other); } -}; - // This object has a compatible storage format with boost::ptime. struct DateTimeVal : public AnyVal { // MySQL packet time @@ -243,127 +186,6 @@ struct DateTimeVal : public AnyVal { bool operator!=(const DateTimeVal& other) const { return !(*this == other); } }; -struct DateTimeV2Val : public AnyVal { - uint64_t datetimev2_value; - - DateTimeV2Val() : datetimev2_value(0) {} - - DateTimeV2Val(uint64_t val) : datetimev2_value(val) {} - - static DateTimeV2Val null() { - DateTimeV2Val result; - result.is_null = true; - return result; - } - - bool operator==(const DateTimeV2Val& other) const { - if (is_null && other.is_null) { - return true; - } - - if (is_null || other.is_null) { - return false; - } - - return datetimev2_value == other.datetimev2_value; - } - - bool operator!=(const DateTimeV2Val& other) const { return !(*this == other); } -}; - -// FIXME: for view using we should use StringRef. StringVal need to be rewrite to deep-copy type. -// Note: there is a difference between a nullptr string (is_null == true) and an -// empty string (len == 0). -struct StringVal : public AnyVal { - static const int MAX_LENGTH = (1 << 30); - - int64_t len; - uint8_t* ptr; - - // Construct a StringVal from ptr/len. Note: this does not make a copy of ptr - // so the buffer must exist as long as this StringVal does. - StringVal() : len(0), ptr(nullptr) {} - - // Construct a StringVal from ptr/len. Note: this does not make a copy of ptr - // so the buffer must exist as long as this StringVal does. - StringVal(uint8_t* ptr, int64_t len) : len(len), ptr(ptr) {} - - // Construct a StringVal from nullptr-terminated c-string. Note: this does not make a - // copy of ptr so the underlying string must exist as long as this StringVal does. - StringVal(const char* ptr) : len(strlen(ptr)), ptr((uint8_t*)ptr) {} - - StringVal(const char* ptr, int64_t len) : len(len), ptr((uint8_t*)ptr) {} - - static StringVal null() { - StringVal sv; - sv.is_null = true; - return sv; - } - - bool operator==(const StringVal& other) const { - if (is_null != other.is_null) { - return false; - } - - if (is_null) { - return true; - } - - if (len != other.len) { - return false; - } - - return len == 0 || ptr == other.ptr || memcmp(ptr, other.ptr, len) == 0; - } - - bool operator!=(const StringVal& other) const { return !(*this == other); } - - std::string to_string() const { return std::string((char*)ptr, len); } -}; - -std::ostream& operator<<(std::ostream& os, const StringVal& string_val); - -struct DecimalV2Val : public AnyVal { - __int128 val; - - // Default value is zero - DecimalV2Val() : val(0) {} - - const __int128& value() const { return val; } - - DecimalV2Val(__int128 value) : val(value) {} - - static DecimalV2Val null() { - DecimalV2Val result; - result.is_null = true; - return result; - } - - void set_to_zero() { val = 0; } - - void set_to_abs_value() { - if (val < 0) val = -val; - } - - bool operator==(const DecimalV2Val& other) const { - if (is_null && other.is_null) { - return true; - } - - if (is_null || other.is_null) { - return false; - } - - return val == other.val; - } - - bool operator!=(const DecimalV2Val& other) const { return !(*this == other); } -}; - -using doris::BigIntVal; -using doris::DoubleVal; -using doris::StringVal; -using doris::DecimalV2Val; using doris::DateTimeVal; using doris::FunctionContext; } // namespace doris diff --git a/be/src/util/bitmap_value.h b/be/src/util/bitmap_value.h index d95ff00f1d..4f2fad3e8d 100644 --- a/be/src/util/bitmap_value.h +++ b/be/src/util/bitmap_value.h @@ -1628,14 +1628,14 @@ public: return true; } - doris::BigIntVal minimum() const { + int64_t minimum() const { switch (_type) { case SINGLE: - return doris::BigIntVal(_sv); + return _sv; case BITMAP: - return doris::BigIntVal(_bitmap.minimum()); + return _bitmap.minimum(); default: - return doris::BigIntVal::null(); + return 0; } } @@ -1673,14 +1673,14 @@ public: return ss.str(); } - doris::BigIntVal maximum() const { + int64_t maximum() const { switch (_type) { case SINGLE: - return doris::BigIntVal(_sv); + return _sv; case BITMAP: - return doris::BigIntVal(_bitmap.maximum()); + return _bitmap.maximum(); default: - return doris::BigIntVal::null(); + return 0; } } diff --git a/be/src/util/counts.h b/be/src/util/counts.h index 0818dbeed3..8291d3a5b1 100644 --- a/be/src/util/counts.h +++ b/be/src/util/counts.h @@ -107,9 +107,11 @@ public: return (higher - position) * lower_key + (position - lower) * higher_key; } - doris::DoubleVal terminate(double quantile) const { + double terminate(double quantile) const { if (_counts.empty()) { - return doris::DoubleVal::null(); + // 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()); @@ -126,7 +128,7 @@ public: long max_position = total - 1; double position = max_position * quantile; - return doris::DoubleVal(get_percentile(elems, position)); + return get_percentile(elems, position); } private: diff --git a/be/src/util/simd/vstring_function.h b/be/src/util/simd/vstring_function.h index d716e8e573..6a6d1fcb72 100644 --- a/be/src/util/simd/vstring_function.h +++ b/be/src/util/simd/vstring_function.h @@ -56,50 +56,50 @@ public: static constexpr auto REGISTER_SIZE = sizeof(__m128i); #endif public: - static StringVal rtrim(const StringVal& str) { - if (str.is_null || str.len == 0) { + static StringRef rtrim(const StringRef& str) { + if (str.size == 0) { return str; } auto begin = 0; - auto end = str.len - 1; + int64_t end = str.size - 1; #if defined(__SSE2__) || defined(__aarch64__) char blank = ' '; const auto pattern = _mm_set1_epi8(blank); while (end - begin + 1 >= REGISTER_SIZE) { const auto v_haystack = _mm_loadu_si128( - reinterpret_cast<const __m128i*>(str.ptr + end + 1 - REGISTER_SIZE)); + reinterpret_cast<const __m128i*>(str.data + end + 1 - REGISTER_SIZE)); const auto v_against_pattern = _mm_cmpeq_epi8(v_haystack, pattern); const auto mask = _mm_movemask_epi8(v_against_pattern); int offset = __builtin_clz(~(mask << REGISTER_SIZE)); /// means not found if (offset == 0) { - return StringVal(str.ptr + begin, end - begin + 1); + return StringRef(str.data + begin, end - begin + 1); } else { end -= offset; } } #endif - while (end >= begin && str.ptr[end] == ' ') { + while (end >= begin && str.data[end] == ' ') { --end; } if (end < 0) { - return StringVal(""); + return StringRef(""); } - return StringVal(str.ptr + begin, end - begin + 1); + return StringRef(str.data + begin, end - begin + 1); } - static StringVal ltrim(const StringVal& str) { - if (str.is_null || str.len == 0) { + static StringRef ltrim(const StringRef& str) { + if (str.size == 0) { return str; } auto begin = 0; - auto end = str.len - 1; + auto end = str.size - 1; #if defined(__SSE2__) || defined(__aarch64__) char blank = ' '; const auto pattern = _mm_set1_epi8(blank); while (end - begin + 1 >= REGISTER_SIZE) { const auto v_haystack = - _mm_loadu_si128(reinterpret_cast<const __m128i*>(str.ptr + begin)); + _mm_loadu_si128(reinterpret_cast<const __m128i*>(str.data + begin)); const auto v_against_pattern = _mm_cmpeq_epi8(v_haystack, pattern); const auto mask = _mm_movemask_epi8(v_against_pattern) ^ 0xffff; /// zero means not found @@ -108,56 +108,57 @@ public: } else { const auto offset = __builtin_ctz(mask); begin += offset; - return StringVal(str.ptr + begin, end - begin + 1); + return StringRef(str.data + begin, end - begin + 1); } } #endif - while (begin <= end && str.ptr[begin] == ' ') { + while (begin <= end && str.data[begin] == ' ') { ++begin; } - return StringVal(str.ptr + begin, end - begin + 1); + return StringRef(str.data + begin, end - begin + 1); } - static StringVal trim(const StringVal& str) { - if (str.is_null || str.len == 0) { + static StringRef trim(const StringRef& str) { + if (str.size == 0) { return str; } return rtrim(ltrim(str)); } // Gcc will do auto simd in this function - static bool is_ascii(const StringVal& str) { + static bool is_ascii(const StringRef& str) { char or_code = 0; - for (size_t i = 0; i < str.len; i++) { - or_code |= str.ptr[i]; + for (size_t i = 0; i < str.size; i++) { + or_code |= str.data[i]; } return !(or_code & 0x80); } - static void reverse(const StringVal& str, StringVal dst) { + static void reverse(const StringRef& str, StringRef dst) { if (is_ascii(str)) { int64_t begin = 0; - int64_t end = str.len; - int64_t result_end = dst.len - 1; + int64_t end = str.size; + int64_t result_end = dst.size - 1; // auto SIMD here - auto* __restrict l = dst.ptr; - auto* __restrict r = str.ptr; + auto* __restrict l = const_cast<char*>(dst.data); + auto* __restrict r = str.data; for (; begin < end; ++begin, --result_end) { l[result_end] = r[begin]; } } else { - for (size_t i = 0, char_size = 0; i < str.len; i += char_size) { - char_size = UTF8_BYTE_LENGTH[(unsigned char)(str.ptr)[i]]; + char* dst_data = const_cast<char*>(dst.data); + for (size_t i = 0, char_size = 0; i < str.size; i += char_size) { + char_size = UTF8_BYTE_LENGTH[(unsigned char)(str.data)[i]]; // there exists occasion where the last character is an illegal UTF-8 one which returns // a char_size larger than the actual space, which would cause offset execeeding the buffer range - // for example, consider str.len=4, i = 3, then the last char returns char_size 2, then - // the str.ptr + offset would exceed the buffer range + // for example, consider str.size=4, i = 3, then the last char returns char_size 2, then + // the str.data + offset would exceed the buffer range size_t offset = i + char_size; - if (offset > str.len) { - offset = str.len; + if (offset > str.size) { + offset = str.size; } - std::copy(str.ptr + i, str.ptr + offset, dst.ptr + str.len - offset); + std::copy(str.data + i, str.data + offset, dst_data + str.size - offset); } } } diff --git a/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.h b/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.h index ae3ba2a0ea..79a8c23e34 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.h +++ b/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.h @@ -85,8 +85,8 @@ public: HashUtil::murmur_hash64A((char*)&value, sizeof(value), HashUtil::MURMUR_SEED)); } else { auto value = static_cast<const ColumnDataType*>(columns[0])->get_data_at(row_num); - StringVal sv = value.to_string_val(); - uint64_t hash_value = HashUtil::murmur_hash64A(sv.ptr, sv.len, HashUtil::MURMUR_SEED); + uint64_t hash_value = + HashUtil::murmur_hash64A(value.data, value.size, HashUtil::MURMUR_SEED); this->data(place).add(hash_value); } } diff --git a/be/src/vec/aggregate_functions/aggregate_function_percentile_approx.h b/be/src/vec/aggregate_functions/aggregate_function_percentile_approx.h index 007dccbfac..c07cd3e2f3 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_percentile_approx.h +++ b/be/src/vec/aggregate_functions/aggregate_function_percentile_approx.h @@ -339,15 +339,12 @@ struct PercentileState { inited_flag = false; } - double get() const { - auto result = vec_counts[0].terminate(vec_quantile[0]); //DoubleVal - return result.val; - } + double get() const { return vec_counts[0].terminate(vec_quantile[0]); } void insert_result_into(IColumn& to) const { auto& column_data = static_cast<ColumnVector<Float64>&>(to).get_data(); for (int i = 0; i < vec_counts.size(); ++i) { - column_data.push_back(vec_counts[i].terminate(vec_quantile[i]).val); + column_data.push_back(vec_counts[i].terminate(vec_quantile[i])); } } }; diff --git a/be/src/vec/common/string_ref.h b/be/src/vec/common/string_ref.h index 158d7ed5de..7561b33c3c 100644 --- a/be/src/vec/common/string_ref.h +++ b/be/src/vec/common/string_ref.h @@ -29,7 +29,6 @@ #include "gutil/hash/city.h" #include "gutil/hash/hash128to64.h" -#include "udf/udf.h" #include "util/cpu_info.h" #include "util/hash_util.hpp" #include "util/slice.h" @@ -207,11 +206,8 @@ struct StringRef { : StringRef(reinterpret_cast<const char*>(data_), size_) {} StringRef(const std::string& s) : data(s.data()), size(s.size()) {} - StringRef(const StringVal& src) : StringRef(src.ptr, src.len) {} explicit StringRef(const char* str) : data(str), size(strlen(str)) {} - static StringRef from_string_val(const StringVal& src) { return StringRef(src); } - std::string to_string() const { return std::string(data, size); } std::string debug_string() const { return to_string(); } std::string_view to_string_view() const { return std::string_view(data, size); } @@ -220,15 +216,6 @@ struct StringRef { // this is just for show, e.g. print data to error log, to avoid print large string. std::string to_prefix(size_t length) const { return std::string(data, std::min(length, size)); } - // TODO: this function is dangerous! - StringVal to_string_val() const { - return StringVal(reinterpret_cast<uint8_t*>(const_cast<char*>(data)), size); - } - - void to_string_val(StringVal* sv) const { - *sv = StringVal(reinterpret_cast<uint8_t*>(const_cast<char*>(data)), size); - } - explicit operator std::string() const { return to_string(); } operator std::string_view() const { return std::string_view {data, size}; } diff --git a/be/src/vec/exec/scan/new_olap_scan_node.cpp b/be/src/vec/exec/scan/new_olap_scan_node.cpp index 7367ab3fea..d32224ee11 100644 --- a/be/src/vec/exec/scan/new_olap_scan_node.cpp +++ b/be/src/vec/exec/scan/new_olap_scan_node.cpp @@ -299,7 +299,7 @@ Status NewOlapScanNode::_build_key_ranges_and_filters() { Status NewOlapScanNode::_should_push_down_function_filter(VectorizedFnCall* fn_call, VExprContext* expr_ctx, - StringVal* constant_str, + StringRef* constant_str, doris::FunctionContext** fn_ctx, VScanNode::PushDownType& pdt) { // Now only `like` function filters is supported to push down @@ -327,7 +327,7 @@ Status NewOlapScanNode::_should_push_down_function_filter(VectorizedFnCall* fn_c RETURN_IF_ERROR(children[1 - i]->get_const_col(expr_ctx, &const_col_wrapper)); if (const ColumnConst* const_column = check_and_get_column<ColumnConst>(const_col_wrapper->column_ptr)) { - *constant_str = const_column->get_data_at(0).to_string_val(); + *constant_str = const_column->get_data_at(0); } else { pdt = PushDownType::UNACCEPTABLE; return Status::OK(); diff --git a/be/src/vec/exec/scan/new_olap_scan_node.h b/be/src/vec/exec/scan/new_olap_scan_node.h index 9ec95e6d0a..29d4220a17 100644 --- a/be/src/vec/exec/scan/new_olap_scan_node.h +++ b/be/src/vec/exec/scan/new_olap_scan_node.h @@ -45,7 +45,7 @@ protected: bool _is_key_column(const std::string& col_name) override; Status _should_push_down_function_filter(VectorizedFnCall* fn_call, VExprContext* expr_ctx, - StringVal* constant_str, + StringRef* constant_str, doris::FunctionContext** fn_ctx, PushDownType& pdt) override; diff --git a/be/src/vec/exec/scan/vscan_node.cpp b/be/src/vec/exec/scan/vscan_node.cpp index 27edacfb4c..6093c6314d 100644 --- a/be/src/vec/exec/scan/vscan_node.cpp +++ b/be/src/vec/exec/scan/vscan_node.cpp @@ -639,7 +639,7 @@ Status VScanNode::_normalize_function_filters(VExpr* expr, VExprContext* expr_ct if (TExprNodeType::FUNCTION_CALL == fn_expr->node_type()) { doris::FunctionContext* fn_ctx = nullptr; - StringVal val; + StringRef val; PushDownType temp_pdt; RETURN_IF_ERROR(_should_push_down_function_filter( reinterpret_cast<VectorizedFnCall*>(fn_expr), expr_ctx, &val, &fn_ctx, temp_pdt)); diff --git a/be/src/vec/exec/scan/vscan_node.h b/be/src/vec/exec/scan/vscan_node.h index 4fb023a5dc..2d6e287af0 100644 --- a/be/src/vec/exec/scan/vscan_node.h +++ b/be/src/vec/exec/scan/vscan_node.h @@ -157,7 +157,7 @@ protected: virtual Status _should_push_down_function_filter(VectorizedFnCall* fn_call, VExprContext* expr_ctx, - StringVal* constant_str, + StringRef* constant_str, doris::FunctionContext** fn_ctx, PushDownType& pdt) { pdt = PushDownType::UNACCEPTABLE; diff --git a/be/src/vec/functions/function_bitmap_min_or_max.h b/be/src/vec/functions/function_bitmap_min_or_max.h index 3675d5db59..7b6d738f0c 100644 --- a/be/src/vec/functions/function_bitmap_min_or_max.h +++ b/be/src/vec/functions/function_bitmap_min_or_max.h @@ -26,12 +26,12 @@ namespace doris::vectorized { struct FunctionBitmapMinImpl { static constexpr auto name = "bitmap_min"; - static Int64 calculate(const BitmapValue& value) { return value.minimum().val; } + static Int64 calculate(const BitmapValue& value) { return value.minimum(); } }; struct FunctionBitmapMaxImpl { static constexpr auto name = "bitmap_max"; - static Int64 calculate(const BitmapValue& value) { return value.maximum().val; } + static Int64 calculate(const BitmapValue& value) { return value.maximum(); } }; template <typename Impl> diff --git a/be/src/vec/functions/function_conv.cpp b/be/src/vec/functions/function_conv.cpp index 2c5742a1ac..d1c2120e4d 100644 --- a/be/src/vec/functions/function_conv.cpp +++ b/be/src/vec/functions/function_conv.cpp @@ -128,8 +128,8 @@ struct ConvInt64Impl { StringParser::PARSE_OVERFLOW); } } - StringVal str = MathFunctions::decimal_to_base(context, decimal_num, dst_base); - result_column->insert_data(reinterpret_cast<const char*>(str.ptr), str.len); + StringRef str = MathFunctions::decimal_to_base(context, decimal_num, dst_base); + result_column->insert_data(reinterpret_cast<const char*>(str.data), str.size); } }; @@ -153,8 +153,8 @@ struct ConvStringImpl { if (!MathFunctions::handle_parse_result(dst_base, &decimal_num, parse_res)) { result_column->insert_data("0", 1); } else { - StringVal str = MathFunctions::decimal_to_base(context, decimal_num, dst_base); - result_column->insert_data(reinterpret_cast<const char*>(str.ptr), str.len); + StringRef str = MathFunctions::decimal_to_base(context, decimal_num, dst_base); + result_column->insert_data(reinterpret_cast<const char*>(str.data), str.size); } } }; diff --git a/be/src/vec/functions/function_regexp.cpp b/be/src/vec/functions/function_regexp.cpp index 87941a9c11..11e5d2f992 100644 --- a/be/src/vec/functions/function_regexp.cpp +++ b/be/src/vec/functions/function_regexp.cpp @@ -50,9 +50,9 @@ struct RegexpReplaceImpl { std::unique_ptr<re2::RE2> scoped_re; // destroys re if state->re is nullptr if (re == nullptr) { std::string error_str; - const auto& pattern = pattern_col->get_data_at(i).to_string_val(); - bool st = StringFunctions::compile_regex(pattern, &error_str, StringVal::null(), - scoped_re); + const auto& pattern = pattern_col->get_data_at(i); + bool st = + StringFunctions::compile_regex(pattern, &error_str, StringRef(), scoped_re); if (!st) { context->add_warning(error_str.c_str()); StringOP::push_null_string(i, result_data, result_offset, null_map); @@ -94,9 +94,9 @@ struct RegexpReplaceOneImpl { std::unique_ptr<re2::RE2> scoped_re; // destroys re if state->re is nullptr if (re == nullptr) { std::string error_str; - const auto& pattern = pattern_col->get_data_at(i).to_string_val(); - bool st = StringFunctions::compile_regex(pattern, &error_str, StringVal::null(), - scoped_re); + const auto& pattern = pattern_col->get_data_at(i); + bool st = + StringFunctions::compile_regex(pattern, &error_str, StringRef(), scoped_re); if (!st) { context->add_warning(error_str.c_str()); StringOP::push_null_string(i, result_data, result_offset, null_map); @@ -143,9 +143,9 @@ struct RegexpExtractImpl { std::unique_ptr<re2::RE2> scoped_re; if (re == nullptr) { std::string error_str; - const auto& pattern = pattern_col->get_data_at(i).to_string_val(); - bool st = StringFunctions::compile_regex(pattern, &error_str, StringVal::null(), - scoped_re); + const auto& pattern = pattern_col->get_data_at(i); + bool st = + StringFunctions::compile_regex(pattern, &error_str, StringRef(), scoped_re); if (!st) { context->add_warning(error_str.c_str()); StringOP::push_null_string(i, result_data, result_offset, null_map); @@ -198,9 +198,9 @@ struct RegexpExtractAllImpl { std::unique_ptr<re2::RE2> scoped_re; if (re == nullptr) { std::string error_str; - const auto& pattern = pattern_col->get_data_at(i).to_string_val(); - bool st = StringFunctions::compile_regex(pattern, &error_str, StringVal::null(), - scoped_re); + const auto& pattern = pattern_col->get_data_at(i); + bool st = + StringFunctions::compile_regex(pattern, &error_str, StringRef(), scoped_re); if (!st) { context->add_warning(error_str.c_str()); StringOP::push_null_string(i, result_data, result_offset, null_map); @@ -280,15 +280,15 @@ public: if (context->is_col_constant(1)) { DCHECK(!context->get_function_state(scope)); const auto pattern_col = context->get_constant_col(1)->column_ptr; - const auto& pattern = pattern_col->get_data_at(0).to_string_val(); - if (pattern.is_null) { + const auto& pattern = pattern_col->get_data_at(0); + if (pattern.size == 0) { return Status::OK(); } std::string error_str; std::unique_ptr<re2::RE2> scoped_re; - bool st = StringFunctions::compile_regex(pattern, &error_str, StringVal::null(), - scoped_re); + bool st = + StringFunctions::compile_regex(pattern, &error_str, StringRef(), scoped_re); if (!st) { context->set_error(error_str.c_str()); return Status::InvalidArgument(error_str); diff --git a/be/src/vec/functions/function_string.cpp b/be/src/vec/functions/function_string.cpp index 660dce0551..8952ff73da 100644 --- a/be/src/vec/functions/function_string.cpp +++ b/be/src/vec/functions/function_string.cpp @@ -328,14 +328,14 @@ struct TrimImpl { for (size_t i = 0; i < offset_size; ++i) { const char* raw_str = reinterpret_cast<const char*>(&data[offsets[i - 1]]); ColumnString::Offset size = offsets[i] - offsets[i - 1]; - StringVal str(raw_str, size); + StringRef str(raw_str, size); if constexpr (is_ltrim) { str = simd::VStringFunctions::ltrim(str); } if constexpr (is_rtrim) { str = simd::VStringFunctions::rtrim(str); } - StringOP::push_value_string(std::string_view((char*)str.ptr, str.len), i, res_data, + StringOP::push_value_string(std::string_view((char*)str.data, str.size), i, res_data, res_offsets); } return Status::OK(); diff --git a/be/src/vec/functions/function_string.h b/be/src/vec/functions/function_string.h index f9f624880c..fcd2b9ea41 100644 --- a/be/src/vec/functions/function_string.h +++ b/be/src/vec/functions/function_string.h @@ -78,10 +78,10 @@ inline size_t get_char_len(const std::string_view& str, std::vector<size_t>* str return char_len; } -inline size_t get_char_len(const StringVal& str, std::vector<size_t>* str_index) { +inline size_t get_char_len(const StringRef& str, std::vector<size_t>* str_index) { size_t char_len = 0; - for (size_t i = 0, char_size = 0; i < str.len; i += char_size) { - char_size = UTF8_BYTE_LENGTH[(unsigned char)(str.ptr)[i]]; + for (size_t i = 0, char_size = 0; i < str.size; i += char_size) { + char_size = UTF8_BYTE_LENGTH[(unsigned char)(str.data)[i]]; str_index->push_back(i); ++char_len; } @@ -215,7 +215,7 @@ private: } if (byte_pos <= str_size && fixed_len > 0) { - // return StringVal(str.ptr + byte_pos, fixed_len); + // return StringRef(str.data + byte_pos, fixed_len); StringOP::push_value_string( std::string_view {reinterpret_cast<const char*>(raw_str + byte_pos), (size_t)fixed_len}, @@ -1258,7 +1258,7 @@ public: pad_byte_len = pad_times * pad_len; pad_byte_len += pad_index[pad_remainder]; int32_t byte_len = str_len + pad_byte_len; - // StringVal result(context, byte_len); + // StringRef result(context, byte_len); if constexpr (Impl::is_lpad) { int pad_idx = 0; int result_index = 0; @@ -2020,38 +2020,40 @@ public: namespace MoneyFormat { template <typename T, size_t N> -static StringVal do_money_format(FunctionContext* context, const T int_value, +static StringRef do_money_format(FunctionContext* context, const T int_value, const int32_t frac_value = 0) { char local[N]; char* p = SimpleItoaWithCommas(int_value, local, sizeof(local)); int32_t string_val_len = local + sizeof(local) - p + 3; - StringVal result = context->create_temp_string_val(string_val_len); - memcpy(result.ptr, p, string_val_len - 3); - *(result.ptr + string_val_len - 3) = '.'; - *(result.ptr + string_val_len - 2) = '0' + (frac_value / 10); - *(result.ptr + string_val_len - 1) = '0' + (frac_value % 10); + StringRef result = context->create_temp_string_val(string_val_len); + char* result_data = const_cast<char*>(result.data); + memcpy(result_data, p, string_val_len - 3); + *(result_data + string_val_len - 3) = '.'; + *(result_data + string_val_len - 2) = '0' + (frac_value / 10); + *(result_data + string_val_len - 1) = '0' + (frac_value % 10); return result; }; // Note string value must be valid decimal string which contains two digits after the decimal point -static StringVal do_money_format(FunctionContext* context, const string& value) { +static StringRef do_money_format(FunctionContext* context, const string& value) { bool is_positive = (value[0] != '-'); int32_t result_len = value.size() + (value.size() - (is_positive ? 4 : 5)) / 3; - StringVal result = context->create_temp_string_val(result_len); + StringRef result = context->create_temp_string_val(result_len); + char* result_data = const_cast<char*>(result.data); if (!is_positive) { - *result.ptr = '-'; + *result_data = '-'; } for (int i = value.size() - 4, j = result_len - 4; i >= 0; i = i - 3, j = j - 4) { - *(result.ptr + j) = *(value.data() + i); + *(result_data + j) = *(value.data() + i); if (i - 1 < 0) break; - *(result.ptr + j - 1) = *(value.data() + i - 1); + *(result_data + j - 1) = *(value.data() + i - 1); if (i - 2 < 0) break; - *(result.ptr + j - 2) = *(value.data() + i - 2); + *(result_data + j - 2) = *(value.data() + i - 2); if (j - 3 > 1 || (j - 3 == 1 && is_positive)) { - *(result.ptr + j - 3) = ','; + *(result_data + j - 3) = ','; } } - memcpy(result.ptr + result_len - 3, value.data() + value.size() - 3, 3); + memcpy(result_data + result_len - 3, value.data() + value.size() - 3, 3); return result; }; @@ -2065,8 +2067,8 @@ struct MoneyFormatDoubleImpl { for (size_t i = 0; i < input_rows_count; i++) { double value = MathFunctions::my_double_round(data_column->get_element(i), 2, false, false); - StringVal str = MoneyFormat::do_money_format(context, fmt::format("{:.2f}", value)); - result_column->insert_data(reinterpret_cast<const char*>(str.ptr), str.len); + StringRef str = MoneyFormat::do_money_format(context, fmt::format("{:.2f}", value)); + result_column->insert_data(str.data, str.size); } } }; @@ -2079,8 +2081,8 @@ struct MoneyFormatInt64Impl { const auto* data_column = assert_cast<const ColumnVector<Int64>*>(col_ptr.get()); for (size_t i = 0; i < input_rows_count; i++) { Int64 value = data_column->get_element(i); - StringVal str = MoneyFormat::do_money_format<Int64, 26>(context, value); - result_column->insert_data(reinterpret_cast<const char*>(str.ptr), str.len); + StringRef str = MoneyFormat::do_money_format<Int64, 26>(context, value); + result_column->insert_data(str.data, str.size); } } }; @@ -2093,8 +2095,8 @@ struct MoneyFormatInt128Impl { const auto* data_column = assert_cast<const ColumnVector<Int128>*>(col_ptr.get()); for (size_t i = 0; i < input_rows_count; i++) { Int128 value = data_column->get_element(i); - StringVal str = MoneyFormat::do_money_format<Int128, 52>(context, value); - result_column->insert_data(reinterpret_cast<const char*>(str.ptr), str.len); + StringRef str = MoneyFormat::do_money_format<Int128, 52>(context, value); + result_column->insert_data(str.data, str.size); } } }; @@ -2108,15 +2110,15 @@ struct MoneyFormatDecimalImpl { size_t input_rows_count) { if (auto* decimalv2_column = check_and_get_column<ColumnDecimal<Decimal128>>(*col_ptr)) { for (size_t i = 0; i < input_rows_count; i++) { - DecimalV2Val value = DecimalV2Val(decimalv2_column->get_element(i)); + DecimalV2Value value = DecimalV2Value(decimalv2_column->get_element(i)); DecimalV2Value rounded(0); - DecimalV2Value::from_decimal_val(value).round(&rounded, 2, HALF_UP); + value.round(&rounded, 2, HALF_UP); - StringVal str = MoneyFormat::do_money_format<int64_t, 26>( + StringRef str = MoneyFormat::do_money_format<int64_t, 26>( context, rounded.int_value(), abs(rounded.frac_value() / 10000000)); - result_column->insert_data(reinterpret_cast<const char*>(str.ptr), str.len); + result_column->insert_data(str.data, str.size); } } else if (auto* decimal32_column = check_and_get_column<ColumnDecimal<Decimal32>>(*col_ptr)) { @@ -2132,10 +2134,10 @@ struct MoneyFormatDecimalImpl { frac_part = frac_part * multiplier; } - StringVal str = MoneyFormat::do_money_format<int64_t, 26>( + StringRef str = MoneyFormat::do_money_format<int64_t, 26>( context, decimal32_column->get_whole_part(i), frac_part); - result_column->insert_data(reinterpret_cast<const char*>(str.ptr), str.len); + result_column->insert_data(str.data, str.size); } } else if (auto* decimal64_column = check_and_get_column<ColumnDecimal<Decimal64>>(*col_ptr)) { @@ -2151,10 +2153,10 @@ struct MoneyFormatDecimalImpl { frac_part = frac_part * multiplier; } - StringVal str = MoneyFormat::do_money_format<int64_t, 26>( + StringRef str = MoneyFormat::do_money_format<int64_t, 26>( context, decimal64_column->get_whole_part(i), frac_part); - result_column->insert_data(reinterpret_cast<const char*>(str.ptr), str.len); + result_column->insert_data(str.data, str.size); } } else if (auto* decimal128_column = check_and_get_column<ColumnDecimal<Decimal128I>>(*col_ptr)) { @@ -2170,10 +2172,10 @@ struct MoneyFormatDecimalImpl { frac_part = frac_part * multiplier; } - StringVal str = MoneyFormat::do_money_format<int64_t, 26>( + StringRef str = MoneyFormat::do_money_format<int64_t, 26>( context, decimal128_column->get_whole_part(i), frac_part); - result_column->insert_data(reinterpret_cast<const char*>(str.ptr), str.len); + result_column->insert_data(str.data, str.size); } } } @@ -2215,8 +2217,8 @@ public: vec_res.resize(input_rows_count); for (int i = 0; i < input_rows_count; ++i) { - vec_res[i] = locate_pos(col_substr->get_data_at(i).to_string_val(), - col_str->get_data_at(i).to_string_val(), vec_pos[i]); + vec_res[i] = + locate_pos(col_substr->get_data_at(i), col_str->get_data_at(i), vec_pos[i]); } block.replace_by_position(result, std::move(col_res)); @@ -2224,13 +2226,13 @@ public: } private: - int locate_pos(StringVal substr, StringVal str, int start_pos) { - if (substr.len == 0) { + int locate_pos(StringRef substr, StringRef str, int start_pos) { + if (substr.size == 0) { if (start_pos <= 0) { return 0; } else if (start_pos == 1) { return 1; - } else if (start_pos > str.len) { + } else if (start_pos > str.size) { return 0; } else { return start_pos; @@ -2241,14 +2243,13 @@ private: // Since returning 0 seems to be Hive's error condition, return 0. std::vector<size_t> index; size_t char_len = get_char_len(str, &index); - if (start_pos <= 0 || start_pos > str.len || start_pos > char_len) { + if (start_pos <= 0 || start_pos > str.size || start_pos > char_len) { return 0; } StringRef substr_sv = StringRef(substr); StringSearch search(&substr_sv); // Input start_pos starts from 1. - StringRef adjusted_str(reinterpret_cast<char*>(str.ptr) + index[start_pos - 1], - str.len - index[start_pos - 1]); + StringRef adjusted_str(str.data + index[start_pos - 1], str.size - index[start_pos - 1]); int32_t match_pos = search.search(&adjusted_str); if (match_pos >= 0) { // Hive returns the position in the original string starting from 1. @@ -2330,8 +2331,8 @@ struct ReverseImpl { int64_t src_len = offsets[i] - offsets[i - 1]; string dst; dst.resize(src_len); - simd::VStringFunctions::reverse(StringVal((uint8_t*)src_str, src_len), - StringVal((uint8_t*)dst.data(), src_len)); + simd::VStringFunctions::reverse(StringRef((uint8_t*)src_str, src_len), + StringRef((uint8_t*)dst.data(), src_len)); StringOP::push_value_string(std::string_view(dst.data(), src_len), i, res_data, res_offsets); } diff --git a/be/src/vec/olap/block_reader.cpp b/be/src/vec/olap/block_reader.cpp index 6db2d3cebe..a30abe2650 100644 --- a/be/src/vec/olap/block_reader.cpp +++ b/be/src/vec/olap/block_reader.cpp @@ -453,8 +453,8 @@ ColumnPredicate* BlockReader::_parse_to_predicate(const FunctionFilter& function } // currently only support like predicate - return new LikeColumnPredicate<true>(function_filter._opposite, index, function_filter._fn_ctx, - function_filter._string_param); + return new LikeColumnPredicate(function_filter._opposite, index, function_filter._fn_ctx, + function_filter._string_param); } } // namespace doris::vectorized diff --git a/be/src/vec/runtime/vdatetime_value.h b/be/src/vec/runtime/vdatetime_value.h index 4060bae8cb..a6f777536e 100644 --- a/be/src/vec/runtime/vdatetime_value.h +++ b/be/src/vec/runtime/vdatetime_value.h @@ -1095,13 +1095,6 @@ public: bool get_date_from_daynr(uint64_t); - static DateV2Value<DateTimeV2ValueType> from_datetimev2_val(const doris::DateTimeV2Val& tv) { - DCHECK(is_datetime); - DateV2Value<DateTimeV2ValueType> value; - value.from_datetime(tv.datetimev2_value); - return value; - } - template <TimeUnit unit> void set_time_unit(uint32_t val) { if constexpr (unit == TimeUnit::YEAR) { diff --git a/be/src/vec/runtime/vorc_writer.cpp b/be/src/vec/runtime/vorc_writer.cpp index 3d181b0526..3ea250a65c 100644 --- a/be/src/vec/runtime/vorc_writer.cpp +++ b/be/src/vec/runtime/vorc_writer.cpp @@ -158,13 +158,13 @@ void VOrcWriterWrapper::close() { cur_batch->notNull[row_id] = 1; \ int len = binary_cast<FROM, TO>( \ assert_cast<const ColumnVector<FROM>&>(*col).get_data()[row_id]) \ - .to_buffer((char*)buffer.ptr); \ - while (buffer.len < offset + len) { \ - char* new_ptr = (char*)malloc(buffer.len + BUFFER_UNIT_SIZE); \ - memcpy(new_ptr, buffer.ptr, buffer.len); \ - free(buffer.ptr); \ - buffer.ptr = (uint8_t*)new_ptr; \ - buffer.len = buffer.len + BUFFER_UNIT_SIZE; \ + .to_buffer(const_cast<char*>(buffer.data)); \ + while (buffer.size < offset + len) { \ + char* new_ptr = (char*)malloc(buffer.size + BUFFER_UNIT_SIZE); \ + memcpy(new_ptr, buffer.data, buffer.size); \ + free(const_cast<char*>(buffer.data)); \ + buffer.data = new_ptr; \ + buffer.size = buffer.size + BUFFER_UNIT_SIZE; \ } \ cur_batch->length[row_id] = len; \ offset += len; \ @@ -175,7 +175,7 @@ void VOrcWriterWrapper::close() { if (null_data[row_id] != 0) { \ cur_batch->notNull[row_id] = 0; \ } else { \ - cur_batch->data[row_id] = (char*)buffer.ptr + offset; \ + cur_batch->data[row_id] = const_cast<char*>(buffer.data) + offset; \ offset += cur_batch->length[row_id]; \ } \ } \ @@ -183,20 +183,20 @@ void VOrcWriterWrapper::close() { check_and_get_column<const ColumnVector<FROM>>(col)) { \ for (size_t row_id = 0; row_id < sz; row_id++) { \ int len = binary_cast<FROM, TO>(not_null_column->get_data()[row_id]) \ - .to_buffer((char*)buffer.ptr); \ - while (buffer.len < offset + len) { \ - char* new_ptr = (char*)malloc(buffer.len + BUFFER_UNIT_SIZE); \ - memcpy(new_ptr, buffer.ptr, buffer.len); \ - free(buffer.ptr); \ - buffer.ptr = (uint8_t*)new_ptr; \ - buffer.len = buffer.len + BUFFER_UNIT_SIZE; \ + .to_buffer(const_cast<char*>(buffer.data)); \ + while (buffer.size < offset + len) { \ + char* new_ptr = (char*)malloc(buffer.size + BUFFER_UNIT_SIZE); \ + memcpy(new_ptr, buffer.data, buffer.size); \ + free(const_cast<char*>(buffer.data)); \ + buffer.data = new_ptr; \ + buffer.size = buffer.size + BUFFER_UNIT_SIZE; \ } \ cur_batch->length[row_id] = len; \ offset += len; \ } \ offset = 0; \ for (size_t row_id = 0; row_id < sz; row_id++) { \ - cur_batch->data[row_id] = (char*)buffer.ptr + offset; \ + cur_batch->data[row_id] = const_cast<char*>(buffer.data) + offset; \ offset += cur_batch->length[row_id]; \ } \ } else { \ @@ -258,7 +258,7 @@ Status VOrcWriterWrapper::write(const Block& block) { // Buffer used by date type char* ptr = (char*)malloc(BUFFER_UNIT_SIZE); - StringVal buffer(ptr, BUFFER_UNIT_SIZE); + StringRef buffer(ptr, BUFFER_UNIT_SIZE); size_t sz = block.rows(); auto row_batch = _create_row_batch(sz); @@ -347,13 +347,14 @@ Status VOrcWriterWrapper::write(const Block& block) { int len = binary_cast<UInt64, DateV2Value<DateTimeV2ValueType>>( assert_cast<const ColumnVector<UInt64>&>(*col) .get_data()[row_id]) - .to_buffer((char*)buffer.ptr, output_scale); - while (buffer.len < offset + len) { - char* new_ptr = (char*)malloc(buffer.len + BUFFER_UNIT_SIZE); - memcpy(new_ptr, buffer.ptr, buffer.len); - free(buffer.ptr); - buffer.ptr = (uint8_t*)new_ptr; - buffer.len = buffer.len + BUFFER_UNIT_SIZE; + .to_buffer(const_cast<char*>(buffer.data), + output_scale); + while (buffer.size < offset + len) { + char* new_ptr = (char*)malloc(buffer.size + BUFFER_UNIT_SIZE); + memcpy(new_ptr, buffer.data, buffer.size); + free(const_cast<char*>(buffer.data)); + buffer.data = new_ptr; + buffer.size = buffer.size + BUFFER_UNIT_SIZE; } cur_batch->length[row_id] = len; offset += len; @@ -364,7 +365,7 @@ Status VOrcWriterWrapper::write(const Block& block) { if (null_data[row_id] != 0) { cur_batch->notNull[row_id] = 0; } else { - cur_batch->data[row_id] = (char*)buffer.ptr + offset; + cur_batch->data[row_id] = const_cast<char*>(buffer.data) + offset; offset += cur_batch->length[row_id]; } } @@ -374,20 +375,20 @@ Status VOrcWriterWrapper::write(const Block& block) { int output_scale = _output_vexpr_ctxs[i]->root()->type().scale; int len = binary_cast<UInt64, DateV2Value<DateTimeV2ValueType>>( not_null_column->get_data()[row_id]) - .to_buffer((char*)buffer.ptr, output_scale); - while (buffer.len < offset + len) { - char* new_ptr = (char*)malloc(buffer.len + BUFFER_UNIT_SIZE); - memcpy(new_ptr, buffer.ptr, buffer.len); - free(buffer.ptr); - buffer.ptr = (uint8_t*)new_ptr; - buffer.len = buffer.len + BUFFER_UNIT_SIZE; + .to_buffer(const_cast<char*>(buffer.data), output_scale); + while (buffer.size < offset + len) { + char* new_ptr = (char*)malloc(buffer.size + BUFFER_UNIT_SIZE); + memcpy(new_ptr, buffer.data, buffer.size); + free(const_cast<char*>(buffer.data)); + buffer.data = new_ptr; + buffer.size = buffer.size + BUFFER_UNIT_SIZE; } cur_batch->length[row_id] = len; offset += len; } offset = 0; for (size_t row_id = 0; row_id < sz; row_id++) { - cur_batch->data[row_id] = (char*)buffer.ptr + offset; + cur_batch->data[row_id] = const_cast<char*>(buffer.data) + offset; offset += cur_batch->length[row_id]; } } else { @@ -508,7 +509,7 @@ Status VOrcWriterWrapper::write(const Block& block) { _writer->add(*row_batch); _cur_written_rows += sz; - free(buffer.ptr); + free(const_cast<char*>(buffer.data)); return Status::OK(); } diff --git a/be/test/util/counts_test.cpp b/be/test/util/counts_test.cpp index d4d9e5895a..c943d30998 100644 --- a/be/test/util/counts_test.cpp +++ b/be/test/util/counts_test.cpp @@ -39,16 +39,16 @@ TEST_F(TCountsTest, TotalTest) { counts.increment(19, 1); counts.increment(7, 2); - doris::DoubleVal result = counts.terminate(0.2); - EXPECT_EQ(1, result.val); + double result = counts.terminate(0.2); + EXPECT_EQ(1, result); uint8_t* writer = new uint8_t[counts.serialized_size()]; uint8_t* type_reader = writer; counts.serialize(writer); Counts other; other.unserialize(type_reader); - doris::DoubleVal result1 = other.terminate(0.2); - EXPECT_EQ(result.val, result1.val); + double result1 = other.terminate(0.2); + EXPECT_EQ(result, result1); Counts other1; other1.increment(1, 1); @@ -59,7 +59,7 @@ TEST_F(TCountsTest, TotalTest) { counts.merge(&other1); // 1 1 1 1 2 5 7 7 9 9 10 19 50 50 50 99 99 100 100 100 - EXPECT_EQ(counts.terminate(0.3).val, 6.4); + EXPECT_EQ(counts.terminate(0.3), 6.4); delete[] writer; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org