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 | | #include <glog/logging.h> |
19 | | #include <stddef.h> |
20 | | |
21 | | #include <algorithm> |
22 | | #include <boost/iterator/iterator_facade.hpp> |
23 | | #include <memory> |
24 | | #include <ostream> |
25 | | #include <string> |
26 | | #include <string_view> |
27 | | #include <tuple> |
28 | | #include <utility> |
29 | | |
30 | | #include "common/status.h" |
31 | | #include "core/assert_cast.h" |
32 | | #include "core/block/block.h" |
33 | | #include "core/block/column_numbers.h" |
34 | | #include "core/block/column_with_type_and_name.h" |
35 | | #include "core/call_on_type_index.h" |
36 | | #include "core/column/column.h" |
37 | | #include "core/column/column_array.h" |
38 | | #include "core/column/column_const.h" |
39 | | #include "core/column/column_map.h" |
40 | | #include "core/column/column_nullable.h" |
41 | | #include "core/column/column_vector.h" |
42 | | #include "core/data_type/data_type.h" |
43 | | #include "core/data_type/data_type_array.h" |
44 | | #include "core/data_type/data_type_map.h" |
45 | | #include "core/data_type/data_type_nullable.h" |
46 | | #include "core/data_type/data_type_number.h" |
47 | | #include "core/data_type/data_type_string.h" |
48 | | #include "core/data_type/data_type_struct.h" |
49 | | #include "core/data_type/primitive_type.h" |
50 | | #include "core/typeid_cast.h" |
51 | | #include "core/types.h" |
52 | | #include "exprs/aggregate/aggregate_function.h" |
53 | | #include "exprs/function/array/function_array_index.h" |
54 | | #include "exprs/function/function.h" |
55 | | #include "exprs/function/simple_function_factory.h" |
56 | | #include "util/simd/vstring_function.h" |
57 | | |
58 | | namespace doris { |
59 | | class FunctionContext; |
60 | | } // namespace doris |
61 | | |
62 | | namespace doris { |
63 | | |
64 | | // construct a map |
65 | | // map(key1, value2, key2, value2) -> {key1: value2, key2: value2} |
66 | | class FunctionMap : public IFunction { |
67 | | public: |
68 | | static constexpr auto name = "map"; |
69 | 5.17k | static FunctionPtr create() { return std::make_shared<FunctionMap>(); } |
70 | | |
71 | | /// Get function name. |
72 | 0 | String get_name() const override { return name; } |
73 | | |
74 | 5.16k | bool is_variadic() const override { return true; } |
75 | | |
76 | 10.3k | bool use_default_implementation_for_nulls() const override { return false; } |
77 | | |
78 | 0 | size_t get_number_of_arguments() const override { return 0; } |
79 | | |
80 | 5.16k | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
81 | 5.16k | DCHECK(arguments.size() % 2 == 0) |
82 | 0 | << "function: " << get_name() << ", arguments should not be even number"; |
83 | 5.16k | return std::make_shared<DataTypeMap>(make_nullable(arguments[0]), |
84 | 5.16k | make_nullable(arguments[1])); |
85 | 5.16k | } |
86 | | |
87 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
88 | 5.16k | uint32_t result, size_t input_rows_count) const override { |
89 | 5.16k | DCHECK(arguments.size() % 2 == 0) |
90 | 0 | << "function: " << get_name() << ", arguments should not be even number"; |
91 | | |
92 | 5.16k | size_t num_element = arguments.size(); |
93 | | |
94 | 5.16k | auto result_col = block.get_by_position(result).type->create_column(); |
95 | 5.16k | auto* map_column = assert_cast<ColumnMap*>(result_col.get()); |
96 | | |
97 | | // map keys column |
98 | 5.16k | auto& result_col_map_keys_data = map_column->get_keys(); |
99 | 5.16k | result_col_map_keys_data.reserve(input_rows_count * num_element / 2); |
100 | | // map values column |
101 | 5.16k | auto& result_col_map_vals_data = map_column->get_values(); |
102 | 5.16k | result_col_map_vals_data.reserve(input_rows_count * num_element / 2); |
103 | | // map offsets column |
104 | 5.16k | auto& result_col_map_offsets = map_column->get_offsets(); |
105 | 5.16k | result_col_map_offsets.resize(input_rows_count); |
106 | | |
107 | 5.16k | std::unique_ptr<bool[]> col_const = std::make_unique_for_overwrite<bool[]>(num_element); |
108 | 5.16k | std::vector<ColumnPtr> arg(num_element); |
109 | 16.1k | for (size_t i = 0; i < num_element; ++i) { |
110 | 10.9k | auto& col = block.get_by_position(arguments[i]).column; |
111 | 10.9k | std::tie(col, col_const[i]) = unpack_if_const(col); |
112 | 10.9k | bool is_nullable = i % 2 == 0 ? result_col_map_keys_data.is_nullable() |
113 | 10.9k | : result_col_map_vals_data.is_nullable(); |
114 | | // convert to nullable column |
115 | 10.9k | arg[i] = col; |
116 | 10.9k | if (is_nullable && !col->is_nullable()) { |
117 | 10.6k | arg[i] = ColumnNullable::create(col, ColumnUInt8::create(col->size(), 0)); |
118 | 10.6k | } |
119 | 10.9k | } |
120 | | |
121 | | // insert value into map |
122 | 5.16k | ColumnArray::Offset64 offset = 0; |
123 | 10.3k | for (size_t row = 0; row < input_rows_count; ++row) { |
124 | 10.6k | for (size_t i = 0; i < num_element; i += 2) { |
125 | 5.48k | result_col_map_keys_data.insert_from(*arg[i], index_check_const(row, col_const[i])); |
126 | 5.48k | result_col_map_vals_data.insert_from(*arg[i + 1], |
127 | 5.48k | index_check_const(row, col_const[i + 1])); |
128 | 5.48k | } |
129 | 5.16k | offset += num_element / 2; |
130 | 5.16k | result_col_map_offsets[row] = offset; |
131 | 5.16k | } |
132 | | |
133 | 5.16k | RETURN_IF_ERROR(map_column->deduplicate_keys()); |
134 | 5.16k | block.replace_by_position(result, std::move(result_col)); |
135 | 5.16k | return Status::OK(); |
136 | 5.16k | } |
137 | | }; |
138 | | |
139 | | template <bool is_key, bool OldVersion = false> |
140 | | class FunctionMapContains : public IFunction { |
141 | | public: |
142 | | static constexpr auto name = is_key ? "map_contains_key" : "map_contains_value"; |
143 | 123 | static FunctionPtr create() { return std::make_shared<FunctionMapContains>(); }_ZN5doris19FunctionMapContainsILb1ELb0EE6createEv Line | Count | Source | 143 | 65 | static FunctionPtr create() { return std::make_shared<FunctionMapContains>(); } |
_ZN5doris19FunctionMapContainsILb0ELb0EE6createEv Line | Count | Source | 143 | 58 | static FunctionPtr create() { return std::make_shared<FunctionMapContains>(); } |
|
144 | | |
145 | | /// Get function name. |
146 | 2 | String get_name() const override { return name; }_ZNK5doris19FunctionMapContainsILb1ELb0EE8get_nameB5cxx11Ev Line | Count | Source | 146 | 1 | String get_name() const override { return name; } |
_ZNK5doris19FunctionMapContainsILb0ELb0EE8get_nameB5cxx11Ev Line | Count | Source | 146 | 1 | String get_name() const override { return name; } |
|
147 | | |
148 | 107 | bool is_variadic() const override { return false; }_ZNK5doris19FunctionMapContainsILb1ELb0EE11is_variadicEv Line | Count | Source | 148 | 57 | bool is_variadic() const override { return false; } |
_ZNK5doris19FunctionMapContainsILb0ELb0EE11is_variadicEv Line | Count | Source | 148 | 50 | bool is_variadic() const override { return false; } |
|
149 | | |
150 | 105 | size_t get_number_of_arguments() const override { return 2; }_ZNK5doris19FunctionMapContainsILb1ELb0EE23get_number_of_argumentsEv Line | Count | Source | 150 | 56 | size_t get_number_of_arguments() const override { return 2; } |
_ZNK5doris19FunctionMapContainsILb0ELb0EE23get_number_of_argumentsEv Line | Count | Source | 150 | 49 | size_t get_number_of_arguments() const override { return 2; } |
|
151 | | |
152 | 2.19k | bool use_default_implementation_for_nulls() const override { |
153 | 2.19k | return FunctionArrayIndex<ArrayContainsAction> {}.use_default_implementation_for_nulls(); |
154 | 2.19k | } _ZNK5doris19FunctionMapContainsILb1ELb0EE36use_default_implementation_for_nullsEv Line | Count | Source | 152 | 1.87k | bool use_default_implementation_for_nulls() const override { | 153 | 1.87k | return FunctionArrayIndex<ArrayContainsAction> {}.use_default_implementation_for_nulls(); | 154 | 1.87k | } |
_ZNK5doris19FunctionMapContainsILb0ELb0EE36use_default_implementation_for_nullsEv Line | Count | Source | 152 | 317 | bool use_default_implementation_for_nulls() const override { | 153 | 317 | return FunctionArrayIndex<ArrayContainsAction> {}.use_default_implementation_for_nulls(); | 154 | 317 | } |
|
155 | | |
156 | 105 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
157 | 105 | DataTypePtr datatype = arguments[0]; |
158 | 105 | if (datatype->is_nullable()) { |
159 | 61 | datatype = assert_cast<const DataTypeNullable*>(datatype.get())->get_nested_type(); |
160 | 61 | } |
161 | 105 | DCHECK(datatype->get_primitive_type() == TYPE_MAP) |
162 | 0 | << "first argument for function: " << name << " should be DataTypeMap"; |
163 | | |
164 | | if constexpr (OldVersion) { |
165 | | return make_nullable(std::make_shared<DataTypeBool>()); |
166 | 105 | } else { |
167 | 105 | if (arguments[0]->is_nullable()) { |
168 | 61 | return make_nullable(std::make_shared<DataTypeBool>()); |
169 | 61 | } else { |
170 | 44 | return std::make_shared<DataTypeBool>(); |
171 | 44 | } |
172 | 105 | } |
173 | 105 | } _ZNK5doris19FunctionMapContainsILb1ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS6_EE Line | Count | Source | 156 | 56 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | 157 | 56 | DataTypePtr datatype = arguments[0]; | 158 | 56 | if (datatype->is_nullable()) { | 159 | 32 | datatype = assert_cast<const DataTypeNullable*>(datatype.get())->get_nested_type(); | 160 | 32 | } | 161 | 56 | DCHECK(datatype->get_primitive_type() == TYPE_MAP) | 162 | 0 | << "first argument for function: " << name << " should be DataTypeMap"; | 163 | | | 164 | | if constexpr (OldVersion) { | 165 | | return make_nullable(std::make_shared<DataTypeBool>()); | 166 | 56 | } else { | 167 | 56 | if (arguments[0]->is_nullable()) { | 168 | 32 | return make_nullable(std::make_shared<DataTypeBool>()); | 169 | 32 | } else { | 170 | 24 | return std::make_shared<DataTypeBool>(); | 171 | 24 | } | 172 | 56 | } | 173 | 56 | } |
_ZNK5doris19FunctionMapContainsILb0ELb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS6_EE Line | Count | Source | 156 | 49 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | 157 | 49 | DataTypePtr datatype = arguments[0]; | 158 | 49 | if (datatype->is_nullable()) { | 159 | 29 | datatype = assert_cast<const DataTypeNullable*>(datatype.get())->get_nested_type(); | 160 | 29 | } | 161 | 49 | DCHECK(datatype->get_primitive_type() == TYPE_MAP) | 162 | 0 | << "first argument for function: " << name << " should be DataTypeMap"; | 163 | | | 164 | | if constexpr (OldVersion) { | 165 | | return make_nullable(std::make_shared<DataTypeBool>()); | 166 | 49 | } else { | 167 | 49 | if (arguments[0]->is_nullable()) { | 168 | 29 | return make_nullable(std::make_shared<DataTypeBool>()); | 169 | 29 | } else { | 170 | 20 | return std::make_shared<DataTypeBool>(); | 171 | 20 | } | 172 | 49 | } | 173 | 49 | } |
|
174 | | |
175 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
176 | 2.08k | uint32_t result, size_t input_rows_count) const override { |
177 | | // backup original argument 0 |
178 | 2.08k | auto orig_arg0 = block.get_by_position(arguments[0]); |
179 | 2.08k | auto left_column = |
180 | 2.08k | block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); |
181 | 2.08k | const ColumnMap* map_column = nullptr; |
182 | 2.08k | ColumnPtr nullmap_column = nullptr; |
183 | 2.08k | if (left_column->is_nullable()) { |
184 | 1.95k | auto nullable_column = reinterpret_cast<const ColumnNullable*>(left_column.get()); |
185 | 1.95k | const auto map_column_guard = |
186 | 1.95k | check_and_get_column<ColumnMap>(nullable_column->get_nested_column()); |
187 | 1.95k | if (map_column_guard) { |
188 | 1.94k | map_column = map_column_guard.get(); |
189 | 1.94k | } |
190 | 1.95k | nullmap_column = nullable_column->get_null_map_column_ptr(); |
191 | 1.95k | } else { |
192 | 137 | const auto map_column_guard = check_and_get_column<ColumnMap>(*left_column.get()); |
193 | 140 | if (map_column_guard) { |
194 | 140 | map_column = map_column_guard.get(); |
195 | 140 | } |
196 | 137 | } |
197 | 2.08k | if (!map_column) { |
198 | 0 | return Status::RuntimeError("unsupported types for function {}({})", get_name(), |
199 | 0 | block.get_by_position(arguments[0]).type->get_name()); |
200 | 0 | } |
201 | | |
202 | 2.08k | DataTypePtr datatype = block.get_by_position(arguments[0]).type; |
203 | 2.08k | if (datatype->is_nullable()) { |
204 | 1.94k | datatype = assert_cast<const DataTypeNullable*>(datatype.get())->get_nested_type(); |
205 | 1.94k | } |
206 | 2.08k | const auto datatype_map = static_cast<const DataTypeMap*>(datatype.get()); |
207 | 2.08k | if constexpr (is_key) { |
208 | 1.82k | const auto& array_column = map_column->get_keys_array_ptr(); |
209 | 1.82k | const auto datatype_array = |
210 | 1.82k | std::make_shared<DataTypeArray>(datatype_map->get_key_type()); |
211 | 1.82k | if (nullmap_column) { |
212 | 1.74k | block.get_by_position(arguments[0]) = { |
213 | 1.74k | ColumnNullable::create(array_column, nullmap_column), |
214 | 1.74k | make_nullable(datatype_array), |
215 | 1.74k | block.get_by_position(arguments[0]).name + ".keys"}; |
216 | 1.74k | } else { |
217 | 76 | block.get_by_position(arguments[0]) = { |
218 | 76 | array_column, datatype_array, |
219 | 76 | block.get_by_position(arguments[0]).name + ".keys"}; |
220 | 76 | } |
221 | 1.82k | } else { |
222 | 267 | const auto& array_column = map_column->get_values_array_ptr(); |
223 | 267 | const auto datatype_array = |
224 | 267 | std::make_shared<DataTypeArray>(datatype_map->get_value_type()); |
225 | 267 | if (nullmap_column) { |
226 | 206 | block.get_by_position(arguments[0]) = { |
227 | 206 | ColumnNullable::create(array_column, nullmap_column), |
228 | 206 | make_nullable(datatype_array), |
229 | 206 | block.get_by_position(arguments[0]).name + ".values"}; |
230 | 206 | } else { |
231 | 61 | block.get_by_position(arguments[0]) = { |
232 | 61 | array_column, datatype_array, |
233 | 61 | block.get_by_position(arguments[0]).name + ".values"}; |
234 | 61 | } |
235 | 267 | } |
236 | | |
237 | 2.08k | RETURN_IF_ERROR(FunctionArrayIndex<ArrayContainsAction> {}.execute_impl( |
238 | 2.08k | context, block, arguments, result, input_rows_count)); |
239 | | |
240 | | // restore original argument 0 |
241 | 2.08k | block.get_by_position(arguments[0]) = orig_arg0; |
242 | 2.08k | return Status::OK(); |
243 | 2.08k | } _ZNK5doris19FunctionMapContainsILb1ELb0EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 176 | 1.82k | uint32_t result, size_t input_rows_count) const override { | 177 | | // backup original argument 0 | 178 | 1.82k | auto orig_arg0 = block.get_by_position(arguments[0]); | 179 | 1.82k | auto left_column = | 180 | 1.82k | block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); | 181 | 1.82k | const ColumnMap* map_column = nullptr; | 182 | 1.82k | ColumnPtr nullmap_column = nullptr; | 183 | 1.82k | if (left_column->is_nullable()) { | 184 | 1.74k | auto nullable_column = reinterpret_cast<const ColumnNullable*>(left_column.get()); | 185 | 1.74k | const auto map_column_guard = | 186 | 1.74k | check_and_get_column<ColumnMap>(nullable_column->get_nested_column()); | 187 | 1.74k | if (map_column_guard) { | 188 | 1.74k | map_column = map_column_guard.get(); | 189 | 1.74k | } | 190 | 1.74k | nullmap_column = nullable_column->get_null_map_column_ptr(); | 191 | 1.74k | } else { | 192 | 76 | const auto map_column_guard = check_and_get_column<ColumnMap>(*left_column.get()); | 193 | 78 | if (map_column_guard) { | 194 | 78 | map_column = map_column_guard.get(); | 195 | 78 | } | 196 | 76 | } | 197 | 1.82k | if (!map_column) { | 198 | 0 | return Status::RuntimeError("unsupported types for function {}({})", get_name(), | 199 | 0 | block.get_by_position(arguments[0]).type->get_name()); | 200 | 0 | } | 201 | | | 202 | 1.82k | DataTypePtr datatype = block.get_by_position(arguments[0]).type; | 203 | 1.82k | if (datatype->is_nullable()) { | 204 | 1.74k | datatype = assert_cast<const DataTypeNullable*>(datatype.get())->get_nested_type(); | 205 | 1.74k | } | 206 | 1.82k | const auto datatype_map = static_cast<const DataTypeMap*>(datatype.get()); | 207 | 1.82k | if constexpr (is_key) { | 208 | 1.82k | const auto& array_column = map_column->get_keys_array_ptr(); | 209 | 1.82k | const auto datatype_array = | 210 | 1.82k | std::make_shared<DataTypeArray>(datatype_map->get_key_type()); | 211 | 1.82k | if (nullmap_column) { | 212 | 1.74k | block.get_by_position(arguments[0]) = { | 213 | 1.74k | ColumnNullable::create(array_column, nullmap_column), | 214 | 1.74k | make_nullable(datatype_array), | 215 | 1.74k | block.get_by_position(arguments[0]).name + ".keys"}; | 216 | 1.74k | } else { | 217 | 76 | block.get_by_position(arguments[0]) = { | 218 | 76 | array_column, datatype_array, | 219 | 76 | block.get_by_position(arguments[0]).name + ".keys"}; | 220 | 76 | } | 221 | | } else { | 222 | | const auto& array_column = map_column->get_values_array_ptr(); | 223 | | const auto datatype_array = | 224 | | std::make_shared<DataTypeArray>(datatype_map->get_value_type()); | 225 | | if (nullmap_column) { | 226 | | block.get_by_position(arguments[0]) = { | 227 | | ColumnNullable::create(array_column, nullmap_column), | 228 | | make_nullable(datatype_array), | 229 | | block.get_by_position(arguments[0]).name + ".values"}; | 230 | | } else { | 231 | | block.get_by_position(arguments[0]) = { | 232 | | array_column, datatype_array, | 233 | | block.get_by_position(arguments[0]).name + ".values"}; | 234 | | } | 235 | | } | 236 | | | 237 | 1.82k | RETURN_IF_ERROR(FunctionArrayIndex<ArrayContainsAction> {}.execute_impl( | 238 | 1.82k | context, block, arguments, result, input_rows_count)); | 239 | | | 240 | | // restore original argument 0 | 241 | 1.82k | block.get_by_position(arguments[0]) = orig_arg0; | 242 | 1.82k | return Status::OK(); | 243 | 1.82k | } |
_ZNK5doris19FunctionMapContainsILb0ELb0EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 176 | 267 | uint32_t result, size_t input_rows_count) const override { | 177 | | // backup original argument 0 | 178 | 267 | auto orig_arg0 = block.get_by_position(arguments[0]); | 179 | 267 | auto left_column = | 180 | 267 | block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); | 181 | 267 | const ColumnMap* map_column = nullptr; | 182 | 267 | ColumnPtr nullmap_column = nullptr; | 183 | 267 | if (left_column->is_nullable()) { | 184 | 206 | auto nullable_column = reinterpret_cast<const ColumnNullable*>(left_column.get()); | 185 | 206 | const auto map_column_guard = | 186 | 206 | check_and_get_column<ColumnMap>(nullable_column->get_nested_column()); | 187 | 206 | if (map_column_guard) { | 188 | 206 | map_column = map_column_guard.get(); | 189 | 206 | } | 190 | 206 | nullmap_column = nullable_column->get_null_map_column_ptr(); | 191 | 206 | } else { | 192 | 61 | const auto map_column_guard = check_and_get_column<ColumnMap>(*left_column.get()); | 193 | 62 | if (map_column_guard) { | 194 | 62 | map_column = map_column_guard.get(); | 195 | 62 | } | 196 | 61 | } | 197 | 267 | if (!map_column) { | 198 | 0 | return Status::RuntimeError("unsupported types for function {}({})", get_name(), | 199 | 0 | block.get_by_position(arguments[0]).type->get_name()); | 200 | 0 | } | 201 | | | 202 | 267 | DataTypePtr datatype = block.get_by_position(arguments[0]).type; | 203 | 267 | if (datatype->is_nullable()) { | 204 | 206 | datatype = assert_cast<const DataTypeNullable*>(datatype.get())->get_nested_type(); | 205 | 206 | } | 206 | 267 | const auto datatype_map = static_cast<const DataTypeMap*>(datatype.get()); | 207 | | if constexpr (is_key) { | 208 | | const auto& array_column = map_column->get_keys_array_ptr(); | 209 | | const auto datatype_array = | 210 | | std::make_shared<DataTypeArray>(datatype_map->get_key_type()); | 211 | | if (nullmap_column) { | 212 | | block.get_by_position(arguments[0]) = { | 213 | | ColumnNullable::create(array_column, nullmap_column), | 214 | | make_nullable(datatype_array), | 215 | | block.get_by_position(arguments[0]).name + ".keys"}; | 216 | | } else { | 217 | | block.get_by_position(arguments[0]) = { | 218 | | array_column, datatype_array, | 219 | | block.get_by_position(arguments[0]).name + ".keys"}; | 220 | | } | 221 | 267 | } else { | 222 | 267 | const auto& array_column = map_column->get_values_array_ptr(); | 223 | 267 | const auto datatype_array = | 224 | 267 | std::make_shared<DataTypeArray>(datatype_map->get_value_type()); | 225 | 267 | if (nullmap_column) { | 226 | 206 | block.get_by_position(arguments[0]) = { | 227 | 206 | ColumnNullable::create(array_column, nullmap_column), | 228 | 206 | make_nullable(datatype_array), | 229 | 206 | block.get_by_position(arguments[0]).name + ".values"}; | 230 | 206 | } else { | 231 | 61 | block.get_by_position(arguments[0]) = { | 232 | 61 | array_column, datatype_array, | 233 | 61 | block.get_by_position(arguments[0]).name + ".values"}; | 234 | 61 | } | 235 | 267 | } | 236 | | | 237 | 267 | RETURN_IF_ERROR(FunctionArrayIndex<ArrayContainsAction> {}.execute_impl( | 238 | 267 | context, block, arguments, result, input_rows_count)); | 239 | | | 240 | | // restore original argument 0 | 241 | 267 | block.get_by_position(arguments[0]) = orig_arg0; | 242 | 267 | return Status::OK(); | 243 | 267 | } |
|
244 | | }; |
245 | | |
246 | | template <bool is_key> |
247 | | class FunctionMapKeysOrValues : public IFunction { |
248 | | public: |
249 | | static constexpr auto name = is_key ? "map_keys" : "map_values"; |
250 | 276 | static FunctionPtr create() { return std::make_shared<FunctionMapKeysOrValues>(); }_ZN5doris23FunctionMapKeysOrValuesILb1EE6createEv Line | Count | Source | 250 | 103 | static FunctionPtr create() { return std::make_shared<FunctionMapKeysOrValues>(); } |
_ZN5doris23FunctionMapKeysOrValuesILb0EE6createEv Line | Count | Source | 250 | 173 | static FunctionPtr create() { return std::make_shared<FunctionMapKeysOrValues>(); } |
|
251 | | |
252 | | /// Get function name. |
253 | 2 | String get_name() const override { return name; }_ZNK5doris23FunctionMapKeysOrValuesILb1EE8get_nameB5cxx11Ev Line | Count | Source | 253 | 1 | String get_name() const override { return name; } |
_ZNK5doris23FunctionMapKeysOrValuesILb0EE8get_nameB5cxx11Ev Line | Count | Source | 253 | 1 | String get_name() const override { return name; } |
|
254 | | |
255 | 260 | bool is_variadic() const override { return false; }_ZNK5doris23FunctionMapKeysOrValuesILb1EE11is_variadicEv Line | Count | Source | 255 | 95 | bool is_variadic() const override { return false; } |
_ZNK5doris23FunctionMapKeysOrValuesILb0EE11is_variadicEv Line | Count | Source | 255 | 165 | bool is_variadic() const override { return false; } |
|
256 | | |
257 | 258 | size_t get_number_of_arguments() const override { return 1; }_ZNK5doris23FunctionMapKeysOrValuesILb1EE23get_number_of_argumentsEv Line | Count | Source | 257 | 94 | size_t get_number_of_arguments() const override { return 1; } |
_ZNK5doris23FunctionMapKeysOrValuesILb0EE23get_number_of_argumentsEv Line | Count | Source | 257 | 164 | size_t get_number_of_arguments() const override { return 1; } |
|
258 | | |
259 | 258 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
260 | 258 | DataTypePtr datatype = arguments[0]; |
261 | 258 | if (datatype->is_nullable()) { |
262 | 0 | datatype = assert_cast<const DataTypeNullable*>(datatype.get())->get_nested_type(); |
263 | 0 | } |
264 | 258 | DCHECK(datatype->get_primitive_type() == TYPE_MAP) |
265 | 0 | << "first argument for function: " << name << " should be DataTypeMap"; |
266 | 258 | const auto datatype_map = static_cast<const DataTypeMap*>(datatype.get()); |
267 | 258 | if (is_key) { |
268 | 94 | return std::make_shared<DataTypeArray>(datatype_map->get_key_type()); |
269 | 164 | } else { |
270 | 164 | return std::make_shared<DataTypeArray>(datatype_map->get_value_type()); |
271 | 164 | } |
272 | 258 | } _ZNK5doris23FunctionMapKeysOrValuesILb1EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS6_EE Line | Count | Source | 259 | 94 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | 260 | 94 | DataTypePtr datatype = arguments[0]; | 261 | 94 | if (datatype->is_nullable()) { | 262 | 0 | datatype = assert_cast<const DataTypeNullable*>(datatype.get())->get_nested_type(); | 263 | 0 | } | 264 | 94 | DCHECK(datatype->get_primitive_type() == TYPE_MAP) | 265 | 0 | << "first argument for function: " << name << " should be DataTypeMap"; | 266 | 94 | const auto datatype_map = static_cast<const DataTypeMap*>(datatype.get()); | 267 | 94 | if (is_key) { | 268 | 94 | return std::make_shared<DataTypeArray>(datatype_map->get_key_type()); | 269 | 94 | } else { | 270 | 0 | return std::make_shared<DataTypeArray>(datatype_map->get_value_type()); | 271 | 0 | } | 272 | 94 | } |
_ZNK5doris23FunctionMapKeysOrValuesILb0EE20get_return_type_implERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS6_EE Line | Count | Source | 259 | 164 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | 260 | 164 | DataTypePtr datatype = arguments[0]; | 261 | 164 | if (datatype->is_nullable()) { | 262 | 0 | datatype = assert_cast<const DataTypeNullable*>(datatype.get())->get_nested_type(); | 263 | 0 | } | 264 | 164 | DCHECK(datatype->get_primitive_type() == TYPE_MAP) | 265 | 0 | << "first argument for function: " << name << " should be DataTypeMap"; | 266 | 164 | const auto datatype_map = static_cast<const DataTypeMap*>(datatype.get()); | 267 | 164 | if (is_key) { | 268 | 0 | return std::make_shared<DataTypeArray>(datatype_map->get_key_type()); | 269 | 164 | } else { | 270 | 164 | return std::make_shared<DataTypeArray>(datatype_map->get_value_type()); | 271 | 164 | } | 272 | 164 | } |
|
273 | | |
274 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
275 | 1.89k | uint32_t result, size_t input_rows_count) const override { |
276 | 1.89k | auto left_column = |
277 | 1.89k | block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); |
278 | 1.89k | const ColumnMap* map_column = nullptr; |
279 | 1.89k | if (left_column->is_nullable()) { |
280 | 0 | auto nullable_column = reinterpret_cast<const ColumnNullable*>(left_column.get()); |
281 | 0 | const auto map_column_guard = |
282 | 0 | check_and_get_column<ColumnMap>(nullable_column->get_nested_column()); |
283 | 0 | if (map_column_guard) { |
284 | 0 | map_column = map_column_guard.get(); |
285 | 0 | } |
286 | 1.89k | } else { |
287 | 1.89k | const auto map_column_guard = check_and_get_column<ColumnMap>(*left_column.get()); |
288 | 1.89k | if (map_column_guard) { |
289 | 1.89k | map_column = map_column_guard.get(); |
290 | 1.89k | } |
291 | 1.89k | } |
292 | 1.89k | if (!map_column) { |
293 | 0 | return Status::RuntimeError("unsupported types for function {}({})", get_name(), |
294 | 0 | block.get_by_position(arguments[0]).type->get_name()); |
295 | 0 | } |
296 | | |
297 | 1.89k | if constexpr (is_key) { |
298 | 500 | block.replace_by_position(result, map_column->get_keys_array_ptr()); |
299 | 1.39k | } else { |
300 | 1.39k | block.replace_by_position(result, map_column->get_values_array_ptr()); |
301 | 1.39k | } |
302 | | |
303 | 1.89k | return Status::OK(); |
304 | 1.89k | } _ZNK5doris23FunctionMapKeysOrValuesILb1EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 275 | 500 | uint32_t result, size_t input_rows_count) const override { | 276 | 500 | auto left_column = | 277 | 500 | block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); | 278 | 500 | const ColumnMap* map_column = nullptr; | 279 | 500 | if (left_column->is_nullable()) { | 280 | 0 | auto nullable_column = reinterpret_cast<const ColumnNullable*>(left_column.get()); | 281 | 0 | const auto map_column_guard = | 282 | 0 | check_and_get_column<ColumnMap>(nullable_column->get_nested_column()); | 283 | 0 | if (map_column_guard) { | 284 | 0 | map_column = map_column_guard.get(); | 285 | 0 | } | 286 | 500 | } else { | 287 | 500 | const auto map_column_guard = check_and_get_column<ColumnMap>(*left_column.get()); | 288 | 500 | if (map_column_guard) { | 289 | 500 | map_column = map_column_guard.get(); | 290 | 500 | } | 291 | 500 | } | 292 | 500 | if (!map_column) { | 293 | 0 | return Status::RuntimeError("unsupported types for function {}({})", get_name(), | 294 | 0 | block.get_by_position(arguments[0]).type->get_name()); | 295 | 0 | } | 296 | | | 297 | 500 | if constexpr (is_key) { | 298 | 500 | block.replace_by_position(result, map_column->get_keys_array_ptr()); | 299 | | } else { | 300 | | block.replace_by_position(result, map_column->get_values_array_ptr()); | 301 | | } | 302 | | | 303 | 500 | return Status::OK(); | 304 | 500 | } |
_ZNK5doris23FunctionMapKeysOrValuesILb0EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 275 | 1.39k | uint32_t result, size_t input_rows_count) const override { | 276 | 1.39k | auto left_column = | 277 | 1.39k | block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); | 278 | 1.39k | const ColumnMap* map_column = nullptr; | 279 | 1.39k | if (left_column->is_nullable()) { | 280 | 0 | auto nullable_column = reinterpret_cast<const ColumnNullable*>(left_column.get()); | 281 | 0 | const auto map_column_guard = | 282 | 0 | check_and_get_column<ColumnMap>(nullable_column->get_nested_column()); | 283 | 0 | if (map_column_guard) { | 284 | 0 | map_column = map_column_guard.get(); | 285 | 0 | } | 286 | 1.39k | } else { | 287 | 1.39k | const auto map_column_guard = check_and_get_column<ColumnMap>(*left_column.get()); | 288 | 1.39k | if (map_column_guard) { | 289 | 1.39k | map_column = map_column_guard.get(); | 290 | 1.39k | } | 291 | 1.39k | } | 292 | 1.39k | if (!map_column) { | 293 | 0 | return Status::RuntimeError("unsupported types for function {}({})", get_name(), | 294 | 0 | block.get_by_position(arguments[0]).type->get_name()); | 295 | 0 | } | 296 | | | 297 | | if constexpr (is_key) { | 298 | | block.replace_by_position(result, map_column->get_keys_array_ptr()); | 299 | 1.39k | } else { | 300 | 1.39k | block.replace_by_position(result, map_column->get_values_array_ptr()); | 301 | 1.39k | } | 302 | | | 303 | 1.39k | return Status::OK(); | 304 | 1.39k | } |
|
305 | | }; |
306 | | |
307 | | class FunctionMapEntries : public IFunction { |
308 | | public: |
309 | | static constexpr auto name = "map_entries"; |
310 | 34 | static FunctionPtr create() { return std::make_shared<FunctionMapEntries>(); } |
311 | | |
312 | | /// Get function name. |
313 | 1 | String get_name() const override { return name; } |
314 | | |
315 | 26 | bool is_variadic() const override { return false; } |
316 | | |
317 | 25 | size_t get_number_of_arguments() const override { return 1; } |
318 | | |
319 | 25 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
320 | 25 | const auto* const datatype_map = assert_cast<const DataTypeMap*>(arguments[0].get()); |
321 | | |
322 | | // Create struct type with named fields "key" and "value" |
323 | | // key and value are always nullable |
324 | 25 | auto struct_type = std::make_shared<DataTypeStruct>( |
325 | 25 | DataTypes {make_nullable(datatype_map->get_key_type()), |
326 | 25 | make_nullable(datatype_map->get_value_type())}, |
327 | 25 | Strings {"key", "value"}); |
328 | | |
329 | | // Theoretically, the struct element will never be null, |
330 | | // but FE expects the array element to be nullable |
331 | 25 | return std::make_shared<DataTypeArray>(make_nullable(struct_type)); |
332 | 25 | } |
333 | | |
334 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
335 | 33 | uint32_t result, size_t input_rows_count) const override { |
336 | 33 | const auto* map_column = |
337 | 33 | assert_cast<const ColumnMap*>(block.get_by_position(arguments[0]).column.get()); |
338 | | |
339 | 33 | auto struct_column = ColumnStruct::create( |
340 | 33 | Columns {map_column->get_keys_ptr(), map_column->get_values_ptr()}); |
341 | | |
342 | | // all struct elements are not null |
343 | 33 | auto struct_null_map = ColumnUInt8::create(struct_column->size(), 0); |
344 | 33 | auto nullable_struct_column = |
345 | 33 | ColumnNullable::create(std::move(struct_column), std::move(struct_null_map)); |
346 | | |
347 | 33 | auto result_array_column = ColumnArray::create(std::move(nullable_struct_column), |
348 | 33 | map_column->get_offsets_ptr()); |
349 | | |
350 | 33 | block.replace_by_position(result, std::move(result_array_column)); |
351 | | |
352 | 33 | return Status::OK(); |
353 | 33 | } |
354 | | }; |
355 | | |
356 | | class FunctionStrToMap : public IFunction { |
357 | | public: |
358 | | static constexpr auto name = "str_to_map"; |
359 | 62 | static FunctionPtr create() { return std::make_shared<FunctionStrToMap>(); } |
360 | | |
361 | 1 | String get_name() const override { return name; } |
362 | | |
363 | 53 | size_t get_number_of_arguments() const override { return 3; } |
364 | | |
365 | 53 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
366 | 53 | return std::make_shared<DataTypeMap>(make_nullable(std::make_shared<DataTypeString>()), |
367 | 53 | make_nullable(std::make_shared<DataTypeString>())); |
368 | 53 | } |
369 | | |
370 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
371 | 170 | uint32_t result, size_t input_rows_count) const override { |
372 | 170 | DCHECK(arguments.size() == 3); |
373 | | |
374 | 170 | bool cols_const[2]; |
375 | 170 | ColumnPtr cols[2]; |
376 | 510 | for (size_t i = 0; i < 2; ++i) { |
377 | 340 | cols_const[i] = is_column_const(*block.get_by_position(arguments[i]).column); |
378 | 340 | } |
379 | | // convert to full column if necessary |
380 | 170 | default_preprocess_parameter_columns(cols, cols_const, {0, 1}, block, arguments); |
381 | 170 | const auto& [col3, col3_const] = |
382 | 170 | unpack_if_const(block.get_by_position(arguments[2]).column); |
383 | | |
384 | 170 | const auto& str_column = assert_cast<const ColumnString*>(cols[0].get()); |
385 | 170 | const auto& pair_delim_column = assert_cast<const ColumnString*>(cols[1].get()); |
386 | 170 | const auto& kv_delim_column = assert_cast<const ColumnString*>(col3.get()); |
387 | | |
388 | 170 | ColumnPtr result_col; |
389 | 170 | if (cols_const[0] && cols_const[1]) { |
390 | 10 | result_col = execute_vector<true, false>(input_rows_count, *str_column, |
391 | 10 | *pair_delim_column, *kv_delim_column); |
392 | 160 | } else if (col3_const) { |
393 | 30 | result_col = execute_vector<false, true>(input_rows_count, *str_column, |
394 | 30 | *pair_delim_column, *kv_delim_column); |
395 | 130 | } else { |
396 | 130 | result_col = execute_vector<false, false>(input_rows_count, *str_column, |
397 | 130 | *pair_delim_column, *kv_delim_column); |
398 | 130 | } |
399 | | |
400 | 170 | block.replace_by_position(result, std::move(result_col)); |
401 | | |
402 | 170 | return Status::OK(); |
403 | 170 | } |
404 | | |
405 | | private: |
406 | | template <bool is_str_and_pair_delim_const, bool is_kv_delim_const> |
407 | | static ColumnPtr execute_vector(const size_t input_rows_count, const ColumnString& str_col, |
408 | | const ColumnString& pair_delim_col, |
409 | 170 | const ColumnString& kv_delim_col) { |
410 | | // map keys column |
411 | 170 | auto result_col_map_keys_data = |
412 | 170 | ColumnNullable::create(ColumnString::create(), ColumnUInt8::create()); |
413 | 170 | result_col_map_keys_data->reserve(input_rows_count); |
414 | | // map values column |
415 | 170 | auto result_col_map_vals_data = |
416 | 170 | ColumnNullable::create(ColumnString::create(), ColumnUInt8::create()); |
417 | 170 | result_col_map_vals_data->reserve(input_rows_count); |
418 | | // map offsets column |
419 | 170 | auto result_col_map_offsets = ColumnOffset64::create(); |
420 | 170 | result_col_map_offsets->reserve(input_rows_count); |
421 | | |
422 | 170 | std::vector<std::string_view> kvs; |
423 | 170 | std::string_view kv_delim; |
424 | 170 | if constexpr (is_str_and_pair_delim_const) { |
425 | 10 | auto str = str_col.get_data_at(0).to_string_view(); |
426 | 10 | auto pair_delim = pair_delim_col.get_data_at(0).to_string_view(); |
427 | 10 | kvs = split_pair_by_delim(str, pair_delim); |
428 | 10 | } |
429 | 170 | if constexpr (is_kv_delim_const) { |
430 | 30 | kv_delim = kv_delim_col.get_data_at(0).to_string_view(); |
431 | 30 | } |
432 | | |
433 | 405 | for (size_t i = 0; i < input_rows_count; ++i) { |
434 | 235 | if constexpr (!is_str_and_pair_delim_const) { |
435 | 220 | auto str = str_col.get_data_at(i).to_string_view(); |
436 | 220 | auto pair_delim = pair_delim_col.get_data_at(i).to_string_view(); |
437 | 220 | kvs = split_pair_by_delim(str, pair_delim); |
438 | 220 | } |
439 | 235 | if constexpr (!is_kv_delim_const) { |
440 | 190 | kv_delim = kv_delim_col.get_data_at(i).to_string_view(); |
441 | 190 | } |
442 | | |
443 | 1.47k | for (const auto& kv : kvs) { |
444 | 1.47k | auto kv_parts = split_kv_by_delim(kv, kv_delim); |
445 | 1.47k | if (kv_parts.size() == 2) { |
446 | 1.40k | result_col_map_keys_data->insert_data(kv_parts[0].data(), kv_parts[0].size()); |
447 | 1.40k | result_col_map_vals_data->insert_data(kv_parts[1].data(), kv_parts[1].size()); |
448 | 1.40k | } else { |
449 | 73 | result_col_map_keys_data->insert_data(kv.data(), kv.size()); |
450 | 73 | result_col_map_vals_data->insert_default(); |
451 | 73 | } |
452 | 1.47k | } |
453 | 235 | result_col_map_offsets->insert_value(result_col_map_keys_data->size()); |
454 | 235 | } |
455 | | |
456 | 170 | auto map_column = ColumnMap::create(std::move(result_col_map_keys_data), |
457 | 170 | std::move(result_col_map_vals_data), |
458 | 170 | std::move(result_col_map_offsets)); |
459 | | |
460 | | // `deduplicate_keys` always return ok |
461 | 170 | static_cast<void>(map_column->deduplicate_keys()); |
462 | 170 | return map_column; |
463 | 170 | } _ZN5doris16FunctionStrToMap14execute_vectorILb1ELb0EEENS_3COWINS_7IColumnEE13immutable_ptrIS3_EEmRKNS_9ColumnStrIjEESA_SA_ Line | Count | Source | 409 | 10 | const ColumnString& kv_delim_col) { | 410 | | // map keys column | 411 | 10 | auto result_col_map_keys_data = | 412 | 10 | ColumnNullable::create(ColumnString::create(), ColumnUInt8::create()); | 413 | 10 | result_col_map_keys_data->reserve(input_rows_count); | 414 | | // map values column | 415 | 10 | auto result_col_map_vals_data = | 416 | 10 | ColumnNullable::create(ColumnString::create(), ColumnUInt8::create()); | 417 | 10 | result_col_map_vals_data->reserve(input_rows_count); | 418 | | // map offsets column | 419 | 10 | auto result_col_map_offsets = ColumnOffset64::create(); | 420 | 10 | result_col_map_offsets->reserve(input_rows_count); | 421 | | | 422 | 10 | std::vector<std::string_view> kvs; | 423 | 10 | std::string_view kv_delim; | 424 | 10 | if constexpr (is_str_and_pair_delim_const) { | 425 | 10 | auto str = str_col.get_data_at(0).to_string_view(); | 426 | 10 | auto pair_delim = pair_delim_col.get_data_at(0).to_string_view(); | 427 | 10 | kvs = split_pair_by_delim(str, pair_delim); | 428 | 10 | } | 429 | | if constexpr (is_kv_delim_const) { | 430 | | kv_delim = kv_delim_col.get_data_at(0).to_string_view(); | 431 | | } | 432 | | | 433 | 25 | for (size_t i = 0; i < input_rows_count; ++i) { | 434 | | if constexpr (!is_str_and_pair_delim_const) { | 435 | | auto str = str_col.get_data_at(i).to_string_view(); | 436 | | auto pair_delim = pair_delim_col.get_data_at(i).to_string_view(); | 437 | | kvs = split_pair_by_delim(str, pair_delim); | 438 | | } | 439 | 15 | if constexpr (!is_kv_delim_const) { | 440 | 15 | kv_delim = kv_delim_col.get_data_at(i).to_string_view(); | 441 | 15 | } | 442 | | | 443 | 30 | for (const auto& kv : kvs) { | 444 | 30 | auto kv_parts = split_kv_by_delim(kv, kv_delim); | 445 | 30 | if (kv_parts.size() == 2) { | 446 | 2 | result_col_map_keys_data->insert_data(kv_parts[0].data(), kv_parts[0].size()); | 447 | 2 | result_col_map_vals_data->insert_data(kv_parts[1].data(), kv_parts[1].size()); | 448 | 28 | } else { | 449 | 28 | result_col_map_keys_data->insert_data(kv.data(), kv.size()); | 450 | 28 | result_col_map_vals_data->insert_default(); | 451 | 28 | } | 452 | 30 | } | 453 | 15 | result_col_map_offsets->insert_value(result_col_map_keys_data->size()); | 454 | 15 | } | 455 | | | 456 | 10 | auto map_column = ColumnMap::create(std::move(result_col_map_keys_data), | 457 | 10 | std::move(result_col_map_vals_data), | 458 | 10 | std::move(result_col_map_offsets)); | 459 | | | 460 | | // `deduplicate_keys` always return ok | 461 | 10 | static_cast<void>(map_column->deduplicate_keys()); | 462 | 10 | return map_column; | 463 | 10 | } |
_ZN5doris16FunctionStrToMap14execute_vectorILb0ELb1EEENS_3COWINS_7IColumnEE13immutable_ptrIS3_EEmRKNS_9ColumnStrIjEESA_SA_ Line | Count | Source | 409 | 30 | const ColumnString& kv_delim_col) { | 410 | | // map keys column | 411 | 30 | auto result_col_map_keys_data = | 412 | 30 | ColumnNullable::create(ColumnString::create(), ColumnUInt8::create()); | 413 | 30 | result_col_map_keys_data->reserve(input_rows_count); | 414 | | // map values column | 415 | 30 | auto result_col_map_vals_data = | 416 | 30 | ColumnNullable::create(ColumnString::create(), ColumnUInt8::create()); | 417 | 30 | result_col_map_vals_data->reserve(input_rows_count); | 418 | | // map offsets column | 419 | 30 | auto result_col_map_offsets = ColumnOffset64::create(); | 420 | 30 | result_col_map_offsets->reserve(input_rows_count); | 421 | | | 422 | 30 | std::vector<std::string_view> kvs; | 423 | 30 | std::string_view kv_delim; | 424 | | if constexpr (is_str_and_pair_delim_const) { | 425 | | auto str = str_col.get_data_at(0).to_string_view(); | 426 | | auto pair_delim = pair_delim_col.get_data_at(0).to_string_view(); | 427 | | kvs = split_pair_by_delim(str, pair_delim); | 428 | | } | 429 | 30 | if constexpr (is_kv_delim_const) { | 430 | 30 | kv_delim = kv_delim_col.get_data_at(0).to_string_view(); | 431 | 30 | } | 432 | | | 433 | 75 | for (size_t i = 0; i < input_rows_count; ++i) { | 434 | 45 | if constexpr (!is_str_and_pair_delim_const) { | 435 | 45 | auto str = str_col.get_data_at(i).to_string_view(); | 436 | 45 | auto pair_delim = pair_delim_col.get_data_at(i).to_string_view(); | 437 | 45 | kvs = split_pair_by_delim(str, pair_delim); | 438 | 45 | } | 439 | | if constexpr (!is_kv_delim_const) { | 440 | | kv_delim = kv_delim_col.get_data_at(i).to_string_view(); | 441 | | } | 442 | | | 443 | 61 | for (const auto& kv : kvs) { | 444 | 61 | auto kv_parts = split_kv_by_delim(kv, kv_delim); | 445 | 61 | if (kv_parts.size() == 2) { | 446 | 43 | result_col_map_keys_data->insert_data(kv_parts[0].data(), kv_parts[0].size()); | 447 | 43 | result_col_map_vals_data->insert_data(kv_parts[1].data(), kv_parts[1].size()); | 448 | 43 | } else { | 449 | 18 | result_col_map_keys_data->insert_data(kv.data(), kv.size()); | 450 | 18 | result_col_map_vals_data->insert_default(); | 451 | 18 | } | 452 | 61 | } | 453 | 45 | result_col_map_offsets->insert_value(result_col_map_keys_data->size()); | 454 | 45 | } | 455 | | | 456 | 30 | auto map_column = ColumnMap::create(std::move(result_col_map_keys_data), | 457 | 30 | std::move(result_col_map_vals_data), | 458 | 30 | std::move(result_col_map_offsets)); | 459 | | | 460 | | // `deduplicate_keys` always return ok | 461 | 30 | static_cast<void>(map_column->deduplicate_keys()); | 462 | 30 | return map_column; | 463 | 30 | } |
_ZN5doris16FunctionStrToMap14execute_vectorILb0ELb0EEENS_3COWINS_7IColumnEE13immutable_ptrIS3_EEmRKNS_9ColumnStrIjEESA_SA_ Line | Count | Source | 409 | 130 | const ColumnString& kv_delim_col) { | 410 | | // map keys column | 411 | 130 | auto result_col_map_keys_data = | 412 | 130 | ColumnNullable::create(ColumnString::create(), ColumnUInt8::create()); | 413 | 130 | result_col_map_keys_data->reserve(input_rows_count); | 414 | | // map values column | 415 | 130 | auto result_col_map_vals_data = | 416 | 130 | ColumnNullable::create(ColumnString::create(), ColumnUInt8::create()); | 417 | 130 | result_col_map_vals_data->reserve(input_rows_count); | 418 | | // map offsets column | 419 | 130 | auto result_col_map_offsets = ColumnOffset64::create(); | 420 | 130 | result_col_map_offsets->reserve(input_rows_count); | 421 | | | 422 | 130 | std::vector<std::string_view> kvs; | 423 | 130 | std::string_view kv_delim; | 424 | | if constexpr (is_str_and_pair_delim_const) { | 425 | | auto str = str_col.get_data_at(0).to_string_view(); | 426 | | auto pair_delim = pair_delim_col.get_data_at(0).to_string_view(); | 427 | | kvs = split_pair_by_delim(str, pair_delim); | 428 | | } | 429 | | if constexpr (is_kv_delim_const) { | 430 | | kv_delim = kv_delim_col.get_data_at(0).to_string_view(); | 431 | | } | 432 | | | 433 | 305 | for (size_t i = 0; i < input_rows_count; ++i) { | 434 | 175 | if constexpr (!is_str_and_pair_delim_const) { | 435 | 175 | auto str = str_col.get_data_at(i).to_string_view(); | 436 | 175 | auto pair_delim = pair_delim_col.get_data_at(i).to_string_view(); | 437 | 175 | kvs = split_pair_by_delim(str, pair_delim); | 438 | 175 | } | 439 | 175 | if constexpr (!is_kv_delim_const) { | 440 | 175 | kv_delim = kv_delim_col.get_data_at(i).to_string_view(); | 441 | 175 | } | 442 | | | 443 | 1.38k | for (const auto& kv : kvs) { | 444 | 1.38k | auto kv_parts = split_kv_by_delim(kv, kv_delim); | 445 | 1.38k | if (kv_parts.size() == 2) { | 446 | 1.35k | result_col_map_keys_data->insert_data(kv_parts[0].data(), kv_parts[0].size()); | 447 | 1.35k | result_col_map_vals_data->insert_data(kv_parts[1].data(), kv_parts[1].size()); | 448 | 1.35k | } else { | 449 | 27 | result_col_map_keys_data->insert_data(kv.data(), kv.size()); | 450 | 27 | result_col_map_vals_data->insert_default(); | 451 | 27 | } | 452 | 1.38k | } | 453 | 175 | result_col_map_offsets->insert_value(result_col_map_keys_data->size()); | 454 | 175 | } | 455 | | | 456 | 130 | auto map_column = ColumnMap::create(std::move(result_col_map_keys_data), | 457 | 130 | std::move(result_col_map_vals_data), | 458 | 130 | std::move(result_col_map_offsets)); | 459 | | | 460 | | // `deduplicate_keys` always return ok | 461 | 130 | static_cast<void>(map_column->deduplicate_keys()); | 462 | 130 | return map_column; | 463 | 130 | } |
|
464 | | |
465 | | static std::vector<std::string_view> split_pair_by_delim(const std::string_view& str, |
466 | 230 | const std::string_view& delim) { |
467 | 230 | if (str.empty()) { |
468 | 11 | return {str}; |
469 | 11 | } |
470 | 219 | if (delim.empty()) { |
471 | 0 | std::vector<std::string_view> result; |
472 | 0 | size_t offset = 0; |
473 | 0 | while (offset < str.size()) { |
474 | 0 | auto len = get_utf8_byte_length(str[offset]); |
475 | 0 | result.push_back(str.substr(offset, len)); |
476 | 0 | offset += len; |
477 | 0 | } |
478 | 0 | return result; |
479 | 0 | } |
480 | 219 | std::vector<std::string_view> result; |
481 | 219 | size_t offset = 0; |
482 | 1.45k | while (offset < str.size()) { |
483 | 1.45k | auto pos = str.find(delim, offset); |
484 | 1.45k | if (pos == std::string::npos) { |
485 | 217 | result.push_back(str.substr(offset)); |
486 | 217 | break; |
487 | 217 | } |
488 | 1.23k | result.push_back(str.substr(offset, pos - offset)); |
489 | 1.23k | offset = pos + delim.size(); |
490 | 1.23k | } |
491 | 219 | return result; |
492 | 219 | } |
493 | | |
494 | | static std::vector<std::string_view> split_kv_by_delim(const std::string_view& str, |
495 | 1.47k | const std::string_view& delim) { |
496 | 1.47k | if (str.empty()) { |
497 | 15 | return {str}; |
498 | 15 | } |
499 | 1.46k | if (delim.empty()) { |
500 | 0 | auto len = get_utf8_byte_length(str[0]); |
501 | 0 | return {str.substr(0, len), str.substr(len)}; |
502 | 0 | } |
503 | 1.46k | auto pos = str.find(delim); |
504 | 1.46k | if (pos == std::string::npos) { |
505 | 58 | return {str}; |
506 | 1.40k | } else { |
507 | 1.40k | return {str.substr(0, pos), str.substr(pos + delim.size())}; |
508 | 1.40k | } |
509 | 1.46k | } |
510 | | }; |
511 | | |
512 | | class FunctionMapContainsEntry : public IFunction { |
513 | | public: |
514 | | static constexpr auto name = "map_contains_entry"; |
515 | 401 | static FunctionPtr create() { return std::make_shared<FunctionMapContainsEntry>(); } |
516 | | |
517 | 1 | String get_name() const override { return name; } |
518 | 392 | size_t get_number_of_arguments() const override { return 3; } |
519 | 940 | bool use_default_implementation_for_nulls() const override { return false; } |
520 | | |
521 | 392 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
522 | 392 | DataTypePtr datatype = arguments[0]; |
523 | 392 | if (datatype->is_nullable()) { |
524 | 51 | datatype = assert_cast<const DataTypeNullable*>(datatype.get())->get_nested_type(); |
525 | 51 | } |
526 | 392 | DCHECK_EQ(datatype->get_primitive_type(), PrimitiveType::TYPE_MAP) |
527 | 0 | << "first argument for function: " << name << " should be DataTypeMap"; |
528 | | |
529 | 392 | if (arguments[0]->is_nullable()) { |
530 | 51 | return make_nullable(std::make_shared<DataTypeBool>()); |
531 | 341 | } else { |
532 | 341 | return std::make_shared<DataTypeBool>(); |
533 | 341 | } |
534 | 392 | } |
535 | | |
536 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
537 | 547 | uint32_t result, size_t input_rows_count) const override { |
538 | 547 | return _execute_type_check_and_dispatch(block, arguments, result); |
539 | 547 | } |
540 | | |
541 | | private: |
542 | | // assume result_matches is initialized to all 1s |
543 | | template <typename ColumnType> |
544 | | void _execute_column_comparison(const IColumn& map_entry_column, const UInt8* map_entry_nullmap, |
545 | | const IColumn& search_column, const UInt8* search_nullmap, |
546 | | const ColumnArray::Offsets64& map_offsets, |
547 | | const UInt8* map_row_nullmap, bool search_is_const, |
548 | 1.09k | ColumnUInt8& result_matches) const { |
549 | 1.09k | auto& result_data = result_matches.get_data(); |
550 | 2.43k | for (size_t row = 0; row < map_offsets.size(); ++row) { |
551 | 1.33k | if (map_row_nullmap && map_row_nullmap[row]) { |
552 | 110 | continue; |
553 | 110 | } |
554 | 1.22k | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; |
555 | 1.22k | size_t map_end = map_offsets[row]; |
556 | | // const column always uses index 0 |
557 | 1.22k | size_t search_idx = search_is_const ? 0 : row; |
558 | 2.93k | for (size_t i = map_start; i < map_end; ++i) { |
559 | 1.70k | result_data[i] &= |
560 | 1.70k | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, |
561 | 1.70k | search_column, search_idx, search_nullmap) |
562 | 1.70k | ? 1 |
563 | 1.70k | : 0; |
564 | 1.70k | } |
565 | 1.22k | } |
566 | 1.09k | } _ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE2EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRS4_ Line | Count | Source | 548 | 42 | ColumnUInt8& result_matches) const { | 549 | 42 | auto& result_data = result_matches.get_data(); | 550 | 84 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 42 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 2 | continue; | 553 | 2 | } | 554 | 40 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 40 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 40 | size_t search_idx = search_is_const ? 0 : row; | 558 | 80 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 40 | result_data[i] &= | 560 | 40 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 40 | search_column, search_idx, search_nullmap) | 562 | 40 | ? 1 | 563 | 40 | : 0; | 564 | 40 | } | 565 | 40 | } | 566 | 42 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE3EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Line | Count | Source | 548 | 47 | ColumnUInt8& result_matches) const { | 549 | 47 | auto& result_data = result_matches.get_data(); | 550 | 94 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 47 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 47 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 47 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 47 | size_t search_idx = search_is_const ? 0 : row; | 558 | 104 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 57 | result_data[i] &= | 560 | 57 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 57 | search_column, search_idx, search_nullmap) | 562 | 57 | ? 1 | 563 | 57 | : 0; | 564 | 57 | } | 565 | 47 | } | 566 | 47 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE4EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Line | Count | Source | 548 | 53 | ColumnUInt8& result_matches) const { | 549 | 53 | auto& result_data = result_matches.get_data(); | 550 | 106 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 53 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 53 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 53 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 53 | size_t search_idx = search_is_const ? 0 : row; | 558 | 120 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 67 | result_data[i] &= | 560 | 67 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 67 | search_column, search_idx, search_nullmap) | 562 | 67 | ? 1 | 563 | 67 | : 0; | 564 | 67 | } | 565 | 53 | } | 566 | 53 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE5EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Line | Count | Source | 548 | 232 | ColumnUInt8& result_matches) const { | 549 | 232 | auto& result_data = result_matches.get_data(); | 550 | 583 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 351 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 53 | continue; | 553 | 53 | } | 554 | 298 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 298 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 298 | size_t search_idx = search_is_const ? 0 : row; | 558 | 792 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 494 | result_data[i] &= | 560 | 494 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 494 | search_column, search_idx, search_nullmap) | 562 | 494 | ? 1 | 563 | 494 | : 0; | 564 | 494 | } | 565 | 298 | } | 566 | 232 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE6EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Line | Count | Source | 548 | 46 | ColumnUInt8& result_matches) const { | 549 | 46 | auto& result_data = result_matches.get_data(); | 550 | 92 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 46 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 46 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 46 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 46 | size_t search_idx = search_is_const ? 0 : row; | 558 | 104 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 58 | result_data[i] &= | 560 | 58 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 58 | search_column, search_idx, search_nullmap) | 562 | 58 | ? 1 | 563 | 58 | : 0; | 564 | 58 | } | 565 | 46 | } | 566 | 46 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE7EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Line | Count | Source | 548 | 34 | ColumnUInt8& result_matches) const { | 549 | 34 | auto& result_data = result_matches.get_data(); | 550 | 68 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 34 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 34 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 34 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 34 | size_t search_idx = search_is_const ? 0 : row; | 558 | 68 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 34 | result_data[i] &= | 560 | 34 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 34 | search_column, search_idx, search_nullmap) | 562 | 34 | ? 1 | 563 | 34 | : 0; | 564 | 34 | } | 565 | 34 | } | 566 | 34 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE8EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Line | Count | Source | 548 | 34 | ColumnUInt8& result_matches) const { | 549 | 34 | auto& result_data = result_matches.get_data(); | 550 | 68 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 34 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 34 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 34 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 34 | size_t search_idx = search_is_const ? 0 : row; | 558 | 68 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 34 | result_data[i] &= | 560 | 34 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 34 | search_column, search_idx, search_nullmap) | 562 | 34 | ? 1 | 563 | 34 | : 0; | 564 | 34 | } | 565 | 34 | } | 566 | 34 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE9EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Line | Count | Source | 548 | 34 | ColumnUInt8& result_matches) const { | 549 | 34 | auto& result_data = result_matches.get_data(); | 550 | 68 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 34 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 34 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 34 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 34 | size_t search_idx = search_is_const ? 0 : row; | 558 | 68 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 34 | result_data[i] &= | 560 | 34 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 34 | search_column, search_idx, search_nullmap) | 562 | 34 | ? 1 | 563 | 34 | : 0; | 564 | 34 | } | 565 | 34 | } | 566 | 34 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_13ColumnDecimalILNS_13PrimitiveTypeE28EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS_12ColumnVectorILS3_2EEE Line | Count | Source | 548 | 2 | ColumnUInt8& result_matches) const { | 549 | 2 | auto& result_data = result_matches.get_data(); | 550 | 4 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 2 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 2 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 2 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 2 | size_t search_idx = search_is_const ? 0 : row; | 558 | 4 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 2 | result_data[i] &= | 560 | 2 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 2 | search_column, search_idx, search_nullmap) | 562 | 2 | ? 1 | 563 | 2 | : 0; | 564 | 2 | } | 565 | 2 | } | 566 | 2 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_13ColumnDecimalILNS_13PrimitiveTypeE29EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS_12ColumnVectorILS3_2EEE Line | Count | Source | 548 | 2 | ColumnUInt8& result_matches) const { | 549 | 2 | auto& result_data = result_matches.get_data(); | 550 | 4 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 2 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 2 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 2 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 2 | size_t search_idx = search_is_const ? 0 : row; | 558 | 4 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 2 | result_data[i] &= | 560 | 2 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 2 | search_column, search_idx, search_nullmap) | 562 | 2 | ? 1 | 563 | 2 | : 0; | 564 | 2 | } | 565 | 2 | } | 566 | 2 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_13ColumnDecimalILNS_13PrimitiveTypeE20EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS_12ColumnVectorILS3_2EEE Line | Count | Source | 548 | 2 | ColumnUInt8& result_matches) const { | 549 | 2 | auto& result_data = result_matches.get_data(); | 550 | 4 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 2 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 2 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 2 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 2 | size_t search_idx = search_is_const ? 0 : row; | 558 | 4 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 2 | result_data[i] &= | 560 | 2 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 2 | search_column, search_idx, search_nullmap) | 562 | 2 | ? 1 | 563 | 2 | : 0; | 564 | 2 | } | 565 | 2 | } | 566 | 2 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_13ColumnDecimalILNS_13PrimitiveTypeE30EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS_12ColumnVectorILS3_2EEE Line | Count | Source | 548 | 2 | ColumnUInt8& result_matches) const { | 549 | 2 | auto& result_data = result_matches.get_data(); | 550 | 4 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 2 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 2 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 2 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 2 | size_t search_idx = search_is_const ? 0 : row; | 558 | 4 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 2 | result_data[i] &= | 560 | 2 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 2 | search_column, search_idx, search_nullmap) | 562 | 2 | ? 1 | 563 | 2 | : 0; | 564 | 2 | } | 565 | 2 | } | 566 | 2 | } |
Unexecuted instantiation: _ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_13ColumnDecimalILNS_13PrimitiveTypeE35EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS_12ColumnVectorILS3_2EEE Unexecuted instantiation: _ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE11EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE _ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE25EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Line | Count | Source | 548 | 76 | ColumnUInt8& result_matches) const { | 549 | 76 | auto& result_data = result_matches.get_data(); | 550 | 152 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 76 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 76 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 76 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 76 | size_t search_idx = search_is_const ? 0 : row; | 558 | 160 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 84 | result_data[i] &= | 560 | 84 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 84 | search_column, search_idx, search_nullmap) | 562 | 84 | ? 1 | 563 | 84 | : 0; | 564 | 84 | } | 565 | 76 | } | 566 | 76 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE26EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Line | Count | Source | 548 | 76 | ColumnUInt8& result_matches) const { | 549 | 76 | auto& result_data = result_matches.get_data(); | 550 | 152 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 76 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 76 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 76 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 76 | size_t search_idx = search_is_const ? 0 : row; | 558 | 160 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 84 | result_data[i] &= | 560 | 84 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 84 | search_column, search_idx, search_nullmap) | 562 | 84 | ? 1 | 563 | 84 | : 0; | 564 | 84 | } | 565 | 76 | } | 566 | 76 | } |
Unexecuted instantiation: _ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE12EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Unexecuted instantiation: _ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE27EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Unexecuted instantiation: _ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE42EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE _ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE36EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Line | Count | Source | 548 | 34 | ColumnUInt8& result_matches) const { | 549 | 34 | auto& result_data = result_matches.get_data(); | 550 | 68 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 34 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 34 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 34 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 34 | size_t search_idx = search_is_const ? 0 : row; | 558 | 68 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 34 | result_data[i] &= | 560 | 34 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 34 | search_column, search_idx, search_nullmap) | 562 | 34 | ? 1 | 563 | 34 | : 0; | 564 | 34 | } | 565 | 34 | } | 566 | 34 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_12ColumnVectorILNS_13PrimitiveTypeE37EEEEEvRKNS_7IColumnEPKhS7_S9_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES9_bRNS2_ILS3_2EEE Line | Count | Source | 548 | 34 | ColumnUInt8& result_matches) const { | 549 | 34 | auto& result_data = result_matches.get_data(); | 550 | 68 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 34 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 0 | continue; | 553 | 0 | } | 554 | 34 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 34 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 34 | size_t search_idx = search_is_const ? 0 : row; | 558 | 68 | for (size_t i = map_start; i < map_end; ++i) { | 559 | 34 | result_data[i] &= | 560 | 34 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 34 | search_column, search_idx, search_nullmap) | 562 | 34 | ? 1 | 563 | 34 | : 0; | 564 | 34 | } | 565 | 34 | } | 566 | 34 | } |
_ZNK5doris24FunctionMapContainsEntry26_execute_column_comparisonINS_9ColumnStrIjEEEEvRKNS_7IColumnEPKhS6_S8_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES8_bRNS_12ColumnVectorILNS_13PrimitiveTypeE2EEE Line | Count | Source | 548 | 346 | ColumnUInt8& result_matches) const { | 549 | 346 | auto& result_data = result_matches.get_data(); | 550 | 811 | for (size_t row = 0; row < map_offsets.size(); ++row) { | 551 | 465 | if (map_row_nullmap && map_row_nullmap[row]) { | 552 | 55 | continue; | 553 | 55 | } | 554 | 410 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; | 555 | 410 | size_t map_end = map_offsets[row]; | 556 | | // const column always uses index 0 | 557 | 410 | size_t search_idx = search_is_const ? 0 : row; | 558 | 1.05k | for (size_t i = map_start; i < map_end; ++i) { | 559 | 644 | result_data[i] &= | 560 | 644 | compare_values<ColumnType>(map_entry_column, i, map_entry_nullmap, | 561 | 644 | search_column, search_idx, search_nullmap) | 562 | 644 | ? 1 | 563 | 644 | : 0; | 564 | 644 | } | 565 | 410 | } | 566 | 346 | } |
|
567 | | |
568 | | // dispatch column comparison by type, map_entry_column is the column of map's key or value, search_column is the column of search key or value |
569 | | void _dispatch_column_comparison(PrimitiveType type, const IColumn& map_entry_column, |
570 | | const UInt8* map_entry_nullmap, const IColumn& search_column, |
571 | | const UInt8* search_nullmap, |
572 | | const ColumnArray::Offsets64& map_offsets, |
573 | | const UInt8* map_row_nullmap, bool search_is_const, |
574 | 1.09k | ColumnUInt8& result_matches) const { |
575 | 1.09k | auto call = [&](const auto& type) -> bool { |
576 | 1.09k | using DispatchType = std::decay_t<decltype(type)>; |
577 | | |
578 | 1.09k | _execute_column_comparison<typename DispatchType::ColumnType>( |
579 | 1.09k | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, |
580 | 1.09k | map_row_nullmap, search_is_const, result_matches); |
581 | | |
582 | 1.09k | return true; |
583 | 1.09k | }; _ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_2EEEEEbSJ_ Line | Count | Source | 575 | 42 | auto call = [&](const auto& type) -> bool { | 576 | 42 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 42 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 42 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 42 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 42 | return true; | 583 | 42 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_3EEEEEbSJ_ Line | Count | Source | 575 | 47 | auto call = [&](const auto& type) -> bool { | 576 | 47 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 47 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 47 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 47 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 47 | return true; | 583 | 47 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_4EEEEEbSJ_ Line | Count | Source | 575 | 53 | auto call = [&](const auto& type) -> bool { | 576 | 53 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 53 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 53 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 53 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 53 | return true; | 583 | 53 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_5EEEEEbSJ_ Line | Count | Source | 575 | 232 | auto call = [&](const auto& type) -> bool { | 576 | 232 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 232 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 232 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 232 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 232 | return true; | 583 | 232 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_6EEEEEbSJ_ Line | Count | Source | 575 | 46 | auto call = [&](const auto& type) -> bool { | 576 | 46 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 46 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 46 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 46 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 46 | return true; | 583 | 46 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_7EEEEEbSJ_ Line | Count | Source | 575 | 34 | auto call = [&](const auto& type) -> bool { | 576 | 34 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 34 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 34 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 34 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 34 | return true; | 583 | 34 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_8EEEEEbSJ_ Line | Count | Source | 575 | 34 | auto call = [&](const auto& type) -> bool { | 576 | 34 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 34 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 34 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 34 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 34 | return true; | 583 | 34 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_9EEEEEbSJ_ Line | Count | Source | 575 | 34 | auto call = [&](const auto& type) -> bool { | 576 | 34 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 34 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 34 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 34 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 34 | return true; | 583 | 34 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_28EEEEEbSJ_ Line | Count | Source | 575 | 2 | auto call = [&](const auto& type) -> bool { | 576 | 2 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 2 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 2 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 2 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 2 | return true; | 583 | 2 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_29EEEEEbSJ_ Line | Count | Source | 575 | 2 | auto call = [&](const auto& type) -> bool { | 576 | 2 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 2 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 2 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 2 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 2 | return true; | 583 | 2 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_20EEEEEbSJ_ Line | Count | Source | 575 | 2 | auto call = [&](const auto& type) -> bool { | 576 | 2 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 2 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 2 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 2 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 2 | return true; | 583 | 2 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_30EEEEEbSJ_ Line | Count | Source | 575 | 2 | auto call = [&](const auto& type) -> bool { | 576 | 2 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 2 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 2 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 2 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 2 | return true; | 583 | 2 | }; |
Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_35EEEEEbSJ_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_11EEEEEbSJ_ _ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_25EEEEEbSJ_ Line | Count | Source | 575 | 76 | auto call = [&](const auto& type) -> bool { | 576 | 76 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 76 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 76 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 76 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 76 | return true; | 583 | 76 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_26EEEEEbSJ_ Line | Count | Source | 575 | 76 | auto call = [&](const auto& type) -> bool { | 576 | 76 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 76 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 76 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 76 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 76 | return true; | 583 | 76 | }; |
Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_12EEEEEbSJ_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_27EEEEEbSJ_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_42EEEEEbSJ_ _ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_36EEEEEbSJ_ Line | Count | Source | 575 | 34 | auto call = [&](const auto& type) -> bool { | 576 | 34 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 34 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 34 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 34 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 34 | return true; | 583 | 34 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_37EEEEEbSJ_ Line | Count | Source | 575 | 34 | auto call = [&](const auto& type) -> bool { | 576 | 34 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 34 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 34 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 34 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 34 | return true; | 583 | 34 | }; |
_ZZNK5doris24FunctionMapContainsEntry27_dispatch_column_comparisonENS_13PrimitiveTypeERKNS_7IColumnEPKhS4_S6_RKNS_8PODArrayImLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEES6_bRNS_12ColumnVectorILS1_2EEEENKUlRKT_E_clINS_16DispatchDataTypeILS1_23EEEEEbSJ_ Line | Count | Source | 575 | 346 | auto call = [&](const auto& type) -> bool { | 576 | 346 | using DispatchType = std::decay_t<decltype(type)>; | 577 | | | 578 | 346 | _execute_column_comparison<typename DispatchType::ColumnType>( | 579 | 346 | map_entry_column, map_entry_nullmap, search_column, search_nullmap, map_offsets, | 580 | 346 | map_row_nullmap, search_is_const, result_matches); | 581 | | | 582 | 346 | return true; | 583 | 346 | }; |
|
584 | | |
585 | 1.09k | if (!dispatch_switch_all(type, call)) { |
586 | 0 | throw doris::Exception(ErrorCode::INTERNAL_ERROR, "not support type {}", |
587 | 0 | type_to_string(type)); |
588 | 0 | } |
589 | 1.09k | } |
590 | | |
591 | | // main loop function |
592 | | ColumnPtr _execute_all_rows(const ColumnMap* map_column, const ColumnPtr& map_row_nullmap_col, |
593 | | const IColumn& key_column, const UInt8* key_nullmap, |
594 | | const IColumn& value_column, const UInt8* value_nullmap, |
595 | | PrimitiveType key_type, PrimitiveType value_type, bool key_is_const, |
596 | 548 | bool value_is_const) const { |
597 | 548 | const auto& map_offsets = map_column->get_offsets(); |
598 | | |
599 | | // remove the nullable wrapper of map's key and value |
600 | 548 | const auto& map_keys_nullable = |
601 | 548 | reinterpret_cast<const ColumnNullable&>(map_column->get_keys()); |
602 | 548 | const IColumn* map_keys_column = &map_keys_nullable.get_nested_column(); |
603 | 548 | const auto& map_keys_nullmap = map_keys_nullable.get_null_map_column().get_data().data(); |
604 | | |
605 | 548 | const auto& map_values_nullable = |
606 | 548 | reinterpret_cast<const ColumnNullable&>(map_column->get_values()); |
607 | 548 | const IColumn* map_values_column = &map_values_nullable.get_nested_column(); |
608 | 548 | const auto& map_values_nullmap = |
609 | 548 | map_values_nullable.get_null_map_column().get_data().data(); |
610 | | |
611 | 548 | auto result_column = ColumnUInt8::create(map_offsets.size(), 0); |
612 | 548 | auto& result_data = result_column->get_data(); |
613 | | |
614 | 548 | const UInt8* map_row_nullmap = nullptr; |
615 | 548 | if (map_row_nullmap_col) { |
616 | 207 | map_row_nullmap = |
617 | 207 | assert_cast<const ColumnUInt8&>(*map_row_nullmap_col).get_data().data(); |
618 | 207 | } |
619 | | |
620 | 548 | auto matches = ColumnUInt8::create(map_keys_column->size(), 1); |
621 | | |
622 | | // matches &= key_compare |
623 | 548 | _dispatch_column_comparison(key_type, *map_keys_column, map_keys_nullmap, key_column, |
624 | 548 | key_nullmap, map_offsets, map_row_nullmap, key_is_const, |
625 | 548 | *matches); |
626 | | |
627 | | // matches &= value_compare |
628 | 548 | _dispatch_column_comparison(value_type, *map_values_column, map_values_nullmap, |
629 | 548 | value_column, value_nullmap, map_offsets, map_row_nullmap, |
630 | 548 | value_is_const, *matches); |
631 | | |
632 | | // aggregate results by map boundaries |
633 | 548 | auto& matches_data = matches->get_data(); |
634 | 1.21k | for (size_t row = 0; row < map_offsets.size(); ++row) { |
635 | 667 | if (map_row_nullmap && map_row_nullmap[row]) { |
636 | | // result is null for this row |
637 | 55 | continue; |
638 | 55 | } |
639 | | |
640 | 612 | size_t map_start = row == 0 ? 0 : map_offsets[row - 1]; |
641 | 612 | size_t map_end = map_offsets[row]; |
642 | | |
643 | 612 | bool found = false; |
644 | 1.09k | for (size_t i = map_start; i < map_end && !found; ++i) { |
645 | 820 | if (matches_data[i]) { |
646 | 340 | found = true; |
647 | 340 | break; |
648 | 340 | } |
649 | 820 | } |
650 | 612 | result_data[row] = found; |
651 | 612 | } |
652 | | |
653 | 548 | if (map_row_nullmap_col) { |
654 | 207 | return ColumnNullable::create(std::move(result_column), map_row_nullmap_col); |
655 | 207 | } |
656 | 341 | return result_column; |
657 | 548 | } |
658 | | |
659 | | // type comparability check and dispatch |
660 | | Status _execute_type_check_and_dispatch(Block& block, const ColumnNumbers& arguments, |
661 | 547 | uint32_t result) const { |
662 | | // get type information |
663 | 547 | auto map_type = remove_nullable(block.get_by_position(arguments[0]).type); |
664 | 547 | const auto* map_datatype = assert_cast<const DataTypeMap*>(map_type.get()); |
665 | 547 | auto map_key_type = remove_nullable(map_datatype->get_key_type()); |
666 | 547 | auto map_value_type = remove_nullable(map_datatype->get_value_type()); |
667 | 547 | auto search_key_type = remove_nullable(block.get_by_position(arguments[1]).type); |
668 | 547 | auto search_value_type = remove_nullable(block.get_by_position(arguments[2]).type); |
669 | | |
670 | 547 | PrimitiveType key_primitive_type = map_key_type->get_primitive_type(); |
671 | 547 | PrimitiveType value_primitive_type = map_value_type->get_primitive_type(); |
672 | | |
673 | | // FE should ensure the column types are the same, |
674 | | // but primitive type may be different (eg. TYPE_STRING and TYPE_VARCHAR both use ColumnString) |
675 | | |
676 | | // check whether this function supports equality comparison for the types |
677 | 547 | if (!is_equality_comparison_supported(key_primitive_type) || |
678 | 548 | !is_equality_comparison_supported(value_primitive_type)) { |
679 | 0 | return Status::RuntimeError( |
680 | 0 | "Trying to do equality comparison on unsupported types for function {}. " |
681 | 0 | "Map key type: {}, search key type: {}. " |
682 | 0 | "Map value type: {}, search value type: {}. " |
683 | 0 | "Key primitive type: {}, value primitive type: {}.", |
684 | 0 | get_name(), map_key_type->get_name(), search_key_type->get_name(), |
685 | 0 | map_value_type->get_name(), search_value_type->get_name(), |
686 | 0 | type_to_string(key_primitive_type), type_to_string(value_primitive_type)); |
687 | 0 | } |
688 | | |
689 | | // type check passed, extract columns and execute |
690 | | // extract map column |
691 | 547 | auto map_column_ptr = |
692 | 547 | block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); |
693 | 547 | const ColumnMap* map_column = nullptr; |
694 | 547 | ColumnPtr map_row_nullmap_col = nullptr; |
695 | 547 | if (map_column_ptr->is_nullable()) { |
696 | 207 | const auto* nullable_column = |
697 | 207 | reinterpret_cast<const ColumnNullable*>(map_column_ptr.get()); |
698 | 207 | const auto map_column_guard = |
699 | 207 | check_and_get_column<ColumnMap>(nullable_column->get_nested_column()); |
700 | 207 | if (map_column_guard) { |
701 | 206 | map_column = map_column_guard.get(); |
702 | 206 | } |
703 | 207 | map_row_nullmap_col = nullable_column->get_null_map_column_ptr(); |
704 | 340 | } else { |
705 | 340 | const auto map_column_guard = check_and_get_column<ColumnMap>(*map_column_ptr.get()); |
706 | 341 | if (map_column_guard) { |
707 | 341 | map_column = map_column_guard.get(); |
708 | 341 | } |
709 | 340 | } |
710 | 547 | if (!map_column) { |
711 | 0 | return Status::RuntimeError("unsupported types for function {}({})", get_name(), |
712 | 0 | block.get_by_position(arguments[0]).type->get_name()); |
713 | 0 | } |
714 | | |
715 | | // extract (search) key and value columns |
716 | 547 | const auto& [key_column_ptr, key_is_const] = |
717 | 547 | unpack_if_const(block.get_by_position(arguments[1]).column); |
718 | 547 | const auto& [value_column_ptr, value_is_const] = |
719 | 547 | unpack_if_const(block.get_by_position(arguments[2]).column); |
720 | | |
721 | 547 | const IColumn* key_column = nullptr; |
722 | 547 | const IColumn* value_column = nullptr; |
723 | 547 | const UInt8* key_nullmap = nullptr; |
724 | 547 | const UInt8* value_nullmap = nullptr; |
725 | | |
726 | 547 | if (key_column_ptr->is_nullable()) { |
727 | 42 | const auto* nullable_column = assert_cast<const ColumnNullable*>(key_column_ptr.get()); |
728 | 42 | key_column = &nullable_column->get_nested_column(); |
729 | 42 | key_nullmap = nullable_column->get_null_map_column().get_data().data(); |
730 | 505 | } else { |
731 | 505 | key_column = key_column_ptr.get(); |
732 | 505 | } |
733 | | |
734 | 547 | if (value_column_ptr->is_nullable()) { |
735 | 41 | const auto* nullable_column = |
736 | 41 | assert_cast<const ColumnNullable*>(value_column_ptr.get()); |
737 | 41 | value_column = &nullable_column->get_nested_column(); |
738 | 41 | value_nullmap = nullable_column->get_null_map_column().get_data().data(); |
739 | 506 | } else { |
740 | 506 | value_column = value_column_ptr.get(); |
741 | 506 | } |
742 | | |
743 | 547 | ColumnPtr return_column = |
744 | 547 | _execute_all_rows(map_column, map_row_nullmap_col, *key_column, key_nullmap, |
745 | 547 | *value_column, value_nullmap, key_primitive_type, |
746 | 547 | value_primitive_type, key_is_const, value_is_const); |
747 | | |
748 | 548 | if (return_column) { |
749 | 548 | block.replace_by_position(result, std::move(return_column)); |
750 | 548 | return Status::OK(); |
751 | 548 | } |
752 | | |
753 | 18.4E | return Status::RuntimeError( |
754 | 18.4E | "execute failed or unsupported types for function {}({}, {}, {})", get_name(), |
755 | 18.4E | block.get_by_position(arguments[0]).type->get_name(), |
756 | 18.4E | block.get_by_position(arguments[1]).type->get_name(), |
757 | 18.4E | block.get_by_position(arguments[2]).type->get_name()); |
758 | 547 | } |
759 | | |
760 | | // generic type-specialized comparison function |
761 | | template <typename ColumnType> |
762 | | bool compare_values(const IColumn& left_col, size_t left_idx, const UInt8* left_nullmap, |
763 | | const IColumn& right_col, size_t right_idx, |
764 | 1.70k | const UInt8* right_nullmap) const { |
765 | | // handle null values |
766 | 1.70k | bool left_is_null = left_nullmap && left_nullmap[left_idx]; |
767 | 1.70k | bool right_is_null = right_nullmap && right_nullmap[right_idx]; |
768 | | |
769 | 1.70k | if (left_is_null && right_is_null) { |
770 | 18 | return true; |
771 | 18 | } |
772 | 1.68k | if (left_is_null || right_is_null) { |
773 | 188 | return false; |
774 | 188 | } |
775 | | |
776 | | // use compare_at from typed column |
777 | 1.50k | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); |
778 | 1.50k | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); |
779 | 1.50k | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, |
780 | 1.50k | /*nan_direction_hint=*/1) == 0; |
781 | 1.68k | } _ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE2EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 40 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 40 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 40 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 40 | if (left_is_null && right_is_null) { | 770 | 6 | return true; | 771 | 6 | } | 772 | 34 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 34 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 34 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 34 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 34 | /*nan_direction_hint=*/1) == 0; | 781 | 34 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE3EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 57 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 57 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 57 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 57 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 57 | if (left_is_null || right_is_null) { | 773 | 1 | return false; | 774 | 1 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 56 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 56 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 56 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 56 | /*nan_direction_hint=*/1) == 0; | 781 | 57 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE4EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 67 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 67 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 67 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 67 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 67 | if (left_is_null || right_is_null) { | 773 | 4 | return false; | 774 | 4 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 63 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 63 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 63 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 63 | /*nan_direction_hint=*/1) == 0; | 781 | 67 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE5EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 494 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 494 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 494 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 494 | if (left_is_null && right_is_null) { | 770 | 7 | return true; | 771 | 7 | } | 772 | 487 | if (left_is_null || right_is_null) { | 773 | 94 | return false; | 774 | 94 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 393 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 393 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 393 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 393 | /*nan_direction_hint=*/1) == 0; | 781 | 487 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE6EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 58 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 58 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 58 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 58 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 58 | if (left_is_null || right_is_null) { | 773 | 4 | return false; | 774 | 4 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 54 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 54 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 54 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 54 | /*nan_direction_hint=*/1) == 0; | 781 | 58 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE7EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 34 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 34 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 34 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 34 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 34 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 34 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 34 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 34 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 34 | /*nan_direction_hint=*/1) == 0; | 781 | 34 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE8EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 34 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 34 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 34 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 34 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 34 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 34 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 34 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 34 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 34 | /*nan_direction_hint=*/1) == 0; | 781 | 34 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE9EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 34 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 34 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 34 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 34 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 34 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 34 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 34 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 34 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 34 | /*nan_direction_hint=*/1) == 0; | 781 | 34 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_13ColumnDecimalILNS_13PrimitiveTypeE28EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 2 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 2 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 2 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 2 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 2 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 2 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 2 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 2 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 2 | /*nan_direction_hint=*/1) == 0; | 781 | 2 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_13ColumnDecimalILNS_13PrimitiveTypeE29EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 2 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 2 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 2 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 2 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 2 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 2 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 2 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 2 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 2 | /*nan_direction_hint=*/1) == 0; | 781 | 2 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_13ColumnDecimalILNS_13PrimitiveTypeE20EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 2 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 2 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 2 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 2 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 2 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 2 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 2 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 2 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 2 | /*nan_direction_hint=*/1) == 0; | 781 | 2 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_13ColumnDecimalILNS_13PrimitiveTypeE30EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 2 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 2 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 2 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 2 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 2 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 2 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 2 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 2 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 2 | /*nan_direction_hint=*/1) == 0; | 781 | 2 | } |
Unexecuted instantiation: _ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_13ColumnDecimalILNS_13PrimitiveTypeE35EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Unexecuted instantiation: _ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE11EEEEEbRKNS_7IColumnEmPKhS7_mS9_ _ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE25EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 84 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 84 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 84 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 84 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 84 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 84 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 84 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 84 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 84 | /*nan_direction_hint=*/1) == 0; | 781 | 84 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE26EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 84 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 84 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 84 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 84 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 84 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 84 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 84 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 84 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 84 | /*nan_direction_hint=*/1) == 0; | 781 | 84 | } |
Unexecuted instantiation: _ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE12EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Unexecuted instantiation: _ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE27EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Unexecuted instantiation: _ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE42EEEEEbRKNS_7IColumnEmPKhS7_mS9_ _ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE36EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 34 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 34 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 34 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 34 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 34 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 34 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 34 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 34 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 34 | /*nan_direction_hint=*/1) == 0; | 781 | 34 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_12ColumnVectorILNS_13PrimitiveTypeE37EEEEEbRKNS_7IColumnEmPKhS7_mS9_ Line | Count | Source | 764 | 34 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 34 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 34 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 34 | if (left_is_null && right_is_null) { | 770 | 0 | return true; | 771 | 0 | } | 772 | 34 | if (left_is_null || right_is_null) { | 773 | 0 | return false; | 774 | 0 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 34 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 34 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 34 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 34 | /*nan_direction_hint=*/1) == 0; | 781 | 34 | } |
_ZNK5doris24FunctionMapContainsEntry14compare_valuesINS_9ColumnStrIjEEEEbRKNS_7IColumnEmPKhS6_mS8_ Line | Count | Source | 764 | 644 | const UInt8* right_nullmap) const { | 765 | | // handle null values | 766 | 644 | bool left_is_null = left_nullmap && left_nullmap[left_idx]; | 767 | 644 | bool right_is_null = right_nullmap && right_nullmap[right_idx]; | 768 | | | 769 | 644 | if (left_is_null && right_is_null) { | 770 | 5 | return true; | 771 | 5 | } | 772 | 639 | if (left_is_null || right_is_null) { | 773 | 85 | return false; | 774 | 85 | } | 775 | | | 776 | | // use compare_at from typed column | 777 | 554 | const auto& typed_left_col = assert_cast<const ColumnType&>(left_col); | 778 | 554 | const auto& typed_right_col = assert_cast<const ColumnType&>(right_col); | 779 | 554 | return typed_left_col.compare_at(left_idx, right_idx, typed_right_col, | 780 | 554 | /*nan_direction_hint=*/1) == 0; | 781 | 639 | } |
|
782 | | |
783 | | // whether this function supports equality comparison for the given primitive type. |
784 | | // Uses dispatch_switch_all as the single source of truth so any type supported |
785 | | // by the dispatch layer is automatically accepted here. |
786 | 0 | bool is_equality_comparison_supported(PrimitiveType type) const { |
787 | 0 | return dispatch_switch_all(type, [](const auto&) { return true; });Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_2EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_3EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_4EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_5EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_6EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_7EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_8EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_9EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_28EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_29EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_20EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_30EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_35EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_11EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_25EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_26EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_12EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_27EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_42EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_36EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_37EEEEEDaS4_ Unexecuted instantiation: _ZZNK5doris24FunctionMapContainsEntry32is_equality_comparison_supportedENS_13PrimitiveTypeEENKUlRKT_E_clINS_16DispatchDataTypeILS1_23EEEEEDaS4_ |
788 | 0 | } |
789 | | }; |
790 | | |
791 | | class FunctionDeduplicateMap : public IFunction { |
792 | | public: |
793 | | static constexpr auto name = "deduplicate_map"; |
794 | 10 | static FunctionPtr create() { return std::make_shared<FunctionDeduplicateMap>(); } |
795 | | |
796 | 1 | String get_name() const override { return name; } |
797 | 1 | size_t get_number_of_arguments() const override { return 1; } |
798 | 2 | bool use_default_implementation_for_nulls() const override { return true; } |
799 | | |
800 | 1 | DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
801 | 1 | return arguments[0]; |
802 | 1 | } |
803 | | |
804 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
805 | 1 | uint32_t result, size_t input_rows_count) const override { |
806 | 1 | DCHECK_EQ(arguments.size(), 1); |
807 | 1 | auto col_ptr = block.get_by_position(arguments[0]).column->clone_resized(input_rows_count); |
808 | 1 | auto& col_map = assert_cast<ColumnMap&>(*col_ptr); |
809 | 1 | RETURN_IF_ERROR(col_map.deduplicate_keys()); |
810 | 1 | block.replace_by_position(result, std::move(col_ptr)); |
811 | 1 | return Status::OK(); |
812 | 1 | } |
813 | | |
814 | | private: |
815 | | }; |
816 | | |
817 | 8 | void register_function_map(SimpleFunctionFactory& factory) { |
818 | 8 | factory.register_function<FunctionMap>(); |
819 | 8 | factory.register_function<FunctionMapContains<true>>(); |
820 | 8 | factory.register_function<FunctionMapContains<false>>(); |
821 | 8 | factory.register_function<FunctionMapKeysOrValues<true>>(); |
822 | 8 | factory.register_function<FunctionMapKeysOrValues<false>>(); |
823 | 8 | factory.register_function<FunctionMapEntries>(); |
824 | 8 | factory.register_function<FunctionStrToMap>(); |
825 | 8 | factory.register_function<FunctionMapContainsEntry>(); |
826 | 8 | factory.register_function<FunctionDeduplicateMap>(); |
827 | 8 | } |
828 | | |
829 | | } // namespace doris |