Coverage Report

Created: 2026-02-04 17:08

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_13PrimitiveTypeE2EhEET0_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_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
Unexecuted instantiation: _ZN5doris18get_zone_map_valueILNS_13PrimitiveTypeE10ENS_9StringRefEEET0_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
944
            : _column_id(column_id),
204
944
              _col_name(col_name),
205
944
              _primitive_type(primitive_type),
206
944
              _opposite(opposite) {
207
944
        reset_judge_selectivity();
208
944
    }
209
1
    ColumnPredicate(const ColumnPredicate& other, uint32_t col_id) : ColumnPredicate(other) {
210
1
        _column_id = col_id;
211
1
    }
212
213
945
    virtual ~ColumnPredicate() = default;
214
215
    virtual PredicateType type() const = 0;
216
8
    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
    // If this predicate acts on the key column, this predicate should be erased.
229
0
    virtual bool could_be_erased() const { return false; }
230
    // Return the size of value set for IN/NOT IN predicates and 0 for others.
231
2
    virtual std::string debug_string() const {
232
2
        fmt::memory_buffer debug_string_buffer;
233
2
        fmt::format_to(debug_string_buffer,
234
2
                       "Column ID: {}, Data Type: {}, PredicateType: {}, opposite: {}, Runtime "
235
2
                       "Filter ID: {}",
236
2
                       _column_id, type_to_string(primitive_type()), pred_type_string(type()),
237
2
                       _opposite, _runtime_filter_id);
238
2
        return fmt::to_string(debug_string_buffer);
239
2
    }
240
241
    // evaluate predicate on IColumn
242
    // a short circuit eval way
243
4.20k
    uint16_t evaluate(const vectorized::IColumn& column, uint16_t* sel, uint16_t size) const {
244
4.20k
        Defer defer([&] { try_reset_judge_selectivity(); });
245
246
4.20k
        if (always_true()) {
247
0
            update_filter_info(0, 0, size);
248
0
            return size;
249
0
        }
250
251
4.20k
        uint16_t new_size = _evaluate_inner(column, sel, size);
252
4.20k
        if (_can_ignore()) {
253
0
            do_judge_selectivity(size - new_size, size);
254
0
        }
255
4.20k
        update_filter_info(size - new_size, size, 0);
256
4.20k
        return new_size;
257
4.20k
    }
258
    virtual void evaluate_and(const vectorized::IColumn& column, const uint16_t* sel, uint16_t size,
259
0
                              bool* flags) const {}
260
    virtual void evaluate_or(const vectorized::IColumn& column, const uint16_t* sel, uint16_t size,
261
0
                             bool* flags) const {}
262
263
0
    virtual bool support_zonemap() const { return true; }
264
265
0
    virtual bool evaluate_and(const std::pair<WrapperField*, WrapperField*>& statistic) const {
266
0
        return true;
267
0
    }
268
269
0
    virtual bool is_always_true(const std::pair<WrapperField*, WrapperField*>& statistic) const {
270
0
        return false;
271
0
    }
272
273
0
    virtual bool evaluate_del(const std::pair<WrapperField*, WrapperField*>& statistic) const {
274
0
        return false;
275
0
    }
276
277
0
    virtual bool evaluate_and(const vectorized::ParquetBlockSplitBloomFilter* bf) const {
278
0
        return true;
279
0
    }
280
281
0
    virtual bool evaluate_and(const BloomFilter* bf) const { return true; }
282
283
0
    virtual bool evaluate_and(const StringRef* dict_words, const size_t dict_count) const {
284
0
        return true;
285
0
    }
286
287
0
    virtual bool can_do_bloom_filter(bool ngram) const { return false; }
288
289
    /**
290
     * Figure out whether this page is matched partially or completely.
291
     */
292
0
    virtual bool evaluate_and(vectorized::ParquetPredicate::ColumnStat* statistic) const {
293
0
        throw Exception(ErrorCode::INTERNAL_ERROR,
294
0
                        "ParquetPredicate is not supported by this predicate!");
295
0
        return true;
296
0
    }
297
298
    virtual bool evaluate_and(vectorized::ParquetPredicate::CachedPageIndexStat* statistic,
299
0
                              RowRanges* row_ranges) const {
300
0
        throw Exception(ErrorCode::INTERNAL_ERROR,
301
0
                        "ParquetPredicate is not supported by this predicate!");
302
0
        return true;
303
0
    }
304
305
    // used to evaluate pre read column in lazy materialization
306
    // now only support integer/float
307
    // a vectorized eval way
308
0
    virtual void evaluate_vec(const vectorized::IColumn& column, uint16_t size, bool* flags) const {
309
0
        DCHECK(false) << "should not reach here";
310
0
    }
311
    virtual void evaluate_and_vec(const vectorized::IColumn& column, uint16_t size,
312
0
                                  bool* flags) const {
313
0
        DCHECK(false) << "should not reach here";
314
0
    }
315
316
0
    virtual std::string get_search_str() const {
317
0
        DCHECK(false) << "should not reach here";
318
0
        return "";
319
0
    }
320
321
0
    virtual void set_page_ng_bf(std::unique_ptr<segment_v2::BloomFilter>) {
322
0
        DCHECK(false) << "should not reach here";
323
0
    }
324
15.2k
    uint32_t column_id() const { return _column_id; }
325
6
    std::string col_name() const { return _col_name; }
326
327
6
    bool opposite() const { return _opposite; }
328
329
    void attach_profile_counter(
330
            int filter_id, std::shared_ptr<RuntimeProfile::Counter> predicate_filtered_rows_counter,
331
            std::shared_ptr<RuntimeProfile::Counter> predicate_input_rows_counter,
332
0
            std::shared_ptr<RuntimeProfile::Counter> predicate_always_true_rows_counter) {
333
0
        _runtime_filter_id = filter_id;
334
0
        DCHECK(predicate_filtered_rows_counter != nullptr);
335
0
        DCHECK(predicate_input_rows_counter != nullptr);
336
337
0
        if (predicate_filtered_rows_counter != nullptr) {
338
0
            _predicate_filtered_rows_counter = predicate_filtered_rows_counter;
339
0
        }
340
0
        if (predicate_input_rows_counter != nullptr) {
341
0
            _predicate_input_rows_counter = predicate_input_rows_counter;
342
0
        }
343
0
        if (predicate_always_true_rows_counter != nullptr) {
344
0
            _predicate_always_true_rows_counter = predicate_always_true_rows_counter;
345
0
        }
346
0
    }
347
348
    /// TODO: Currently we only record statistics for runtime filters, in the future we should record for all predicates
349
    void update_filter_info(int64_t filter_rows, int64_t input_rows,
350
4.20k
                            int64_t always_true_rows) const {
351
4.20k
        if (_predicate_input_rows_counter == nullptr ||
352
4.20k
            _predicate_filtered_rows_counter == nullptr ||
353
4.20k
            _predicate_always_true_rows_counter == nullptr) {
354
0
            throw Exception(INTERNAL_ERROR, "Predicate profile counters are not initialized");
355
0
        }
356
4.20k
        COUNTER_UPDATE(_predicate_input_rows_counter, input_rows);
357
4.20k
        COUNTER_UPDATE(_predicate_filtered_rows_counter, filter_rows);
358
4.20k
        COUNTER_UPDATE(_predicate_always_true_rows_counter, always_true_rows);
359
4.20k
    }
360
361
2
    static std::string pred_type_string(PredicateType type) {
362
2
        switch (type) {
363
2
        case PredicateType::EQ:
364
2
            return "eq";
365
0
        case PredicateType::NE:
366
0
            return "ne";
367
0
        case PredicateType::LT:
368
0
            return "lt";
369
0
        case PredicateType::LE:
370
0
            return "le";
371
0
        case PredicateType::GT:
372
0
            return "gt";
373
0
        case PredicateType::GE:
374
0
            return "ge";
375
0
        case PredicateType::IN_LIST:
376
0
            return "in";
377
0
        case PredicateType::NOT_IN_LIST:
378
0
            return "not_in";
379
0
        case PredicateType::IS_NULL:
380
0
            return "is_null";
381
0
        case PredicateType::IS_NOT_NULL:
382
0
            return "is_not_null";
383
0
        case PredicateType::BF:
384
0
            return "bf";
385
0
        case PredicateType::MATCH:
386
0
            return "match";
387
0
        default:
388
0
            return "unknown";
389
2
        }
390
2
    }
391
392
4.20k
    bool always_true() const { return _always_true; }
393
    // Return whether the ColumnPredicate was created by a runtime filter.
394
    // If true, it was definitely created by a runtime filter.
395
    // If false, it may still have been created by a runtime filter,
396
    // as certain filters like "in filter" generate key ranges instead of ColumnPredicate.
397
    // is_runtime_filter uses _can_ignore, except for BitmapFilter,
398
    // as BitmapFilter cannot ignore data.
399
0
    virtual bool is_runtime_filter() const { return _can_ignore(); }
400
401
protected:
402
8.40k
    virtual bool _can_ignore() const { return _runtime_filter_id != -1; }
403
    virtual uint16_t _evaluate_inner(const vectorized::IColumn& column, uint16_t* sel,
404
0
                                     uint16_t size) const {
405
0
        throw Exception(INTERNAL_ERROR, "Not Implemented _evaluate_inner");
406
0
    }
407
408
944
    void reset_judge_selectivity() const {
409
944
        _always_true = false;
410
944
        _judge_counter = config::runtime_filter_sampling_frequency;
411
944
        _judge_input_rows = 0;
412
944
        _judge_filter_rows = 0;
413
944
    }
414
415
4.20k
    void try_reset_judge_selectivity() const {
416
4.20k
        if (_can_ignore() && ((_judge_counter--) == 0)) {
417
0
            reset_judge_selectivity();
418
0
        }
419
4.20k
    }
420
421
0
    void do_judge_selectivity(uint64_t filter_rows, uint64_t input_rows) const {
422
0
        if (!_always_true) {
423
0
            _judge_filter_rows += filter_rows;
424
0
            _judge_input_rows += input_rows;
425
0
            RuntimeFilterSelectivity::judge_selectivity(get_ignore_threshold(), _judge_filter_rows,
426
0
                                                        _judge_input_rows, _always_true);
427
0
        }
428
0
    }
429
430
    uint32_t _column_id;
431
    const std::string _col_name;
432
    PrimitiveType _primitive_type;
433
    // TODO: the value is only in delete condition, better be template value
434
    bool _opposite;
435
    int _runtime_filter_id = -1;
436
    // VRuntimeFilterWrapper and ColumnPredicate share the same logic,
437
    // but it's challenging to unify them, so the code is duplicated.
438
    // _judge_counter, _judge_input_rows, _judge_filter_rows, and _always_true
439
    // are variables used to implement the _always_true logic, calculated periodically
440
    // based on runtime_filter_sampling_frequency. During each period, if _always_true
441
    // is evaluated as true, the logic for always_true is applied for the rest of that period
442
    // without recalculating. At the beginning of the next period,
443
    // reset_judge_selectivity is used to reset these variables.
444
    mutable int _judge_counter = 0;
445
    mutable uint64_t _judge_input_rows = 0;
446
    mutable uint64_t _judge_filter_rows = 0;
447
    mutable bool _always_true = false;
448
449
    std::shared_ptr<RuntimeProfile::Counter> _predicate_filtered_rows_counter =
450
            std::make_shared<RuntimeProfile::Counter>(TUnit::UNIT, 0);
451
    std::shared_ptr<RuntimeProfile::Counter> _predicate_input_rows_counter =
452
            std::make_shared<RuntimeProfile::Counter>(TUnit::UNIT, 0);
453
    std::shared_ptr<RuntimeProfile::Counter> _predicate_always_true_rows_counter =
454
            std::make_shared<RuntimeProfile::Counter>(TUnit::UNIT, 0);
455
456
private:
457
1
    ColumnPredicate(const ColumnPredicate& other) = default;
458
};
459
460
} //namespace doris