be/src/exprs/function/array/function_array_intersect.cpp
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 "core/assert_cast.h" |
19 | | #include "core/column/column_const.h" |
20 | | #include "exprs/function/array/function_array_binary.h" |
21 | | #include "exprs/function/array/function_array_map.h" |
22 | | #include "exprs/function/array/function_array_nary.h" |
23 | | #include "exprs/function/simple_function_factory.h" |
24 | | |
25 | | namespace doris { |
26 | | |
27 | | #include "common/compile_check_begin.h" |
28 | | struct NameArrayIntersect { |
29 | | static constexpr auto name = "array_intersect"; |
30 | | }; |
31 | | |
32 | | template <typename Map, typename ColumnType> |
33 | | struct IntersectAction { |
34 | | // True if current has null element |
35 | | bool current_null_flag = false; |
36 | | // True if result_set has null element |
37 | | bool result_null_flag = true; |
38 | | // True if it should execute the left array first. |
39 | | typename Map::mapped_type* value = nullptr; |
40 | | |
41 | | // Handle Null element. |
42 | 0 | bool apply_null() { return result_null_flag; }Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIhmNS1_4HashIhEENS1_7EqualToIhEESaISt4pairIKhmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE2EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIamNS1_4HashIaEENS1_7EqualToIaEESaISt4pairIKamEEEENS_12ColumnVectorILNS_13PrimitiveTypeE3EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIsmNS1_4HashIsEENS1_7EqualToIsEESaISt4pairIKsmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE4EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIimNS1_4HashIiEENS1_7EqualToIiEESaISt4pairIKimEEEENS_12ColumnVectorILNS_13PrimitiveTypeE5EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIlmNS1_4HashIlEENS1_7EqualToIlEESaISt4pairIKlmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE6EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapInmNS1_4HashInEENS1_7EqualToInEESaISt4pairIKnmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE7EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIfmNS1_4HashIfEENS1_7EqualToIfEESaISt4pairIKfmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE8EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIdmNS1_4HashIdEENS1_7EqualToIdEESaISt4pairIKdmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE9EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIimNS1_4HashIiEENS1_7EqualToIiEESaISt4pairIKimEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE28EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIlmNS1_4HashIlEENS1_7EqualToIlEESaISt4pairIKlmEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE29EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapInmNS1_4HashInEENS1_7EqualToInEESaISt4pairIKnmEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE30EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapInmNS1_4HashInEENS1_7EqualToInEESaISt4pairIKnmEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE20EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIN4wide7integerILm256EiEEmNS1_4HashIS5_EENS1_7EqualToIS5_EESaISt4pairIKS5_mEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE35EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_16VecDateTimeValueEmNS1_4HashIS3_EENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE11EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_16VecDateTimeValueEmNS1_4HashIS3_EENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE12EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_11DateV2ValueINS_15DateV2ValueTypeEEEmNS1_4HashIS5_EENS1_7EqualToIS5_EESaISt4pairIKS5_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE25EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEEmNS1_4HashIS5_EENS1_7EqualToIS5_EESaISt4pairIKS5_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE26EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_16TimestampTzValueEmNS1_4HashIS3_EENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE42EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_9StringRefEmNS_13StringRefHashENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_9ColumnStrIjEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIjmNS1_4HashIjEENS1_7EqualToIjEESaISt4pairIKjmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE36EEEE10apply_nullEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIomNS1_4HashIoEENS1_7EqualToIoEESaISt4pairIKomEEEENS_12ColumnVectorILNS_13PrimitiveTypeE37EEEE10apply_nullEv |
43 | | |
44 | | // Handle Non-Null element. |
45 | | void apply(Map& map, const size_t arg_idx, const size_t row_idx, |
46 | 0 | const ColumnArrayExecutionData& param) { |
47 | 0 | current_null_flag = false; |
48 | 0 | size_t start_off = (*param.offsets_ptr)[row_idx - 1]; |
49 | 0 | size_t end_off = (*param.offsets_ptr)[row_idx]; |
50 | 0 | for (size_t off = start_off; off < end_off; ++off) { |
51 | 0 | if (param.nested_nullmap_data && param.nested_nullmap_data[off]) { |
52 | 0 | current_null_flag = true; |
53 | 0 | } else { |
54 | 0 | if constexpr (std::is_same_v<ColumnString, ColumnType>) { |
55 | 0 | value = &map[param.nested_col->get_data_at(off)]; |
56 | 0 | } else { |
57 | 0 | auto& data_col = static_cast<const ColumnType&>(*param.nested_col); |
58 | 0 | value = &map[data_col.get_element(off)]; |
59 | 0 | } |
60 | 0 | if (*value == arg_idx) { |
61 | 0 | ++(*value); |
62 | 0 | } |
63 | 0 | } |
64 | 0 | } |
65 | 0 | if (!current_null_flag) { |
66 | 0 | result_null_flag = false; |
67 | 0 | } |
68 | 0 | } Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIhmNS1_4HashIhEENS1_7EqualToIhEESaISt4pairIKhmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE2EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIamNS1_4HashIaEENS1_7EqualToIaEESaISt4pairIKamEEEENS_12ColumnVectorILNS_13PrimitiveTypeE3EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIsmNS1_4HashIsEENS1_7EqualToIsEESaISt4pairIKsmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE4EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIimNS1_4HashIiEENS1_7EqualToIiEESaISt4pairIKimEEEENS_12ColumnVectorILNS_13PrimitiveTypeE5EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIlmNS1_4HashIlEENS1_7EqualToIlEESaISt4pairIKlmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE6EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapInmNS1_4HashInEENS1_7EqualToInEESaISt4pairIKnmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE7EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIfmNS1_4HashIfEENS1_7EqualToIfEESaISt4pairIKfmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE8EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIdmNS1_4HashIdEENS1_7EqualToIdEESaISt4pairIKdmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE9EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIimNS1_4HashIiEENS1_7EqualToIiEESaISt4pairIKimEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE28EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIlmNS1_4HashIlEENS1_7EqualToIlEESaISt4pairIKlmEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE29EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapInmNS1_4HashInEENS1_7EqualToInEESaISt4pairIKnmEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE30EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapInmNS1_4HashInEENS1_7EqualToInEESaISt4pairIKnmEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE20EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIN4wide7integerILm256EiEEmNS1_4HashIS5_EENS1_7EqualToIS5_EESaISt4pairIKS5_mEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE35EEEE5applyERSE_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_16VecDateTimeValueEmNS1_4HashIS3_EENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE11EEEE5applyERSC_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_16VecDateTimeValueEmNS1_4HashIS3_EENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE12EEEE5applyERSC_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_11DateV2ValueINS_15DateV2ValueTypeEEEmNS1_4HashIS5_EENS1_7EqualToIS5_EESaISt4pairIKS5_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE25EEEE5applyERSE_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEEmNS1_4HashIS5_EENS1_7EqualToIS5_EESaISt4pairIKS5_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE26EEEE5applyERSE_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_16TimestampTzValueEmNS1_4HashIS3_EENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE42EEEE5applyERSC_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_9StringRefEmNS_13StringRefHashENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_9ColumnStrIjEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIjmNS1_4HashIjEENS1_7EqualToIjEESaISt4pairIKjmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE36EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIomNS1_4HashIoEENS1_7EqualToIoEESaISt4pairIKomEEEENS_12ColumnVectorILNS_13PrimitiveTypeE37EEEE5applyERSB_mmRKNS_24ColumnArrayExecutionDataE |
69 | | |
70 | 0 | void reset() { |
71 | 0 | current_null_flag = false; |
72 | 0 | result_null_flag = true; |
73 | 0 | } Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIhmNS1_4HashIhEENS1_7EqualToIhEESaISt4pairIKhmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE2EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIamNS1_4HashIaEENS1_7EqualToIaEESaISt4pairIKamEEEENS_12ColumnVectorILNS_13PrimitiveTypeE3EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIsmNS1_4HashIsEENS1_7EqualToIsEESaISt4pairIKsmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE4EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIimNS1_4HashIiEENS1_7EqualToIiEESaISt4pairIKimEEEENS_12ColumnVectorILNS_13PrimitiveTypeE5EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIlmNS1_4HashIlEENS1_7EqualToIlEESaISt4pairIKlmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE6EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapInmNS1_4HashInEENS1_7EqualToInEESaISt4pairIKnmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE7EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIfmNS1_4HashIfEENS1_7EqualToIfEESaISt4pairIKfmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE8EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIdmNS1_4HashIdEENS1_7EqualToIdEESaISt4pairIKdmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE9EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIimNS1_4HashIiEENS1_7EqualToIiEESaISt4pairIKimEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE28EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIlmNS1_4HashIlEENS1_7EqualToIlEESaISt4pairIKlmEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE29EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapInmNS1_4HashInEENS1_7EqualToInEESaISt4pairIKnmEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE30EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapInmNS1_4HashInEENS1_7EqualToInEESaISt4pairIKnmEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE20EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIN4wide7integerILm256EiEEmNS1_4HashIS5_EENS1_7EqualToIS5_EESaISt4pairIKS5_mEEEENS_13ColumnDecimalILNS_13PrimitiveTypeE35EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_16VecDateTimeValueEmNS1_4HashIS3_EENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE11EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_16VecDateTimeValueEmNS1_4HashIS3_EENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE12EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_11DateV2ValueINS_15DateV2ValueTypeEEEmNS1_4HashIS5_EENS1_7EqualToIS5_EESaISt4pairIKS5_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE25EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEEmNS1_4HashIS5_EENS1_7EqualToIS5_EESaISt4pairIKS5_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE26EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_16TimestampTzValueEmNS1_4HashIS3_EENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_12ColumnVectorILNS_13PrimitiveTypeE42EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapINS_9StringRefEmNS_13StringRefHashENS1_7EqualToIS3_EESaISt4pairIKS3_mEEEENS_9ColumnStrIjEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIjmNS1_4HashIjEENS1_7EqualToIjEESaISt4pairIKjmEEEENS_12ColumnVectorILNS_13PrimitiveTypeE36EEEE5resetEv Unexecuted instantiation: _ZN5doris15IntersectActionIN5phmap13flat_hash_mapIomNS1_4HashIoEENS1_7EqualToIoEESaISt4pairIKomEEEENS_12ColumnVectorILNS_13PrimitiveTypeE37EEEE5resetEv |
74 | | }; |
75 | | |
76 | | using FunctionArrayIntersect = |
77 | | FunctionArrayNary<ArrayMapImpl<MapOperation::INTERSECT>, NameArrayIntersect>; |
78 | | |
79 | 1 | void register_function_array_intersect(SimpleFunctionFactory& factory) { |
80 | 1 | factory.register_function<FunctionArrayIntersect>(); |
81 | 1 | } |
82 | | |
83 | | } // namespace doris |