be/src/storage/predicate/predicate_creator.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 "storage/predicate/predicate_creator.h" |
19 | | |
20 | | #include "common/exception.h" |
21 | | #include "exprs/create_predicate_function.h" |
22 | | #include "storage/predicate/bloom_filter_predicate.h" |
23 | | |
24 | | namespace doris { |
25 | | |
26 | | std::shared_ptr<ColumnPredicate> create_bloom_filter_predicate( |
27 | | const uint32_t cid, const std::string col_name, const DataTypePtr& data_type, |
28 | 0 | const std::shared_ptr<BloomFilterFuncBase>& filter) { |
29 | | // Do the necessary type conversion, for CAST(STRING AS CHAR), we do nothing here but change the data type to the target type CHAR |
30 | 0 | std::shared_ptr<BloomFilterFuncBase> filter_olap; |
31 | 0 | filter_olap.reset(create_bloom_filter(data_type->get_primitive_type(), false)); |
32 | 0 | filter_olap->light_copy(filter.get()); |
33 | 0 | switch (data_type->get_primitive_type()) { |
34 | 0 | case TYPE_TINYINT: { |
35 | 0 | return BloomFilterColumnPredicate<TYPE_TINYINT>::create_shared(cid, col_name, filter_olap); |
36 | 0 | } |
37 | 0 | case TYPE_SMALLINT: { |
38 | 0 | return BloomFilterColumnPredicate<TYPE_SMALLINT>::create_shared(cid, col_name, filter_olap); |
39 | 0 | } |
40 | 0 | case TYPE_INT: { |
41 | 0 | return BloomFilterColumnPredicate<TYPE_INT>::create_shared(cid, col_name, filter_olap); |
42 | 0 | } |
43 | 0 | case TYPE_BIGINT: { |
44 | 0 | return BloomFilterColumnPredicate<TYPE_BIGINT>::create_shared(cid, col_name, filter_olap); |
45 | 0 | } |
46 | 0 | case TYPE_LARGEINT: { |
47 | 0 | return BloomFilterColumnPredicate<TYPE_LARGEINT>::create_shared(cid, col_name, filter_olap); |
48 | 0 | } |
49 | 0 | case TYPE_FLOAT: { |
50 | 0 | return BloomFilterColumnPredicate<TYPE_FLOAT>::create_shared(cid, col_name, filter_olap); |
51 | 0 | } |
52 | 0 | case TYPE_DOUBLE: { |
53 | 0 | return BloomFilterColumnPredicate<TYPE_DOUBLE>::create_shared(cid, col_name, filter_olap); |
54 | 0 | } |
55 | 0 | case TYPE_DECIMALV2: { |
56 | 0 | return BloomFilterColumnPredicate<TYPE_DECIMALV2>::create_shared(cid, col_name, |
57 | 0 | filter_olap); |
58 | 0 | } |
59 | 0 | case TYPE_DECIMAL32: { |
60 | 0 | return BloomFilterColumnPredicate<TYPE_DECIMAL32>::create_shared(cid, col_name, |
61 | 0 | filter_olap); |
62 | 0 | } |
63 | 0 | case TYPE_DECIMAL64: { |
64 | 0 | return BloomFilterColumnPredicate<TYPE_DECIMAL64>::create_shared(cid, col_name, |
65 | 0 | filter_olap); |
66 | 0 | } |
67 | 0 | case TYPE_DECIMAL128I: { |
68 | 0 | return BloomFilterColumnPredicate<TYPE_DECIMAL128I>::create_shared(cid, col_name, |
69 | 0 | filter_olap); |
70 | 0 | } |
71 | 0 | case TYPE_DECIMAL256: { |
72 | 0 | return BloomFilterColumnPredicate<TYPE_DECIMAL256>::create_shared(cid, col_name, |
73 | 0 | filter_olap); |
74 | 0 | } |
75 | 0 | case TYPE_CHAR: { |
76 | 0 | return BloomFilterColumnPredicate<TYPE_CHAR>::create_shared(cid, col_name, filter_olap); |
77 | 0 | } |
78 | 0 | case TYPE_VARCHAR: { |
79 | 0 | return BloomFilterColumnPredicate<TYPE_VARCHAR>::create_shared(cid, col_name, filter_olap); |
80 | 0 | } |
81 | 0 | case TYPE_STRING: { |
82 | 0 | return BloomFilterColumnPredicate<TYPE_STRING>::create_shared(cid, col_name, filter_olap); |
83 | 0 | } |
84 | 0 | case TYPE_DATE: { |
85 | 0 | return BloomFilterColumnPredicate<TYPE_DATE>::create_shared(cid, col_name, filter_olap); |
86 | 0 | } |
87 | 0 | case TYPE_DATEV2: { |
88 | 0 | return BloomFilterColumnPredicate<TYPE_DATEV2>::create_shared(cid, col_name, filter_olap); |
89 | 0 | } |
90 | 0 | case TYPE_DATETIME: { |
91 | 0 | return BloomFilterColumnPredicate<TYPE_DATETIME>::create_shared(cid, col_name, filter_olap); |
92 | 0 | } |
93 | 0 | case TYPE_DATETIMEV2: { |
94 | 0 | return BloomFilterColumnPredicate<TYPE_DATETIMEV2>::create_shared(cid, col_name, |
95 | 0 | filter_olap); |
96 | 0 | } |
97 | 0 | case TYPE_TIMESTAMPTZ: { |
98 | 0 | return BloomFilterColumnPredicate<TYPE_TIMESTAMPTZ>::create_shared(cid, col_name, |
99 | 0 | filter_olap); |
100 | 0 | } |
101 | 0 | case TYPE_BOOLEAN: { |
102 | 0 | return BloomFilterColumnPredicate<TYPE_BOOLEAN>::create_shared(cid, col_name, filter_olap); |
103 | 0 | } |
104 | 0 | case TYPE_IPV4: { |
105 | 0 | return BloomFilterColumnPredicate<TYPE_IPV4>::create_shared(cid, col_name, filter_olap); |
106 | 0 | } |
107 | 0 | case TYPE_IPV6: { |
108 | 0 | return BloomFilterColumnPredicate<TYPE_IPV6>::create_shared(cid, col_name, filter_olap); |
109 | 0 | } |
110 | 0 | default: |
111 | 0 | throw Exception(ErrorCode::INVALID_ARGUMENT, |
112 | 0 | fmt::format("Cannot use bloom filter for type: {}", |
113 | 0 | type_to_string(data_type->get_primitive_type()))); |
114 | 0 | return nullptr; |
115 | 0 | } |
116 | 0 | } |
117 | | |
118 | | } // namespace doris |