Coverage Report

Created: 2026-04-17 21:24

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