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


##########
be/src/pipeline/common/join_utils.h:
##########
@@ -109,4 +121,80 @@ struct JoinDataVariants {
     }
 };
 
+template <typename Method>
+void primary_to_direct_mapping(Method* context, const 
vectorized::ColumnRawPtrs& key_columns,
+                               const 
std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
+    using FieldType = typename Method::Base::Key;
+    FieldType max_key = std::numeric_limits<FieldType>::min();
+    FieldType min_key = std::numeric_limits<FieldType>::max();
+
+    size_t num_rows = key_columns[0]->size();
+    if (key_columns[0]->is_nullable()) {
+        const FieldType* input_keys =
+                (FieldType*)assert_cast<const 
vectorized::ColumnNullable*>(key_columns[0])
+                        ->get_nested_column_ptr()
+                        ->get_raw_data()
+                        .data;
+        const vectorized::NullMap& null_map =
+                assert_cast<const 
vectorized::ColumnNullable*>(key_columns[0])->get_null_map_data();
+        // skip first mocked row
+        for (size_t i = 1; i < num_rows; i++) {
+            if (null_map[i]) {
+                continue;
+            }
+            max_key = std::max(max_key, input_keys[i]);
+            min_key = std::min(min_key, input_keys[i]);
+        }
+    } else {
+        const FieldType* input_keys = 
(FieldType*)key_columns[0]->get_raw_data().data;
+        // skip first mocked row
+        for (size_t i = 1; i < num_rows; i++) {
+            max_key = std::max(max_key, input_keys[i]);
+            min_key = std::min(min_key, input_keys[i]);
+        }
+    }
+
+    constexpr auto MAX_MAPPING_RANGE = 1 << 23;
+    bool allow_direct_mapping = (max_key >= min_key && max_key - min_key < 
MAX_MAPPING_RANGE - 1);
+    if (allow_direct_mapping) {
+        for (const auto& variant_ptr : variant_ptrs) {
+            
variant_ptr->method_variant.emplace<DirectPrimaryTypeHashTableContext<FieldType>>(
+                    max_key, min_key);

Review Comment:
   reuse the max_key/min_key to build min/max runtime filter



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