forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime_filter_expr.h
More file actions
146 lines (121 loc) · 5.54 KB
/
Copy pathruntime_filter_expr.h
File metadata and controls
146 lines (121 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#pragma once
#include <gen_cpp/Metrics_types.h>
#include <atomic>
#include <cstdint>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include "common/config.h"
#include "common/status.h"
#include "exec/runtime_filter/runtime_filter_selectivity.h"
#include "exprs/function_context.h"
#include "exprs/vexpr.h"
#include "runtime/runtime_profile.h"
namespace doris {
class RowDescriptor;
class RuntimeState;
class TExprNode;
double get_in_list_ignore_thredhold(size_t list_size);
double get_comparison_ignore_thredhold();
double get_bloom_filter_ignore_thredhold();
} // namespace doris
namespace doris {
class Block;
class VExprContext;
class RuntimeFilterExpr final : public VExpr {
ENABLE_FACTORY_CREATOR(RuntimeFilterExpr);
public:
RuntimeFilterExpr(const TExprNode& node, VExprSPtr impl, double ignore_thredhold,
bool null_aware, int filter_id,
int sampling_frequency = RuntimeFilterSelectivity::DISABLE_SAMPLING);
~RuntimeFilterExpr() override = default;
Status execute_column_impl(VExprContext* context, const Block* block, const Selector* selector,
size_t count, ColumnPtr& result_column) const override;
Status prepare(RuntimeState* state, const RowDescriptor& desc, VExprContext* context) override;
Status open(RuntimeState* state, VExprContext* context,
FunctionContext::FunctionStateScope scope) override;
std::string debug_string() const override { return _impl->debug_string(); }
void close(VExprContext* context, FunctionContext::FunctionStateScope scope) override;
const std::string& expr_name() const override;
const VExprSPtrs& children() const override { return _impl->children(); }
TExprNodeType::type node_type() const override { return _impl->node_type(); }
double execute_cost() const override { return _impl->execute_cost(); }
Status execute_filter(VExprContext* context, const Block* block,
uint8_t* __restrict result_filter_data, size_t rows, bool accept_null,
bool* can_filter_all) const override;
uint64_t get_digest(uint64_t seed) const override {
seed = _impl->get_digest(seed);
if (seed) {
return HashUtil::crc_hash64(&_null_aware, sizeof(_null_aware), seed);
}
return seed;
}
VExprSPtr get_impl() const override { return _impl; }
void set_impl(VExprSPtr impl) { _impl = std::move(impl); }
Status clone_node(VExprSPtr* cloned_expr) const override;
void attach_profile_counter(std::shared_ptr<RuntimeProfile::Counter> rf_input_rows,
std::shared_ptr<RuntimeProfile::Counter> rf_filter_rows,
std::shared_ptr<RuntimeProfile::Counter> always_true_filter_rows) {
DCHECK(rf_input_rows != nullptr);
DCHECK(rf_filter_rows != nullptr);
DCHECK(always_true_filter_rows != nullptr);
if (rf_input_rows != nullptr) {
_rf_input_rows = rf_input_rows;
}
if (rf_filter_rows != nullptr) {
_rf_filter_rows = rf_filter_rows;
}
if (always_true_filter_rows != nullptr) {
_always_true_filter_rows = always_true_filter_rows;
}
}
bool is_rf_wrapper() const override { return true; }
ZoneMapFilterResult evaluate_zonemap_filter(const ZoneMapEvalContext& ctx) const override;
bool can_evaluate_zonemap_filter() const override;
void collect_slot_column_ids(std::set<int>& column_ids) const override;
int filter_id() const { return _filter_id; }
std::shared_ptr<RuntimeProfile::Counter> predicate_filtered_rows_counter() const {
return _rf_filter_rows;
}
std::shared_ptr<RuntimeProfile::Counter> predicate_input_rows_counter() const {
return _rf_input_rows;
}
std::shared_ptr<RuntimeProfile::Counter> predicate_always_true_rows_counter() const {
return _always_true_filter_rows;
}
bool is_slot_ref() const override { return false; }
bool is_virtual_slot_ref() const override { return false; }
bool is_column_ref() const override { return false; }
private:
VExprSPtr _impl;
std::shared_ptr<RuntimeProfile::Counter> _rf_input_rows =
std::make_shared<RuntimeProfile::Counter>(TUnit::UNIT, 0);
std::shared_ptr<RuntimeProfile::Counter> _rf_filter_rows =
std::make_shared<RuntimeProfile::Counter>(TUnit::UNIT, 0);
std::shared_ptr<RuntimeProfile::Counter> _always_true_filter_rows =
std::make_shared<RuntimeProfile::Counter>(TUnit::UNIT, 0);
std::string _expr_name;
double _ignore_thredhold;
bool _null_aware;
int _filter_id;
int _sampling_frequency;
};
using RuntimeFilterExprPtr = std::shared_ptr<RuntimeFilterExpr>;
} // namespace doris