be/src/exec/operator/repeat_operator.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 <stdint.h> |
21 | | |
22 | | #include "common/status.h" |
23 | | #include "exec/operator/operator.h" |
24 | | |
25 | | namespace doris { |
26 | | #include "common/compile_check_begin.h" |
27 | | class RuntimeState; |
28 | | |
29 | | class RepeatOperatorX; |
30 | | |
31 | | class RepeatLocalState final : public PipelineXLocalState<FakeSharedState> { |
32 | | public: |
33 | | ENABLE_FACTORY_CREATOR(RepeatLocalState); |
34 | | using Parent = RepeatOperatorX; |
35 | | using Base = PipelineXLocalState<FakeSharedState>; |
36 | | RepeatLocalState(RuntimeState* state, OperatorXBase* parent); |
37 | | |
38 | | Status init(RuntimeState* state, LocalStateInfo& info) override; |
39 | | Status open(RuntimeState* state) override; |
40 | | |
41 | | Status get_repeated_block(Block* child_block, int repeat_id_idx, Block* output_block); |
42 | | |
43 | | Status add_grouping_id_column(std::size_t rows, std::size_t& cur_col, MutableColumns& columns, |
44 | | int repeat_id_idx); |
45 | | |
46 | | private: |
47 | | friend class RepeatOperatorX; |
48 | | template <typename LocalStateType> |
49 | | friend class StatefulOperatorX; |
50 | | std::unique_ptr<Block> _child_block; |
51 | | bool _child_eos = false; |
52 | | int _repeat_id_idx; |
53 | | std::unique_ptr<Block> _intermediate_block; |
54 | | VExprContextSPtrs _expr_ctxs; |
55 | | |
56 | | RuntimeProfile::Counter* _evaluate_input_timer = nullptr; |
57 | | RuntimeProfile::Counter* _get_repeat_data_timer = nullptr; |
58 | | RuntimeProfile::Counter* _filter_timer = nullptr; |
59 | | }; |
60 | | |
61 | | class RepeatOperatorX final : public StatefulOperatorX<RepeatLocalState> { |
62 | | public: |
63 | | using Base = StatefulOperatorX<RepeatLocalState>; |
64 | | RepeatOperatorX(ObjectPool* pool, const TPlanNode& tnode, int operator_id, |
65 | | const DescriptorTbl& descs); |
66 | | #ifdef BE_TEST |
67 | 3 | RepeatOperatorX() = default; |
68 | | #endif |
69 | | Status init(const TPlanNode& tnode, RuntimeState* state) override; |
70 | | |
71 | | Status prepare(RuntimeState* state) override; |
72 | | |
73 | | bool need_more_input_data(RuntimeState* state) const override; |
74 | | Status pull(RuntimeState* state, Block* output_block, bool* eos) const override; |
75 | | Status push(RuntimeState* state, Block* input_block, bool eos) const override; |
76 | | |
77 | | private: |
78 | | friend class RepeatLocalState; |
79 | | |
80 | | // Slot id set used to indicate those slots need to set to null. |
81 | | std::vector<std::set<SlotId>> _slot_id_set_list; |
82 | | // all slot id |
83 | | std::set<SlotId> _all_slot_ids; |
84 | | // An integer bitmap list, it indicates the bit position of the exprs not null. |
85 | | int64_t _repeat_id_list_size; |
86 | | std::vector<std::vector<int64_t>> _grouping_list; |
87 | | TupleId _output_tuple_id; |
88 | | |
89 | | std::vector<SlotDescriptor*> _output_slots; |
90 | | |
91 | | VExprContextSPtrs _expr_ctxs; |
92 | | }; |
93 | | |
94 | | #include "common/compile_check_end.h" |
95 | | } // namespace doris |