This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0-beta
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 0be67858585547eed3578b52c86f3b76a0e1f933
Author: Mryange <59914473+mrya...@users.noreply.github.com>
AuthorDate: Fri Jun 9 19:59:25 2023 +0800

     [performance](executor) remove repeated call within the loop in 
validate_column
---
 be/src/vec/sink/vtablet_sink.cpp | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/be/src/vec/sink/vtablet_sink.cpp b/be/src/vec/sink/vtablet_sink.cpp
index 7482cb18a2..1a60b7b71a 100644
--- a/be/src/vec/sink/vtablet_sink.cpp
+++ b/be/src/vec/sink/vtablet_sink.cpp
@@ -1689,7 +1689,8 @@ Status VOlapTableSink::_validate_column(RuntimeState* 
state, const TypeDescripto
         auto column_decimal = 
const_cast<vectorized::ColumnDecimal<vectorized::Decimal128>*>(
                 assert_cast<const 
vectorized::ColumnDecimal<vectorized::Decimal128>*>(
                         real_column_ptr.get()));
-
+        const auto& max_decimalv2 = _get_decimalv2_min_or_max<false>(type);
+        const auto& min_decimalv2 = _get_decimalv2_min_or_max<true>(type);
         for (size_t j = 0; j < column->size(); ++j) {
             auto row = rows ? (*rows)[j] : j;
             if (row == last_invalid_row) {
@@ -1710,8 +1711,6 @@ Status VOlapTableSink::_validate_column(RuntimeState* 
state, const TypeDescripto
                         invalid = true;
                     }
                 }
-                const auto& max_decimalv2 = 
_get_decimalv2_min_or_max<false>(type);
-                const auto& min_decimalv2 = 
_get_decimalv2_min_or_max<true>(type);
                 if (dec_val > max_decimalv2 || dec_val < min_decimalv2) {
                     fmt::format_to(error_msg, "{}", "decimal value is not 
valid for definition");
                     fmt::format_to(error_msg, ", value={}", 
dec_val.to_string());
@@ -1735,6 +1734,8 @@ Status VOlapTableSink::_validate_column(RuntimeState* 
state, const TypeDescripto
     auto column_decimal = 
const_cast<vectorized::ColumnDecimal<vectorized::ColumnDecimalType>*>(   \
             assert_cast<const 
vectorized::ColumnDecimal<vectorized::ColumnDecimalType>*>(          \
                     real_column_ptr.get()));                                   
                    \
+    const auto& max_decimal = 
_get_decimalv3_min_or_max<vectorized::DecimalType, false>(type);     \
+    const auto& min_decimal = 
_get_decimalv3_min_or_max<vectorized::DecimalType, true>(type);      \
     for (size_t j = 0; j < column->size(); ++j) {                              
                    \
         auto row = rows ? (*rows)[j] : j;                                      
                    \
         if (row == last_invalid_row) {                                         
                    \
@@ -1743,10 +1744,6 @@ Status VOlapTableSink::_validate_column(RuntimeState* 
state, const TypeDescripto
         if (need_to_validate(j, row)) {                                        
                    \
             auto dec_val = column_decimal->get_data()[j];                      
                    \
             bool invalid = false;                                              
                    \
-            const auto& max_decimal =                                          
                    \
-                    _get_decimalv3_min_or_max<vectorized::DecimalType, 
false>(type);               \
-            const auto& min_decimal =                                          
                    \
-                    _get_decimalv3_min_or_max<vectorized::DecimalType, 
true>(type);                \
             if (dec_val > max_decimal || dec_val < min_decimal) {              
                    \
                 fmt::format_to(error_msg, "{}", "decimal value is not valid 
for definition");      \
                 fmt::format_to(error_msg, ", value={}", dec_val);              
                    \


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to