HappenLee commented on code in PR #30152:
URL: https://github.com/apache/doris/pull/30152#discussion_r1473940549


##########
be/src/exprs/minmax_predicate.h:
##########
@@ -48,104 +46,71 @@ class MinMaxNumFunc : public MinMaxFuncBase {
     MinMaxNumFunc() = default;
     ~MinMaxNumFunc() override = default;
 
-    void insert(const void* data) override {
-        if (data == nullptr) {
-            return;
-        }
-
-        T val_data = *reinterpret_cast<const T*>(data);
-
-        if constexpr (NeedMin) {
-            if (val_data < _min) {
-                _min = val_data;
-            }
-        }
-
-        if constexpr (NeedMax) {
-            if (val_data > _max) {
-                _max = val_data;
-            }
-        }
-    }
-
     void insert_fixed_len(const vectorized::ColumnPtr& column, size_t start) 
override {
         if (column->empty()) {
             return;
         }
         if (column->is_nullable()) {
             const auto* nullable = assert_cast<const 
vectorized::ColumnNullable*>(column.get());
-            const auto& col = nullable->get_nested_column();
-            const auto& nullmap =
-                    assert_cast<const 
vectorized::ColumnUInt8&>(nullable->get_null_map_column())
-                            .get_data();
-
-            if constexpr (std::is_same_v<T, StringRef>) {
-                const auto& column_string = assert_cast<const 
vectorized::ColumnString&>(col);
-                for (size_t i = start; i < column->size(); i++) {
-                    if (!nullmap[i]) {
-                        if constexpr (NeedMin) {
-                            _min = std::min(_min, 
column_string.get_data_at(i));
-                        }
-                        if constexpr (NeedMax) {
-                            _max = std::max(_max, 
column_string.get_data_at(i));
-                        }
-                    }
-                }
+            const auto& col = nullable->get_nested_column_ptr();
+            const auto& nullmap = nullable->get_null_map_data();
+            if (nullable->has_null()) {
+                update_batch(col, nullmap, start);
             } else {
-                const T* data = (T*)col.get_raw_data().data;
-                for (size_t i = start; i < column->size(); i++) {
-                    if (!nullmap[i]) {
-                        if constexpr (NeedMin) {
-                            _min = std::min(_min, *(data + i));
-                        }
-                        if constexpr (NeedMax) {
-                            _max = std::max(_max, *(data + i));
-                        }
-                    }
+                update_batch(col, start);
+            }
+        } else {
+            update_batch(column, start);
+        }
+    }
+
+    void update_batch(const vectorized::ColumnPtr& column, size_t start) {
+        if constexpr (std::is_same_v<T, StringRef>) {
+            const auto& column_string = assert_cast<const 
vectorized::ColumnString&>(*column);
+            for (size_t i = start; i < column->size(); i++) {
+                if constexpr (NeedMin) {
+                    _min = std::min(_min, column_string.get_data_at(i));
+                }
+                if constexpr (NeedMax) {
+                    _max = std::max(_max, column_string.get_data_at(i));
                 }
             }
         } else {
-            if constexpr (std::is_same_v<T, StringRef>) {
-                const auto& column_string = assert_cast<const 
vectorized::ColumnString&>(*column);
-                for (size_t i = start; i < column->size(); i++) {
-                    if constexpr (NeedMin) {
-                        _min = std::min(_min, column_string.get_data_at(i));
-                    }
-                    if constexpr (NeedMax) {
-                        _max = std::max(_max, column_string.get_data_at(i));
-                    }
+            const T* data = (T*)column->get_raw_data().data;
+            for (size_t i = start; i < column->size(); i++) {
+                if constexpr (NeedMin) {
+                    _min = std::min(_min, *(data + i));
                 }
-            } else {
-                const T* data = (T*)column->get_raw_data().data;
-                for (size_t i = start; i < column->size(); i++) {
-                    if constexpr (NeedMin) {
-                        _min = std::min(_min, *(data + i));
-                    }
-                    if constexpr (NeedMax) {
-                        _max = std::max(_max, *(data + i));
-                    }
+                if constexpr (NeedMax) {
+                    _max = std::max(_max, *(data + i));
                 }
             }
         }
     }
 
-    bool find(void* data) override {
-        if (data == nullptr) {
-            return false;
-        }
-
-        T val_data = *reinterpret_cast<T*>(data);
-        if constexpr (NeedMin) {
-            if (val_data < _min) {
-                return false;
+    void update_batch(const vectorized::ColumnPtr& column, const 
vectorized::NullMap& nullmap,

Review Comment:
   nullmap seems useless?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to