liaoxin01 commented on code in PR #9582: URL: https://github.com/apache/incubator-doris/pull/9582#discussion_r881113467
########## be/src/vec/columns/column_decimal.cpp: ########## @@ -130,6 +131,38 @@ void ColumnDecimal<T>::insert_data(const char* src, size_t /*length*/) { data.emplace_back(tmp); } +template <typename T> +void ColumnDecimal<T>::insert_many_decimalv2_data(const char* data_ptr, size_t num) { + for (int i = 0; i < num; i++) { + const char* cur_ptr = data_ptr + sizeof(decimal12_t) * i; + int64_t int_value = *(int64_t*)(cur_ptr); + int32_t frac_value = *(int32_t*)(cur_ptr + sizeof(int64_t)); + if (config::enable_execution_decimalv3) { + bool is_negative = (int_value < 0 || frac_value < 0); + if (is_negative) { + int_value = std::abs(int_value); + frac_value = std::abs(frac_value); + } + frac_value /= (DecimalV2Value::ONE_BILLION / get_scale_multiplier()); + T value = T(int_value) * get_scale_multiplier() + T(frac_value); + if (is_negative) { + value = -value; + } + this->insert_data(reinterpret_cast<char*>(&value), 0); Review Comment: In this method, we can insert many decimal with same precision and scale. This method converts storage layer decimalv2 to decimalv3 for calculation. ########## be/src/vec/columns/column_decimal.cpp: ########## @@ -130,6 +131,38 @@ void ColumnDecimal<T>::insert_data(const char* src, size_t /*length*/) { data.emplace_back(tmp); } +template <typename T> +void ColumnDecimal<T>::insert_many_decimalv2_data(const char* data_ptr, size_t num) { + for (int i = 0; i < num; i++) { + const char* cur_ptr = data_ptr + sizeof(decimal12_t) * i; + int64_t int_value = *(int64_t*)(cur_ptr); + int32_t frac_value = *(int32_t*)(cur_ptr + sizeof(int64_t)); + if (config::enable_execution_decimalv3) { + bool is_negative = (int_value < 0 || frac_value < 0); + if (is_negative) { + int_value = std::abs(int_value); + frac_value = std::abs(frac_value); + } + frac_value /= (DecimalV2Value::ONE_BILLION / get_scale_multiplier()); + T value = T(int_value) * get_scale_multiplier() + T(frac_value); + if (is_negative) { + value = -value; + } + this->insert_data(reinterpret_cast<char*>(&value), 0); Review Comment: In this method, we can insert many decimal with same precision and scale. This method converts storage layer decimalv2 to decimalv3 for calculation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org