yiguolei commented on code in PR #60587:
URL: https://github.com/apache/doris/pull/60587#discussion_r2844369470


##########
be/src/olap/rowset/segment_v2/zone_map_index.cpp:
##########
@@ -80,31 +105,83 @@ void TypedZoneMapIndexWriter<Type>::add_values(const void* 
values, size_t count)
                 }
             }
         }
-        if (min < unaligned_load<ValType>(_page_zone_map.min_value)) {
-            _field->type_info()->direct_copy_may_cut(_page_zone_map.min_value,
-                                                     reinterpret_cast<const 
void*>(&min));
+        if (!_page_zone_map.is_min_max_set() || min < 
_page_zone_map.min_value.get<Type>()) {
+            _direct_copy_may_cut(_page_zone_map.min_value.get<Type>(), min);
         }
-        if (max > unaligned_load<ValType>(_page_zone_map.max_value)) {
-            _field->type_info()->direct_copy_may_cut(_page_zone_map.max_value,
-                                                     reinterpret_cast<const 
void*>(&max));
+        if (!_page_zone_map.is_min_max_set() || max > 
_page_zone_map.max_value.get<Type>()) {
+            _direct_copy_may_cut(_page_zone_map.max_value.get<Type>(), max);
         }
     } else {
         auto [min, max] = std::minmax_element(vals, vals + count);
-        if (unaligned_load<ValType>(min) < 
unaligned_load<ValType>(_page_zone_map.min_value)) {
-            _field->type_info()->direct_copy_may_cut(_page_zone_map.min_value,
-                                                     reinterpret_cast<const 
void*>(min));
-        }
-        if (unaligned_load<ValType>(max) > 
unaligned_load<ValType>(_page_zone_map.max_value)) {
-            _field->type_info()->direct_copy_may_cut(_page_zone_map.max_value,
-                                                     reinterpret_cast<const 
void*>(max));
+        auto min_val = unaligned_load<ValType>(min);
+        auto max_val = unaligned_load<ValType>(max);
+        if constexpr (is_string_type(Type)) {
+            if (!_page_zone_map.is_min_max_set() ||
+                min_val < ValType(_page_zone_map.min_value.get<Type>())) {

Review Comment:
   这么写逻辑不一定对。 这个min_val 可能是当前string 很长,没有截断的,而page zonemap 中已经截断了,这两个比较可能没有可比性。
   正确的做法,我感觉是,
   1. 用_direct_copy_may_cut, 把input 都放到一个临时的field 里。
   2. 然后 直接比较field 的大小,这样底下这一堆不同类型的is_min_max_set 处理方式都就是一样的。



-- 
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