You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/10/14 08:40:43 UTC

[GitHub] [doris] HappenLee commented on a diff in pull request #13166: [Enhancement](scanner) support split avg key range

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


##########
be/src/exec/olap_common.h:
##########
@@ -550,6 +554,79 @@ void ColumnValueRange<primitive_type>::convert_to_fixed_value() {
     }
 }
 
+template <>
+bool ColumnValueRange<PrimitiveType::TYPE_STRING>::convert_to_avg_range_value(
+        std::vector<OlapTuple>& begin_scan_keys, std::vector<OlapTuple>& end_scan_keys,
+        size_t step_size);
+
+template <>
+bool ColumnValueRange<PrimitiveType::TYPE_CHAR>::convert_to_avg_range_value(
+        std::vector<OlapTuple>& begin_scan_keys, std::vector<OlapTuple>& end_scan_keys,
+        size_t step_size);
+
+template <>
+bool ColumnValueRange<PrimitiveType::TYPE_VARCHAR>::convert_to_avg_range_value(
+        std::vector<OlapTuple>& begin_scan_keys, std::vector<OlapTuple>& end_scan_keys,
+        size_t step_size);
+
+template <>
+bool ColumnValueRange<PrimitiveType::TYPE_HLL>::convert_to_avg_range_value(
+        std::vector<OlapTuple>& begin_scan_keys, std::vector<OlapTuple>& end_scan_keys,
+        size_t step_size);
+
+template <>
+bool ColumnValueRange<PrimitiveType::TYPE_DECIMALV2>::convert_to_avg_range_value(
+        std::vector<OlapTuple>& begin_scan_keys, std::vector<OlapTuple>& end_scan_keys,
+        size_t step_size);
+
+template <>
+bool ColumnValueRange<PrimitiveType::TYPE_LARGEINT>::convert_to_avg_range_value(
+        std::vector<OlapTuple>& begin_scan_keys, std::vector<OlapTuple>& end_scan_keys,
+        size_t step_size);
+
+template <PrimitiveType primitive_type>
+bool ColumnValueRange<primitive_type>::convert_to_avg_range_value(
+        std::vector<OlapTuple>& begin_scan_keys, std::vector<OlapTuple>& end_scan_keys,
+        size_t step_size) {
+    // Incrementing boolean is denied in C++17, So we use int as bool type
+    using type = std::conditional_t<std::is_same<bool, CppType>::value, int, CppType>;
+    type current = get_range_min_value();
+
+    constexpr bool cant_add = primitive_type == PrimitiveType::TYPE_DATEV2 ||

Review Comment:
   can_not_add ?



##########
be/src/exec/olap_common.cpp:
##########
@@ -59,6 +59,48 @@ void ColumnValueRange<PrimitiveType::TYPE_LARGEINT>::convert_to_fixed_value() {
     return;
 }
 
+template <>

Review Comment:
   maybe better use `#define` to do the thing? and do it in `.h` ?



##########
be/src/exec/olap_common.h:
##########
@@ -945,13 +1022,20 @@ Status OlapScanKeys::extend_scan_key(ColumnValueRange<primitive_type>& range,
         _has_range_value = true;
 
         if (_begin_scan_keys.empty()) {
-            _begin_scan_keys.emplace_back();
-            _begin_scan_keys.back().add_value(cast_to_string<primitive_type, CppType>(
-                                                      range.get_range_min_value(), range.scale()),
-                                              range.contain_null());
-            _end_scan_keys.emplace_back();
-            _end_scan_keys.back().add_value(cast_to_string<primitive_type, CppType>(
-                    range.get_range_max_value(), range.scale()));
+            size_t step_size =
+                    std::max((range.get_convertible_fixed_value_size() + max_scan_key_num - 1) /
+                                     max_scan_key_num,
+                             (size_t)1);

Review Comment:
   why do the cal `step_size` here, not in `convert_to_avg_range_value` and we only pass the para to `max_scan_key_num` replace `step_size` and only need to call function `range.get_convertible_fixed_value_size()` one time



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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