be/src/exec/operator/groupjoin_build_sink.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 <gen_cpp/PlanNodes_types.h> |
21 | | |
22 | | #include <memory> |
23 | | #include <vector> |
24 | | |
25 | | #include "core/block/block.h" |
26 | | #include "core/column/column_vector.h" |
27 | | #include "exec/common/groupjoin_utils.h" |
28 | | #include "exec/operator/groupjoin_shared_state.h" |
29 | | #include "exec/operator/operator.h" |
30 | | #include "exec/runtime_filter/runtime_filter_producer_helper_groupjoin.h" |
31 | | |
32 | | namespace doris { |
33 | | |
34 | | class AggFnEvaluator; |
35 | | class GroupJoinBuildSinkOperatorX; |
36 | | |
37 | | class GroupJoinBuildSinkLocalState final : public PipelineXSinkLocalState<GroupJoinSharedState> { |
38 | | public: |
39 | | ENABLE_FACTORY_CREATOR(GroupJoinBuildSinkLocalState); |
40 | | using Base = PipelineXSinkLocalState<GroupJoinSharedState>; |
41 | | using Parent = GroupJoinBuildSinkOperatorX; |
42 | | |
43 | | GroupJoinBuildSinkLocalState(DataSinkOperatorXBase* parent, RuntimeState* state); |
44 | 0 | ~GroupJoinBuildSinkLocalState() override = default; |
45 | | |
46 | | Status init(RuntimeState* state, LocalSinkStateInfo& info) override; |
47 | | Status terminate(RuntimeState* state) override; |
48 | | Status close(RuntimeState* state, Status exec_status) override; |
49 | | |
50 | 0 | Dependency* finishdependency() override { return _finish_dependency.get(); } |
51 | | |
52 | | private: |
53 | | friend class GroupJoinBuildSinkOperatorX; |
54 | | |
55 | | Status _append_runtime_filter_columns(Block* block); |
56 | | |
57 | | VExprContextSPtrs _build_expr_ctxs; |
58 | | std::vector<AggFnEvaluator*> _aggregate_evaluators; |
59 | | ColumnRawPtrs _build_key_not_nullable_columns; |
60 | | std::vector<ColumnPtr> _key_columns_holder; |
61 | | std::vector<AggregateDataPtr> _places; |
62 | | ColumnUInt8::MutablePtr _null_map_column; |
63 | | std::shared_ptr<RuntimeFilterProducerHelperGroupJoin> _runtime_filter_producer_helper; |
64 | | std::shared_ptr<CountedFinishDependency> _finish_dependency; |
65 | | bool _runtime_filter_size_sent = false; |
66 | | }; |
67 | | |
68 | | class GroupJoinBuildSinkOperatorX final : public DataSinkOperatorX<GroupJoinBuildSinkLocalState> { |
69 | | public: |
70 | | using Base = DataSinkOperatorX<GroupJoinBuildSinkLocalState>; |
71 | | |
72 | | GroupJoinBuildSinkOperatorX(ObjectPool* pool, int operator_id, int dest_id, |
73 | | const TPlanNode& tnode, const DescriptorTbl& descs); |
74 | | |
75 | 0 | Status init(const TDataSink& tsink) override { |
76 | 0 | return Status::InternalError("{} should not init with TDataSink", _name); |
77 | 0 | } |
78 | | Status init(const TPlanNode& tnode, RuntimeState* state) override; |
79 | | Status prepare(RuntimeState* state) override; |
80 | | Status sink_impl(RuntimeState* state, Block* in_block, bool eos) override; |
81 | | |
82 | | DataDistribution required_data_distribution(RuntimeState* state) const override; |
83 | | bool is_shuffled_operator() const override; |
84 | | bool is_colocated_operator() const override; |
85 | | bool followed_by_shuffled_operator() const override; |
86 | | |
87 | | private: |
88 | | friend class GroupJoinBuildSinkLocalState; |
89 | | |
90 | | const TJoinDistributionType::type _join_distribution; |
91 | | ObjectPool* _pool = nullptr; |
92 | | std::vector<TExpr> _partition_exprs; |
93 | | VExprContextSPtrs _build_expr_ctxs; |
94 | | std::vector<AggFnEvaluator*> _aggregate_evaluators; |
95 | | std::vector<int> _aggregate_indices; |
96 | | std::vector<TGroupJoinAggSide::type> _aggregate_sides; |
97 | | const std::vector<TRuntimeFilterDesc> _runtime_filter_descs; |
98 | | Sizes _sizes_of_aggregate_states; |
99 | | Sizes _aligns_of_aggregate_states; |
100 | | TupleId _output_tuple_id; |
101 | | TupleDescriptor* _output_tuple_desc = nullptr; |
102 | | }; |
103 | | |
104 | | extern template class PipelineXSinkLocalState<GroupJoinSharedState>; |
105 | | |
106 | | } // namespace doris |