Coverage Report

Created: 2026-08-16 01:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/common/join_utils.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <algorithm>
21
#include <variant>
22
23
#include "exec/common/hash_table/hash_crc32_return32.h"
24
#include "exec/common/hash_table/hash_key_type.h"
25
#include "exec/common/hash_table/hash_map_context.h"
26
#include "exec/common/hash_table/join_hash_table.h"
27
#include "exec/common/join_op_utils.h" // IWYU pragma: export (JoinOpVariants/AsofIndexGroup moved there)
28
29
namespace doris {
30
31
// Devirtualize compare_at for ASOF JOIN supported column types.
32
// ASOF JOIN only supports DateV2, DateTimeV2, and TimestampTZ.
33
// Dispatches to the concrete ColumnVector<T> once so that all compare_at
34
// calls inside `func` are direct (non-virtual) calls.
35
// `func` receives a single argument: a const pointer to the concrete column
36
// (or const IColumn* as fallback for unexpected types).
37
template <typename Func>
38
4
decltype(auto) asof_column_dispatch(const IColumn* col, Func&& func) {
39
4
    if (const auto* c_dv2 = check_and_get_column<ColumnDateV2>(col)) {
40
1
        return std::forward<Func>(func)(c_dv2);
41
3
    } else if (const auto* c_dtv2 = check_and_get_column<ColumnDateTimeV2>(col)) {
42
1
        return std::forward<Func>(func)(c_dtv2);
43
2
    } else if (const auto* c_tstz = check_and_get_column<ColumnTimeStampTz>(col)) {
44
1
        return std::forward<Func>(func)(c_tstz);
45
1
    } else {
46
1
        return std::forward<Func>(func)(col);
47
1
    }
48
4
}
asof_join_test.cpp:_ZN5doris20asof_column_dispatchIZNS_42AsofColumnDispatchTest_DateV2Dispatch_Test8TestBodyEvE3$_0EEDcPKNS_7IColumnEOT_
Line
Count
Source
38
1
decltype(auto) asof_column_dispatch(const IColumn* col, Func&& func) {
39
1
    if (const auto* c_dv2 = check_and_get_column<ColumnDateV2>(col)) {
40
1
        return std::forward<Func>(func)(c_dv2);
41
1
    } else if (const auto* c_dtv2 = check_and_get_column<ColumnDateTimeV2>(col)) {
42
0
        return std::forward<Func>(func)(c_dtv2);
43
0
    } else if (const auto* c_tstz = check_and_get_column<ColumnTimeStampTz>(col)) {
44
0
        return std::forward<Func>(func)(c_tstz);
45
0
    } else {
46
0
        return std::forward<Func>(func)(col);
47
0
    }
48
1
}
asof_join_test.cpp:_ZN5doris20asof_column_dispatchIZNS_46AsofColumnDispatchTest_DateTimeV2Dispatch_Test8TestBodyEvE3$_0EEDcPKNS_7IColumnEOT_
Line
Count
Source
38
1
decltype(auto) asof_column_dispatch(const IColumn* col, Func&& func) {
39
1
    if (const auto* c_dv2 = check_and_get_column<ColumnDateV2>(col)) {
40
0
        return std::forward<Func>(func)(c_dv2);
41
1
    } else if (const auto* c_dtv2 = check_and_get_column<ColumnDateTimeV2>(col)) {
42
1
        return std::forward<Func>(func)(c_dtv2);
43
1
    } else if (const auto* c_tstz = check_and_get_column<ColumnTimeStampTz>(col)) {
44
0
        return std::forward<Func>(func)(c_tstz);
45
0
    } else {
46
0
        return std::forward<Func>(func)(col);
47
0
    }
48
1
}
asof_join_test.cpp:_ZN5doris20asof_column_dispatchIZNS_47AsofColumnDispatchTest_TimestampTZDispatch_Test8TestBodyEvE3$_0EEDcPKNS_7IColumnEOT_
Line
Count
Source
38
1
decltype(auto) asof_column_dispatch(const IColumn* col, Func&& func) {
39
1
    if (const auto* c_dv2 = check_and_get_column<ColumnDateV2>(col)) {
40
0
        return std::forward<Func>(func)(c_dv2);
41
1
    } else if (const auto* c_dtv2 = check_and_get_column<ColumnDateTimeV2>(col)) {
42
0
        return std::forward<Func>(func)(c_dtv2);
43
1
    } else if (const auto* c_tstz = check_and_get_column<ColumnTimeStampTz>(col)) {
44
1
        return std::forward<Func>(func)(c_tstz);
45
1
    } else {
46
0
        return std::forward<Func>(func)(col);
47
0
    }
48
1
}
asof_join_test.cpp:_ZN5doris20asof_column_dispatchIZNS_44AsofColumnDispatchTest_FallbackDispatch_Test8TestBodyEvE3$_0EEDcPKNS_7IColumnEOT_
Line
Count
Source
38
1
decltype(auto) asof_column_dispatch(const IColumn* col, Func&& func) {
39
1
    if (const auto* c_dv2 = check_and_get_column<ColumnDateV2>(col)) {
40
0
        return std::forward<Func>(func)(c_dv2);
41
1
    } else if (const auto* c_dtv2 = check_and_get_column<ColumnDateTimeV2>(col)) {
42
0
        return std::forward<Func>(func)(c_dtv2);
43
1
    } else if (const auto* c_tstz = check_and_get_column<ColumnTimeStampTz>(col)) {
44
0
        return std::forward<Func>(func)(c_tstz);
45
1
    } else {
46
1
        return std::forward<Func>(func)(col);
47
1
    }
48
1
}
Unexecuted instantiation: hashjoin_build_sink.cpp:_ZN5doris20asof_column_dispatchIZNS_27HashJoinBuildSinkLocalState16build_asof_indexERNS_5BlockEE3$_2EEDcPKNS_7IColumnEOT_
49
template <class T>
50
using PrimaryTypeHashTableContext = MethodOneNumber<T, JoinHashMap<T, HashCRC32Return32<T>, false>>;
51
52
template <class T>
53
using DirectPrimaryTypeHashTableContext =
54
        MethodOneNumberDirect<T, JoinHashMap<T, HashCRC32Return32<T>, true>>;
55
56
template <class Key>
57
using FixedKeyHashTableContext = MethodKeysFixed<JoinHashMap<Key, HashCRC32Return32<Key>, false>>;
58
59
using SerializedHashTableContext =
60
        MethodSerialized<JoinHashMap<StringRef, HashCRC32Return32<StringRef>, false>>;
61
using MethodOneString =
62
        MethodStringNoCache<JoinHashMap<StringRef, HashCRC32Return32<StringRef>, false>>;
63
64
using HashTableVariants = std::variant<
65
        std::monostate, SerializedHashTableContext, PrimaryTypeHashTableContext<UInt8>,
66
        PrimaryTypeHashTableContext<UInt16>, PrimaryTypeHashTableContext<UInt32>,
67
        PrimaryTypeHashTableContext<UInt64>, PrimaryTypeHashTableContext<UInt128>,
68
        PrimaryTypeHashTableContext<UInt256>, DirectPrimaryTypeHashTableContext<UInt8>,
69
        DirectPrimaryTypeHashTableContext<UInt16>, DirectPrimaryTypeHashTableContext<UInt32>,
70
        DirectPrimaryTypeHashTableContext<UInt64>, DirectPrimaryTypeHashTableContext<UInt128>,
71
        FixedKeyHashTableContext<UInt64>, FixedKeyHashTableContext<UInt72>,
72
        FixedKeyHashTableContext<UInt96>, FixedKeyHashTableContext<UInt104>,
73
        FixedKeyHashTableContext<UInt128>, FixedKeyHashTableContext<UInt136>,
74
        FixedKeyHashTableContext<UInt256>, MethodOneString>;
75
76
struct JoinDataVariants {
77
    HashTableVariants method_variant;
78
79
48.0k
    void init(const std::vector<DataTypePtr>& data_types, HashKeyType type) {
80
48.0k
        switch (type) {
81
14.1k
        case HashKeyType::serialized:
82
14.1k
            method_variant.emplace<SerializedHashTableContext>();
83
14.1k
            break;
84
160
        case HashKeyType::int8_key:
85
160
            method_variant.emplace<PrimaryTypeHashTableContext<UInt8>>();
86
160
            break;
87
80
        case HashKeyType::int16_key:
88
80
            method_variant.emplace<PrimaryTypeHashTableContext<UInt16>>();
89
80
            break;
90
324
        case HashKeyType::int32_key:
91
324
            method_variant.emplace<PrimaryTypeHashTableContext<UInt32>>();
92
324
            break;
93
800
        case HashKeyType::int64_key:
94
800
            method_variant.emplace<PrimaryTypeHashTableContext<UInt64>>();
95
800
            break;
96
240
        case HashKeyType::int128_key:
97
240
            method_variant.emplace<PrimaryTypeHashTableContext<UInt128>>();
98
240
            break;
99
0
        case HashKeyType::int256_key:
100
0
            method_variant.emplace<PrimaryTypeHashTableContext<UInt256>>();
101
0
            break;
102
324
        case HashKeyType::string_key:
103
324
            method_variant.emplace<MethodOneString>();
104
324
            break;
105
3.92k
        case HashKeyType::fixed64:
106
3.92k
            method_variant.emplace<FixedKeyHashTableContext<UInt64>>(get_key_sizes(data_types));
107
3.92k
            break;
108
3.20k
        case HashKeyType::fixed72:
109
3.20k
            method_variant.emplace<FixedKeyHashTableContext<UInt72>>(get_key_sizes(data_types));
110
3.20k
            break;
111
8.00k
        case HashKeyType::fixed96:
112
8.00k
            method_variant.emplace<FixedKeyHashTableContext<UInt96>>(get_key_sizes(data_types));
113
8.00k
            break;
114
0
        case HashKeyType::fixed104:
115
0
            method_variant.emplace<FixedKeyHashTableContext<UInt104>>(get_key_sizes(data_types));
116
0
            break;
117
8.00k
        case HashKeyType::fixed128:
118
8.00k
            method_variant.emplace<FixedKeyHashTableContext<UInt128>>(get_key_sizes(data_types));
119
8.00k
            break;
120
960
        case HashKeyType::fixed136:
121
960
            method_variant.emplace<FixedKeyHashTableContext<UInt136>>(get_key_sizes(data_types));
122
960
            break;
123
7.92k
        case HashKeyType::fixed256:
124
7.92k
            method_variant.emplace<FixedKeyHashTableContext<UInt256>>(get_key_sizes(data_types));
125
7.92k
            break;
126
0
        default:
127
0
            throw Exception(ErrorCode::INTERNAL_ERROR,
128
0
                            "JoinDataVariants meet invalid key type, type={}", type);
129
48.0k
        }
130
48.0k
    }
131
};
132
133
template <typename Method>
134
void primary_to_direct_mapping(Method* context, const ColumnRawPtrs& key_columns,
135
1.60k
                               const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
136
1.60k
    using FieldType = typename Method::Base::Key;
137
1.60k
    FieldType max_key = std::numeric_limits<FieldType>::min();
138
1.60k
    FieldType min_key = std::numeric_limits<FieldType>::max();
139
140
1.60k
    size_t num_rows = key_columns[0]->size();
141
1.60k
    if (is_column_nullable(*key_columns[0])) {
142
0
        const FieldType* input_keys = (FieldType*)assert_cast<const ColumnNullable*>(key_columns[0])
143
0
                                              ->get_nested_column_ptr()
144
0
                                              ->get_raw_data()
145
0
                                              .data;
146
0
        const NullMap& null_map =
147
0
                assert_cast<const ColumnNullable*>(key_columns[0])->get_null_map_data();
148
        // skip first mocked row
149
0
        for (size_t i = 1; i < num_rows; i++) {
150
0
            if (null_map[i]) {
151
0
                continue;
152
0
            }
153
0
            max_key = std::max(max_key, input_keys[i]);
154
0
            min_key = std::min(min_key, input_keys[i]);
155
0
        }
156
1.60k
    } else {
157
1.60k
        const FieldType* input_keys = (FieldType*)key_columns[0]->get_raw_data().data;
158
        // skip first mocked row
159
4.83k
        for (size_t i = 1; i < num_rows; i++) {
160
3.22k
            max_key = std::max(max_key, input_keys[i]);
161
3.22k
            min_key = std::min(min_key, input_keys[i]);
162
3.22k
        }
163
1.60k
    }
164
165
1.60k
    constexpr auto MAX_MAPPING_RANGE = 1 << 23;
166
1.60k
    bool allow_direct_mapping = (max_key >= min_key && max_key - min_key < MAX_MAPPING_RANGE - 1);
167
1.60k
    if (allow_direct_mapping) {
168
1.60k
        for (const auto& variant_ptr : variant_ptrs) {
169
1.60k
            variant_ptr->method_variant.emplace<DirectPrimaryTypeHashTableContext<FieldType>>(
170
1.60k
                    max_key, min_key);
171
1.60k
        }
172
1.60k
    }
173
1.60k
}
_ZN5doris25primary_to_direct_mappingINS_15MethodOneNumberIhNS_13JoinHashTableIhNS_17HashCRC32Return32IhEELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISC_EERKS9_ISt10shared_ptrINS_16JoinDataVariantsEESaISJ_EE
Line
Count
Source
135
160
                               const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
136
160
    using FieldType = typename Method::Base::Key;
137
160
    FieldType max_key = std::numeric_limits<FieldType>::min();
138
160
    FieldType min_key = std::numeric_limits<FieldType>::max();
139
140
160
    size_t num_rows = key_columns[0]->size();
141
160
    if (is_column_nullable(*key_columns[0])) {
142
0
        const FieldType* input_keys = (FieldType*)assert_cast<const ColumnNullable*>(key_columns[0])
143
0
                                              ->get_nested_column_ptr()
144
0
                                              ->get_raw_data()
145
0
                                              .data;
146
0
        const NullMap& null_map =
147
0
                assert_cast<const ColumnNullable*>(key_columns[0])->get_null_map_data();
148
        // skip first mocked row
149
0
        for (size_t i = 1; i < num_rows; i++) {
150
0
            if (null_map[i]) {
151
0
                continue;
152
0
            }
153
0
            max_key = std::max(max_key, input_keys[i]);
154
0
            min_key = std::min(min_key, input_keys[i]);
155
0
        }
156
160
    } else {
157
160
        const FieldType* input_keys = (FieldType*)key_columns[0]->get_raw_data().data;
158
        // skip first mocked row
159
480
        for (size_t i = 1; i < num_rows; i++) {
160
320
            max_key = std::max(max_key, input_keys[i]);
161
320
            min_key = std::min(min_key, input_keys[i]);
162
320
        }
163
160
    }
164
165
160
    constexpr auto MAX_MAPPING_RANGE = 1 << 23;
166
160
    bool allow_direct_mapping = (max_key >= min_key && max_key - min_key < MAX_MAPPING_RANGE - 1);
167
160
    if (allow_direct_mapping) {
168
160
        for (const auto& variant_ptr : variant_ptrs) {
169
160
            variant_ptr->method_variant.emplace<DirectPrimaryTypeHashTableContext<FieldType>>(
170
160
                    max_key, min_key);
171
160
        }
172
160
    }
173
160
}
_ZN5doris25primary_to_direct_mappingINS_15MethodOneNumberItNS_13JoinHashTableItNS_17HashCRC32Return32ItEELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISC_EERKS9_ISt10shared_ptrINS_16JoinDataVariantsEESaISJ_EE
Line
Count
Source
135
80
                               const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
136
80
    using FieldType = typename Method::Base::Key;
137
80
    FieldType max_key = std::numeric_limits<FieldType>::min();
138
80
    FieldType min_key = std::numeric_limits<FieldType>::max();
139
140
80
    size_t num_rows = key_columns[0]->size();
141
80
    if (is_column_nullable(*key_columns[0])) {
142
0
        const FieldType* input_keys = (FieldType*)assert_cast<const ColumnNullable*>(key_columns[0])
143
0
                                              ->get_nested_column_ptr()
144
0
                                              ->get_raw_data()
145
0
                                              .data;
146
0
        const NullMap& null_map =
147
0
                assert_cast<const ColumnNullable*>(key_columns[0])->get_null_map_data();
148
        // skip first mocked row
149
0
        for (size_t i = 1; i < num_rows; i++) {
150
0
            if (null_map[i]) {
151
0
                continue;
152
0
            }
153
0
            max_key = std::max(max_key, input_keys[i]);
154
0
            min_key = std::min(min_key, input_keys[i]);
155
0
        }
156
80
    } else {
157
80
        const FieldType* input_keys = (FieldType*)key_columns[0]->get_raw_data().data;
158
        // skip first mocked row
159
240
        for (size_t i = 1; i < num_rows; i++) {
160
160
            max_key = std::max(max_key, input_keys[i]);
161
160
            min_key = std::min(min_key, input_keys[i]);
162
160
        }
163
80
    }
164
165
80
    constexpr auto MAX_MAPPING_RANGE = 1 << 23;
166
80
    bool allow_direct_mapping = (max_key >= min_key && max_key - min_key < MAX_MAPPING_RANGE - 1);
167
80
    if (allow_direct_mapping) {
168
80
        for (const auto& variant_ptr : variant_ptrs) {
169
80
            variant_ptr->method_variant.emplace<DirectPrimaryTypeHashTableContext<FieldType>>(
170
80
                    max_key, min_key);
171
80
        }
172
80
    }
173
80
}
_ZN5doris25primary_to_direct_mappingINS_15MethodOneNumberIjNS_13JoinHashTableIjNS_17HashCRC32Return32IjEELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISC_EERKS9_ISt10shared_ptrINS_16JoinDataVariantsEESaISJ_EE
Line
Count
Source
135
323
                               const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
136
323
    using FieldType = typename Method::Base::Key;
137
323
    FieldType max_key = std::numeric_limits<FieldType>::min();
138
323
    FieldType min_key = std::numeric_limits<FieldType>::max();
139
140
323
    size_t num_rows = key_columns[0]->size();
141
323
    if (is_column_nullable(*key_columns[0])) {
142
0
        const FieldType* input_keys = (FieldType*)assert_cast<const ColumnNullable*>(key_columns[0])
143
0
                                              ->get_nested_column_ptr()
144
0
                                              ->get_raw_data()
145
0
                                              .data;
146
0
        const NullMap& null_map =
147
0
                assert_cast<const ColumnNullable*>(key_columns[0])->get_null_map_data();
148
        // skip first mocked row
149
0
        for (size_t i = 1; i < num_rows; i++) {
150
0
            if (null_map[i]) {
151
0
                continue;
152
0
            }
153
0
            max_key = std::max(max_key, input_keys[i]);
154
0
            min_key = std::min(min_key, input_keys[i]);
155
0
        }
156
323
    } else {
157
323
        const FieldType* input_keys = (FieldType*)key_columns[0]->get_raw_data().data;
158
        // skip first mocked row
159
992
        for (size_t i = 1; i < num_rows; i++) {
160
669
            max_key = std::max(max_key, input_keys[i]);
161
669
            min_key = std::min(min_key, input_keys[i]);
162
669
        }
163
323
    }
164
165
323
    constexpr auto MAX_MAPPING_RANGE = 1 << 23;
166
323
    bool allow_direct_mapping = (max_key >= min_key && max_key - min_key < MAX_MAPPING_RANGE - 1);
167
323
    if (allow_direct_mapping) {
168
324
        for (const auto& variant_ptr : variant_ptrs) {
169
324
            variant_ptr->method_variant.emplace<DirectPrimaryTypeHashTableContext<FieldType>>(
170
324
                    max_key, min_key);
171
324
        }
172
323
    }
173
323
}
_ZN5doris25primary_to_direct_mappingINS_15MethodOneNumberImNS_13JoinHashTableImNS_17HashCRC32Return32ImEELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISC_EERKS9_ISt10shared_ptrINS_16JoinDataVariantsEESaISJ_EE
Line
Count
Source
135
800
                               const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
136
800
    using FieldType = typename Method::Base::Key;
137
800
    FieldType max_key = std::numeric_limits<FieldType>::min();
138
800
    FieldType min_key = std::numeric_limits<FieldType>::max();
139
140
800
    size_t num_rows = key_columns[0]->size();
141
800
    if (is_column_nullable(*key_columns[0])) {
142
0
        const FieldType* input_keys = (FieldType*)assert_cast<const ColumnNullable*>(key_columns[0])
143
0
                                              ->get_nested_column_ptr()
144
0
                                              ->get_raw_data()
145
0
                                              .data;
146
0
        const NullMap& null_map =
147
0
                assert_cast<const ColumnNullable*>(key_columns[0])->get_null_map_data();
148
        // skip first mocked row
149
0
        for (size_t i = 1; i < num_rows; i++) {
150
0
            if (null_map[i]) {
151
0
                continue;
152
0
            }
153
0
            max_key = std::max(max_key, input_keys[i]);
154
0
            min_key = std::min(min_key, input_keys[i]);
155
0
        }
156
800
    } else {
157
800
        const FieldType* input_keys = (FieldType*)key_columns[0]->get_raw_data().data;
158
        // skip first mocked row
159
2.40k
        for (size_t i = 1; i < num_rows; i++) {
160
1.60k
            max_key = std::max(max_key, input_keys[i]);
161
1.60k
            min_key = std::min(min_key, input_keys[i]);
162
1.60k
        }
163
800
    }
164
165
800
    constexpr auto MAX_MAPPING_RANGE = 1 << 23;
166
800
    bool allow_direct_mapping = (max_key >= min_key && max_key - min_key < MAX_MAPPING_RANGE - 1);
167
800
    if (allow_direct_mapping) {
168
800
        for (const auto& variant_ptr : variant_ptrs) {
169
800
            variant_ptr->method_variant.emplace<DirectPrimaryTypeHashTableContext<FieldType>>(
170
800
                    max_key, min_key);
171
800
        }
172
800
    }
173
800
}
_ZN5doris25primary_to_direct_mappingINS_15MethodOneNumberIN4wide7integerILm128EjEENS_13JoinHashTableIS4_NS_17HashCRC32Return32IS4_EELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISF_EERKSC_ISt10shared_ptrINS_16JoinDataVariantsEESaISM_EE
Line
Count
Source
135
240
                               const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
136
240
    using FieldType = typename Method::Base::Key;
137
240
    FieldType max_key = std::numeric_limits<FieldType>::min();
138
240
    FieldType min_key = std::numeric_limits<FieldType>::max();
139
140
240
    size_t num_rows = key_columns[0]->size();
141
240
    if (is_column_nullable(*key_columns[0])) {
142
0
        const FieldType* input_keys = (FieldType*)assert_cast<const ColumnNullable*>(key_columns[0])
143
0
                                              ->get_nested_column_ptr()
144
0
                                              ->get_raw_data()
145
0
                                              .data;
146
0
        const NullMap& null_map =
147
0
                assert_cast<const ColumnNullable*>(key_columns[0])->get_null_map_data();
148
        // skip first mocked row
149
0
        for (size_t i = 1; i < num_rows; i++) {
150
0
            if (null_map[i]) {
151
0
                continue;
152
0
            }
153
0
            max_key = std::max(max_key, input_keys[i]);
154
0
            min_key = std::min(min_key, input_keys[i]);
155
0
        }
156
240
    } else {
157
240
        const FieldType* input_keys = (FieldType*)key_columns[0]->get_raw_data().data;
158
        // skip first mocked row
159
720
        for (size_t i = 1; i < num_rows; i++) {
160
480
            max_key = std::max(max_key, input_keys[i]);
161
480
            min_key = std::min(min_key, input_keys[i]);
162
480
        }
163
240
    }
164
165
240
    constexpr auto MAX_MAPPING_RANGE = 1 << 23;
166
240
    bool allow_direct_mapping = (max_key >= min_key && max_key - min_key < MAX_MAPPING_RANGE - 1);
167
240
    if (allow_direct_mapping) {
168
240
        for (const auto& variant_ptr : variant_ptrs) {
169
240
            variant_ptr->method_variant.emplace<DirectPrimaryTypeHashTableContext<FieldType>>(
170
240
                    max_key, min_key);
171
240
        }
172
240
    }
173
240
}
174
175
template <typename Method>
176
void try_convert_to_direct_mapping(
177
        Method* method, const ColumnRawPtrs& key_columns,
178
46.4k
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {}
Unexecuted instantiation: _ZN5doris29try_convert_to_direct_mappingISt9monostateEEvPT_RKSt6vectorIPKNS_7IColumnESaIS7_EERKS4_ISt10shared_ptrINS_16JoinDataVariantsEESaISE_EE
_ZN5doris29try_convert_to_direct_mappingINS_16MethodSerializedINS_13JoinHashTableINS_9StringRefENS_17HashCRC32Return32IS3_EELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISD_EERKSA_ISt10shared_ptrINS_16JoinDataVariantsEESaISK_EE
Line
Count
Source
178
14.1k
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {}
Unexecuted instantiation: _ZN5doris29try_convert_to_direct_mappingINS_15MethodOneNumberIN4wide7integerILm256EjEENS_13JoinHashTableIS4_NS_17HashCRC32Return32IS4_EELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISF_EERKSC_ISt10shared_ptrINS_16JoinDataVariantsEESaISM_EE
Unexecuted instantiation: _ZN5doris29try_convert_to_direct_mappingINS_21MethodOneNumberDirectIhNS_13JoinHashTableIhNS_17HashCRC32Return32IhEELb1EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISC_EERKS9_ISt10shared_ptrINS_16JoinDataVariantsEESaISJ_EE
Unexecuted instantiation: _ZN5doris29try_convert_to_direct_mappingINS_21MethodOneNumberDirectItNS_13JoinHashTableItNS_17HashCRC32Return32ItEELb1EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISC_EERKS9_ISt10shared_ptrINS_16JoinDataVariantsEESaISJ_EE
Unexecuted instantiation: _ZN5doris29try_convert_to_direct_mappingINS_21MethodOneNumberDirectIjNS_13JoinHashTableIjNS_17HashCRC32Return32IjEELb1EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISC_EERKS9_ISt10shared_ptrINS_16JoinDataVariantsEESaISJ_EE
Unexecuted instantiation: _ZN5doris29try_convert_to_direct_mappingINS_21MethodOneNumberDirectImNS_13JoinHashTableImNS_17HashCRC32Return32ImEELb1EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISC_EERKS9_ISt10shared_ptrINS_16JoinDataVariantsEESaISJ_EE
Unexecuted instantiation: _ZN5doris29try_convert_to_direct_mappingINS_21MethodOneNumberDirectIN4wide7integerILm128EjEENS_13JoinHashTableIS4_NS_17HashCRC32Return32IS4_EELb1EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISF_EERKSC_ISt10shared_ptrINS_16JoinDataVariantsEESaISM_EE
_ZN5doris29try_convert_to_direct_mappingINS_15MethodKeysFixedINS_13JoinHashTableImNS_17HashCRC32Return32ImEELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISC_EERKS9_ISt10shared_ptrINS_16JoinDataVariantsEESaISJ_EE
Line
Count
Source
178
3.92k
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {}
_ZN5doris29try_convert_to_direct_mappingINS_15MethodKeysFixedINS_13JoinHashTableINS_6UInt72ENS_17HashCRC32Return32IS3_EELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISD_EERKSA_ISt10shared_ptrINS_16JoinDataVariantsEESaISK_EE
Line
Count
Source
178
3.20k
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {}
_ZN5doris29try_convert_to_direct_mappingINS_15MethodKeysFixedINS_13JoinHashTableINS_6UInt96ENS_17HashCRC32Return32IS3_EELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISD_EERKSA_ISt10shared_ptrINS_16JoinDataVariantsEESaISK_EE
Line
Count
Source
178
8.00k
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {}
Unexecuted instantiation: _ZN5doris29try_convert_to_direct_mappingINS_15MethodKeysFixedINS_13JoinHashTableINS_7UInt104ENS_17HashCRC32Return32IS3_EELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISD_EERKSA_ISt10shared_ptrINS_16JoinDataVariantsEESaISK_EE
_ZN5doris29try_convert_to_direct_mappingINS_15MethodKeysFixedINS_13JoinHashTableIN4wide7integerILm128EjEENS_17HashCRC32Return32IS5_EELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISF_EERKSC_ISt10shared_ptrINS_16JoinDataVariantsEESaISM_EE
Line
Count
Source
178
8.00k
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {}
_ZN5doris29try_convert_to_direct_mappingINS_15MethodKeysFixedINS_13JoinHashTableINS_7UInt136ENS_17HashCRC32Return32IS3_EELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISD_EERKSA_ISt10shared_ptrINS_16JoinDataVariantsEESaISK_EE
Line
Count
Source
178
960
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {}
_ZN5doris29try_convert_to_direct_mappingINS_15MethodKeysFixedINS_13JoinHashTableIN4wide7integerILm256EjEENS_17HashCRC32Return32IS5_EELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISF_EERKSC_ISt10shared_ptrINS_16JoinDataVariantsEESaISM_EE
Line
Count
Source
178
7.92k
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {}
_ZN5doris29try_convert_to_direct_mappingINS_19MethodStringNoCacheINS_13JoinHashTableINS_9StringRefENS_17HashCRC32Return32IS3_EELb0EEEEEEEvPT_RKSt6vectorIPKNS_7IColumnESaISD_EERKSA_ISt10shared_ptrINS_16JoinDataVariantsEESaISK_EE
Line
Count
Source
178
324
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {}
179
180
inline void try_convert_to_direct_mapping(
181
        PrimaryTypeHashTableContext<UInt8>* context, const ColumnRawPtrs& key_columns,
182
160
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
183
160
    primary_to_direct_mapping(context, key_columns, variant_ptrs);
184
160
}
185
186
inline void try_convert_to_direct_mapping(
187
        PrimaryTypeHashTableContext<UInt16>* context, const ColumnRawPtrs& key_columns,
188
80
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
189
80
    primary_to_direct_mapping(context, key_columns, variant_ptrs);
190
80
}
191
192
inline void try_convert_to_direct_mapping(
193
        PrimaryTypeHashTableContext<UInt32>* context, const ColumnRawPtrs& key_columns,
194
323
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
195
323
    primary_to_direct_mapping(context, key_columns, variant_ptrs);
196
323
}
197
198
inline void try_convert_to_direct_mapping(
199
        PrimaryTypeHashTableContext<UInt64>* context, const ColumnRawPtrs& key_columns,
200
800
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
201
800
    primary_to_direct_mapping(context, key_columns, variant_ptrs);
202
800
}
203
204
inline void try_convert_to_direct_mapping(
205
        PrimaryTypeHashTableContext<UInt128>* context, const ColumnRawPtrs& key_columns,
206
240
        const std::vector<std::shared_ptr<JoinDataVariants>>& variant_ptrs) {
207
240
    primary_to_direct_mapping(context, key_columns, variant_ptrs);
208
240
}
209
210
} // namespace doris