Coverage Report

Created: 2026-01-16 00:19

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