Coverage Report

Created: 2025-12-26 15:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/be/src/olap/column_predicate.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <memory>
21
#include <roaring/roaring.hh>
22
23
#include "common/exception.h"
24
#include "olap/rowset/segment_v2/bloom_filter.h"
25
#include "olap/rowset/segment_v2/inverted_index_iterator.h"
26
#include "runtime/define_primitive_type.h"
27
#include "util/defer_op.h"
28
#include "util/runtime_profile.h"
29
#include "vec/columns/column.h"
30
#include "vec/exec/format/parquet/parquet_predicate.h"
31
#include "vec/exprs/vruntimefilter_wrapper.h"
32
33
using namespace doris::segment_v2;
34
35
namespace doris {
36
37
enum class PredicateType {
38
    UNKNOWN = 0,
39
    EQ = 1,
40
    NE = 2,
41
    LT = 3,
42
    LE = 4,
43
    GT = 5,
44
    GE = 6,
45
    IN_LIST = 7,
46
    NOT_IN_LIST = 8,
47
    IS_NULL = 9,
48
    IS_NOT_NULL = 10,
49
    BF = 11,            // BloomFilter
50
    BITMAP_FILTER = 12, // BitmapFilter
51
    MATCH = 13,         // fulltext match
52
};
53
54
template <PrimitiveType primitive_type, typename ResultType>
55
1.16k
ResultType get_zone_map_value(void* data_ptr) {
56
1.16k
    ResultType res;
57
    // DecimalV2's storage value is different from predicate or compute value type
58
    // need convert it to DecimalV2Value
59
1.16k
    if constexpr (primitive_type == PrimitiveType::TYPE_DECIMALV2) {
60
0
        decimal12_t decimal_12_t_value;
61
0
        memcpy((char*)(&decimal_12_t_value), data_ptr, sizeof(decimal12_t));
62
0
        res.from_olap_decimal(decimal_12_t_value.integer, decimal_12_t_value.fraction);
63
0
    } else if constexpr (primitive_type == PrimitiveType::TYPE_DATE) {
64
0
        static_assert(std::is_same_v<ResultType, VecDateTimeValue>);
65
0
        uint24_t date;
66
0
        memcpy(&date, data_ptr, sizeof(uint24_t));
67
0
        res.from_olap_date(date);
68
0
    } else if constexpr (primitive_type == PrimitiveType::TYPE_DATETIME) {
69
0
        static_assert(std::is_same_v<ResultType, VecDateTimeValue>);
70
0
        uint64_t datetime;
71
0
        memcpy(&datetime, data_ptr, sizeof(uint64_t));
72
0
        res.from_olap_datetime(datetime);
73
1.16k
    } else {
74
1.16k
        memcpy(reinterpret_cast<void*>(&res), data_ptr, sizeof(ResultType));
75
1.16k
    }
76
1.16k
    return res;
77
1.16k
}
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE5EiEET0_Pv
_ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE9EdEET0_Pv
Line
Count
Source
55
1.06k
ResultType get_zone_map_value(void* data_ptr) {
56
1.06k
    ResultType res;
57
    // DecimalV2's storage value is different from predicate or compute value type
58
    // need convert it to DecimalV2Value
59
    if constexpr (primitive_type == PrimitiveType::TYPE_DECIMALV2) {
60
        decimal12_t decimal_12_t_value;
61
        memcpy((char*)(&decimal_12_t_value), data_ptr, sizeof(decimal12_t));
62
        res.from_olap_decimal(decimal_12_t_value.integer, decimal_12_t_value.fraction);
63
    } else if constexpr (primitive_type == PrimitiveType::TYPE_DATE) {
64
        static_assert(std::is_same_v<ResultType, VecDateTimeValue>);
65
        uint24_t date;
66
        memcpy(&date, data_ptr, sizeof(uint24_t));
67
        res.from_olap_date(date);
68
    } else if constexpr (primitive_type == PrimitiveType::TYPE_DATETIME) {
69
        static_assert(std::is_same_v<ResultType, VecDateTimeValue>);
70
        uint64_t datetime;
71
        memcpy(&datetime, data_ptr, sizeof(uint64_t));
72
        res.from_olap_datetime(datetime);
73
1.06k
    } else {
74
1.06k
        memcpy(reinterpret_cast<void*>(&res), data_ptr, sizeof(ResultType));
75
1.06k
    }
76
1.06k
    return res;
77
1.06k
}
_ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE42ENS_16TimestampTzValueEEET0_Pv
Line
Count
Source
55
96
ResultType get_zone_map_value(void* data_ptr) {
56
96
    ResultType res;
57
    // DecimalV2's storage value is different from predicate or compute value type
58
    // need convert it to DecimalV2Value
59
    if constexpr (primitive_type == PrimitiveType::TYPE_DECIMALV2) {
60
        decimal12_t decimal_12_t_value;
61
        memcpy((char*)(&decimal_12_t_value), data_ptr, sizeof(decimal12_t));
62
        res.from_olap_decimal(decimal_12_t_value.integer, decimal_12_t_value.fraction);
63
    } else if constexpr (primitive_type == PrimitiveType::TYPE_DATE) {
64
        static_assert(std::is_same_v<ResultType, VecDateTimeValue>);
65
        uint24_t date;
66
        memcpy(&date, data_ptr, sizeof(uint24_t));
67
        res.from_olap_date(date);
68
    } else if constexpr (primitive_type == PrimitiveType::TYPE_DATETIME) {
69
        static_assert(std::is_same_v<ResultType, VecDateTimeValue>);
70
        uint64_t datetime;
71
        memcpy(&datetime, data_ptr, sizeof(uint64_t));
72
        res.from_olap_datetime(datetime);
73
96
    } else {
74
96
        memcpy(reinterpret_cast<void*>(&res), data_ptr, sizeof(ResultType));
75
96
    }
76
96
    return res;
77
96
}
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE8EfEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE11ENS_16VecDateTimeValueEEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE12ENS_16VecDateTimeValueEEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE6ElEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE2EbEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE3EaEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE4EsEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE7EnEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE20ENS_14DecimalV2ValueEEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE28ENS_10vectorized7DecimalIiEEEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE29ENS_10vectorized7DecimalIlEEEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE30ENS_10vectorized12Decimal128V3EEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE35ENS_10vectorized7DecimalIN4wide7integerILm256EiEEEEEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE15ENS_9StringRefEEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE10ENS_9StringRefEEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE23ENS_9StringRefEEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE25ENS_11DateV2ValueINS_15DateV2ValueTypeEEEEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE26ENS_11DateV2ValueINS_19DateTimeV2ValueTypeEEEEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE36EjEET0_Pv
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE37EoEET0_Pv
78
79
0
inline std::string type_to_string(PredicateType type) {
80
0
    switch (type) {
81
0
    case PredicateType::UNKNOWN:
82
0
        return "UNKNOWN";
83
0
84
0
    case PredicateType::EQ:
85
0
        return "EQ";
86
0
87
0
    case PredicateType::NE:
88
0
        return "NE";
89
0
90
0
    case PredicateType::LT:
91
0
        return "LT";
92
0
93
0
    case PredicateType::LE:
94
0
        return "LE";
95
0
96
0
    case PredicateType::GT:
97
0
        return "GT";
98
0
99
0
    case PredicateType::GE:
100
0
        return "GE";
101
0
102
0
    case PredicateType::IN_LIST:
103
0
        return "IN_LIST";
104
0
105
0
    case PredicateType::NOT_IN_LIST:
106
0
        return "NOT_IN_LIST";
107
0
108
0
    case PredicateType::IS_NULL:
109
0
        return "IS_NULL";
110
0
111
0
    case PredicateType::IS_NOT_NULL:
112
0
        return "IS_NOT_NULL";
113
0
114
0
    case PredicateType::BF:
115
0
        return "BF";
116
0
    default:
117
0
        return "";
118
0
    };
119
0
120
0
    return "";
121
0
}
122
123
0
inline std::string type_to_op_str(PredicateType type) {
124
0
    switch (type) {
125
0
    case PredicateType::EQ:
126
0
        return "=";
127
128
0
    case PredicateType::NE:
129
0
        return "!=";
130
131
0
    case PredicateType::LT:
132
0
        return "<<";
133
134
0
    case PredicateType::LE:
135
0
        return "<=";
136
137
0
    case PredicateType::GT:
138
0
        return ">>";
139
140
0
    case PredicateType::GE:
141
0
        return ">=";
142
143
0
    case PredicateType::IN_LIST:
144
0
        return "*=";
145
146
0
    case PredicateType::NOT_IN_LIST:
147
0
        return "!*=";
148
149
0
    case PredicateType::IS_NULL:
150
0
    case PredicateType::IS_NOT_NULL:
151
0
        return "is";
152
153
0
    default:
154
0
        break;
155
0
    };
156
157
0
    return "";
158
0
}
159
160
struct PredicateTypeTraits {
161
467
    static constexpr bool is_range(PredicateType type) {
162
467
        return (type == PredicateType::LT || type == PredicateType::LE ||
163
467
                type == PredicateType::GT || type == PredicateType::GE);
164
467
    }
165
166
140
    static constexpr bool is_bloom_filter(PredicateType type) { return type == PredicateType::BF; }
167
168
0
    static constexpr bool is_list(PredicateType type) {
169
0
        return (type == PredicateType::IN_LIST || type == PredicateType::NOT_IN_LIST);
170
0
    }
171
172
0
    static constexpr bool is_equal_or_list(PredicateType type) {
173
0
        return (type == PredicateType::EQ || type == PredicateType::IN_LIST);
174
0
    }
175
176
0
    static constexpr bool is_comparison(PredicateType type) {
177
0
        return (type == PredicateType::EQ || type == PredicateType::NE ||
178
0
                type == PredicateType::LT || type == PredicateType::LE ||
179
0
                type == PredicateType::GT || type == PredicateType::GE);
180
0
    }
181
};
182
183
#define EVALUATE_BY_SELECTOR(EVALUATE_IMPL_WITH_NULL_MAP, EVALUATE_IMPL_WITHOUT_NULL_MAP) \
184
4.19k
    const bool is_dense_column = pred_col.size() == size;                                 \
185
3.90M
    for (uint16_t i = 0; i < size; i++) {                                                 \
186
3.90M
        uint16_t idx = is_dense_column ? i : sel[i];                                      \
187
3.90M
        if constexpr (is_nullable) {                                                      \
188
9.40k
            if (EVALUATE_IMPL_WITH_NULL_MAP(idx)) {                                       \
189
9.01k
                sel[new_size++] = idx;                                                    \
190
9.01k
            }                                                                             \
191
3.89M
        } else {                                                                          \
192
3.89M
            if (EVALUATE_IMPL_WITHOUT_NULL_MAP(idx)) {                                    \
193
3.68M
                sel[new_size++] = idx;                                                    \
194
3.68M
            }                                                                             \
195
3.89M
        }                                                                                 \
196
3.90M
    }
197
198
class ColumnPredicate : public std::enable_shared_from_this<ColumnPredicate> {
199
public:
200
    explicit ColumnPredicate(uint32_t column_id, PrimitiveType primitive_type,
201
                             bool opposite = false)
202
932
            : _column_id(column_id), _primitive_type(primitive_type), _opposite(opposite) {
203
932
        reset_judge_selectivity();
204
932
    }
205
0
    ColumnPredicate(const ColumnPredicate& other, uint32_t col_id) : ColumnPredicate(other) {
206
0
        _column_id = col_id;
207
0
    }
208
209
932
    virtual ~ColumnPredicate() = default;
210
211
    virtual PredicateType type() const = 0;
212
0
    virtual PrimitiveType primitive_type() const { return _primitive_type; }
213
    virtual std::shared_ptr<ColumnPredicate> clone(uint32_t col_id) const = 0;
214
215
    //evaluate predicate on inverted
216
    virtual Status evaluate(const vectorized::IndexFieldNameAndTypePair& name_with_type,
217
                            IndexIterator* iterator, uint32_t num_rows,
218
0
                            roaring::Roaring* bitmap) const {
219
0
        return Status::NotSupported(
220
0
                "Not Implemented evaluate with inverted index, please check the predicate");
221
0
    }
222
223
0
    virtual double get_ignore_threshold() const { return 0; }
224
    // Return the size of value set for IN/NOT IN predicates and 0 for others.
225
0
    virtual std::string debug_string() const {
226
0
        fmt::memory_buffer debug_string_buffer;
227
0
        fmt::format_to(debug_string_buffer,
228
0
                       "Column ID: {}, Data Type: {}, PredicateType: {}, opposite: {}, Runtime "
229
0
                       "Filter ID: {}",
230
0
                       _column_id, type_to_string(primitive_type()), pred_type_string(type()),
231
0
                       _opposite, _runtime_filter_id);
232
0
        return fmt::to_string(debug_string_buffer);
233
0
    }
234
235
    // evaluate predicate on IColumn
236
    // a short circuit eval way
237
4.20k
    uint16_t evaluate(const vectorized::IColumn& column, uint16_t* sel, uint16_t size) const {
238
4.20k
        Defer defer([&] { try_reset_judge_selectivity(); });
239
240
4.20k
        if (always_true()) {
241
0
            update_filter_info(0, 0, size);
242
0
            return size;
243
0
        }
244
245
4.20k
        uint16_t new_size = _evaluate_inner(column, sel, size);
246
4.20k
        if (_can_ignore()) {
247
0
            do_judge_selectivity(size - new_size, size);
248
0
        }
249
4.20k
        update_filter_info(size - new_size, size, 0);
250
4.20k
        return new_size;
251
4.20k
    }
252
    virtual void evaluate_and(const vectorized::IColumn& column, const uint16_t* sel, uint16_t size,
253
0
                              bool* flags) const {}
254
    virtual void evaluate_or(const vectorized::IColumn& column, const uint16_t* sel, uint16_t size,
255
0
                             bool* flags) const {}
256
257
0
    virtual bool support_zonemap() const { return true; }
258
259
0
    virtual bool evaluate_and(const std::pair<WrapperField*, WrapperField*>& statistic) const {
260
0
        return true;
261
0
    }
262
263
0
    virtual bool is_always_true(const std::pair<WrapperField*, WrapperField*>& statistic) const {
264
0
        return false;
265
0
    }
266
267
0
    virtual bool evaluate_del(const std::pair<WrapperField*, WrapperField*>& statistic) const {
268
0
        return false;
269
0
    }
270
271
0
    virtual bool evaluate_and(const vectorized::ParquetBlockSplitBloomFilter* bf) const {
272
0
        return true;
273
0
    }
274
275
0
    virtual bool evaluate_and(const BloomFilter* bf) const { return true; }
276
277
0
    virtual bool evaluate_and(const StringRef* dict_words, const size_t dict_count) const {
278
0
        return true;
279
0
    }
280
281
0
    virtual bool can_do_bloom_filter(bool ngram) const { return false; }
282
283
    /**
284
     * Figure out whether this page is matched partially or completely.
285
     */
286
0
    virtual bool evaluate_and(vectorized::ParquetPredicate::ColumnStat* statistic) const {
287
0
        throw Exception(ErrorCode::INTERNAL_ERROR,
288
0
                        "ParquetPredicate is not supported by this predicate!");
289
0
        return true;
290
0
    }
291
292
    virtual bool evaluate_and(vectorized::ParquetPredicate::CachedPageIndexStat* statistic,
293
0
                              RowRanges* row_ranges) const {
294
0
        throw Exception(ErrorCode::INTERNAL_ERROR,
295
0
                        "ParquetPredicate is not supported by this predicate!");
296
0
        return true;
297
0
    }
298
299
    // used to evaluate pre read column in lazy materialization
300
    // now only support integer/float
301
    // a vectorized eval way
302
0
    virtual void evaluate_vec(const vectorized::IColumn& column, uint16_t size, bool* flags) const {
303
0
        DCHECK(false) << "should not reach here";
304
0
    }
305
    virtual void evaluate_and_vec(const vectorized::IColumn& column, uint16_t size,
306
0
                                  bool* flags) const {
307
0
        DCHECK(false) << "should not reach here";
308
0
    }
309
310
0
    virtual std::string get_search_str() const {
311
0
        DCHECK(false) << "should not reach here";
312
0
        return "";
313
0
    }
314
315
0
    virtual void set_page_ng_bf(std::unique_ptr<segment_v2::BloomFilter>) {
316
0
        DCHECK(false) << "should not reach here";
317
0
    }
318
15.2k
    uint32_t column_id() const { return _column_id; }
319
320
0
    bool opposite() const { return _opposite; }
321
322
    void attach_profile_counter(
323
            int filter_id, std::shared_ptr<RuntimeProfile::Counter> predicate_filtered_rows_counter,
324
            std::shared_ptr<RuntimeProfile::Counter> predicate_input_rows_counter,
325
0
            std::shared_ptr<RuntimeProfile::Counter> predicate_always_true_rows_counter) {
326
0
        _runtime_filter_id = filter_id;
327
0
        DCHECK(predicate_filtered_rows_counter != nullptr);
328
0
        DCHECK(predicate_input_rows_counter != nullptr);
329
330
0
        if (predicate_filtered_rows_counter != nullptr) {
331
0
            _predicate_filtered_rows_counter = predicate_filtered_rows_counter;
332
0
        }
333
0
        if (predicate_input_rows_counter != nullptr) {
334
0
            _predicate_input_rows_counter = predicate_input_rows_counter;
335
0
        }
336
0
        if (predicate_always_true_rows_counter != nullptr) {
337
0
            _predicate_always_true_rows_counter = predicate_always_true_rows_counter;
338
0
        }
339
0
    }
340
341
    /// TODO: Currently we only record statistics for runtime filters, in the future we should record for all predicates
342
    void update_filter_info(int64_t filter_rows, int64_t input_rows,
343
4.20k
                            int64_t always_true_rows) const {
344
4.20k
        if (_predicate_input_rows_counter == nullptr ||
345
4.20k
            _predicate_filtered_rows_counter == nullptr ||
346
4.20k
            _predicate_always_true_rows_counter == nullptr) {
347
0
            throw Exception(INTERNAL_ERROR, "Predicate profile counters are not initialized");
348
0
        }
349
4.20k
        COUNTER_UPDATE(_predicate_input_rows_counter, input_rows);
350
4.20k
        COUNTER_UPDATE(_predicate_filtered_rows_counter, filter_rows);
351
4.20k
        COUNTER_UPDATE(_predicate_always_true_rows_counter, always_true_rows);
352
4.20k
    }
353
354
0
    static std::string pred_type_string(PredicateType type) {
355
0
        switch (type) {
356
0
        case PredicateType::EQ:
357
0
            return "eq";
358
0
        case PredicateType::NE:
359
0
            return "ne";
360
0
        case PredicateType::LT:
361
0
            return "lt";
362
0
        case PredicateType::LE:
363
0
            return "le";
364
0
        case PredicateType::GT:
365
0
            return "gt";
366
0
        case PredicateType::GE:
367
0
            return "ge";
368
0
        case PredicateType::IN_LIST:
369
0
            return "in";
370
0
        case PredicateType::NOT_IN_LIST:
371
0
            return "not_in";
372
0
        case PredicateType::IS_NULL:
373
0
            return "is_null";
374
0
        case PredicateType::IS_NOT_NULL:
375
0
            return "is_not_null";
376
0
        case PredicateType::BF:
377
0
            return "bf";
378
0
        case PredicateType::MATCH:
379
0
            return "match";
380
0
        default:
381
0
            return "unknown";
382
0
        }
383
0
    }
384
385
4.20k
    bool always_true() const { return _always_true; }
386
    // Return whether the ColumnPredicate was created by a runtime filter.
387
    // If true, it was definitely created by a runtime filter.
388
    // If false, it may still have been created by a runtime filter,
389
    // as certain filters like "in filter" generate key ranges instead of ColumnPredicate.
390
    // is_runtime_filter uses _can_ignore, except for BitmapFilter,
391
    // as BitmapFilter cannot ignore data.
392
0
    virtual bool is_runtime_filter() const { return _can_ignore(); }
393
394
protected:
395
8.40k
    virtual bool _can_ignore() const { return _runtime_filter_id != -1; }
396
    virtual uint16_t _evaluate_inner(const vectorized::IColumn& column, uint16_t* sel,
397
0
                                     uint16_t size) const {
398
0
        throw Exception(INTERNAL_ERROR, "Not Implemented _evaluate_inner");
399
0
    }
400
401
932
    void reset_judge_selectivity() const {
402
932
        _always_true = false;
403
932
        _judge_counter = config::runtime_filter_sampling_frequency;
404
932
        _judge_input_rows = 0;
405
932
        _judge_filter_rows = 0;
406
932
    }
407
408
4.20k
    void try_reset_judge_selectivity() const {
409
4.20k
        if (_can_ignore() && ((_judge_counter--) == 0)) {
410
0
            reset_judge_selectivity();
411
0
        }
412
4.20k
    }
413
414
0
    void do_judge_selectivity(uint64_t filter_rows, uint64_t input_rows) const {
415
0
        if (!_always_true) {
416
0
            _judge_filter_rows += filter_rows;
417
0
            _judge_input_rows += input_rows;
418
0
            vectorized::VRuntimeFilterWrapper::judge_selectivity(
419
0
                    get_ignore_threshold(), _judge_filter_rows, _judge_input_rows, _always_true);
420
0
        }
421
0
    }
422
423
    uint32_t _column_id;
424
    PrimitiveType _primitive_type;
425
    // TODO: the value is only in delete condition, better be template value
426
    bool _opposite;
427
    int _runtime_filter_id = -1;
428
    // VRuntimeFilterWrapper and ColumnPredicate share the same logic,
429
    // but it's challenging to unify them, so the code is duplicated.
430
    // _judge_counter, _judge_input_rows, _judge_filter_rows, and _always_true
431
    // are variables used to implement the _always_true logic, calculated periodically
432
    // based on runtime_filter_sampling_frequency. During each period, if _always_true
433
    // is evaluated as true, the logic for always_true is applied for the rest of that period
434
    // without recalculating. At the beginning of the next period,
435
    // reset_judge_selectivity is used to reset these variables.
436
    mutable int _judge_counter = 0;
437
    mutable uint64_t _judge_input_rows = 0;
438
    mutable uint64_t _judge_filter_rows = 0;
439
    mutable bool _always_true = false;
440
441
    std::shared_ptr<RuntimeProfile::Counter> _predicate_filtered_rows_counter =
442
            std::make_shared<RuntimeProfile::Counter>(TUnit::UNIT, 0);
443
    std::shared_ptr<RuntimeProfile::Counter> _predicate_input_rows_counter =
444
            std::make_shared<RuntimeProfile::Counter>(TUnit::UNIT, 0);
445
    std::shared_ptr<RuntimeProfile::Counter> _predicate_always_true_rows_counter =
446
            std::make_shared<RuntimeProfile::Counter>(TUnit::UNIT, 0);
447
448
private:
449
0
    ColumnPredicate(const ColumnPredicate& other) = default;
450
};
451
452
} //namespace doris