Coverage Report

Created: 2026-07-29 20:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/sink/viceberg_merge_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/DataSinks_types.h>
21
22
#include <map>
23
#include <memory>
24
#include <string>
25
#include <vector>
26
27
#include "common/status.h"
28
#include "exec/sink/writer/async_result_writer.h"
29
#include "exprs/vexpr_fwd.h"
30
#include "roaring/roaring64map.hh"
31
#include "runtime/descriptors.h"
32
#include "runtime/runtime_profile.h"
33
34
namespace doris {
35
36
class ObjectPool;
37
class RuntimeState;
38
class Dependency;
39
40
class VIcebergDeleteSink;
41
class VIcebergTableWriter;
42
43
class VIcebergMergeSink final : public AsyncResultWriter {
44
public:
45
    VIcebergMergeSink(const TDataSink& t_sink, const VExprContextSPtrs& output_exprs,
46
                      std::shared_ptr<Dependency> dep, std::shared_ptr<Dependency> fin_dep);
47
48
    ~VIcebergMergeSink() override;
49
50
    Status init_properties(ObjectPool* pool, const RowDescriptor& row_desc);
51
52
    Status open(RuntimeState* state, RuntimeProfile* profile) override;
53
54
    Status write(RuntimeState* state, Block& block) override;
55
56
    Status close(Status) override;
57
58
#ifdef BE_TEST
59
11
    void set_skip_io(bool skip) { _skip_io = skip; }
60
#endif
61
62
private:
63
    Status _build_inner_sinks();
64
    Status _prepare_output_layout();
65
    Status _validate_matched_row_ids(const Block& block, const uint8_t* delete_filter);
66
67
    TDataSink _t_sink;
68
    TDataSink _table_sink;
69
    TDataSink _delete_sink;
70
71
    std::unique_ptr<VIcebergTableWriter> _table_writer;
72
    std::unique_ptr<VIcebergDeleteSink> _delete_writer;
73
74
    RuntimeState* _state = nullptr;
75
76
    int _operation_idx = -1;
77
    int _row_id_idx = -1;
78
    std::vector<int> _data_column_indices;
79
    std::map<std::string, roaring::Roaring64Map> _matched_row_positions;
80
    size_t _matched_row_id_state_size = sizeof(std::map<std::string, roaring::Roaring64Map>);
81
    bool _require_merge_cardinality_check = false;
82
83
    VExprContextSPtrs _table_output_expr_ctxs;
84
    VExprContextSPtrs _delete_output_expr_ctxs;
85
86
    size_t _row_count = 0;
87
    size_t _insert_row_count = 0;
88
    size_t _delete_row_count = 0;
89
90
    RuntimeProfile::Counter* _written_rows_counter = nullptr;
91
    RuntimeProfile::Counter* _insert_rows_counter = nullptr;
92
    RuntimeProfile::Counter* _delete_rows_counter = nullptr;
93
    RuntimeProfile::Counter* _matched_row_id_state_bytes_counter = nullptr;
94
    RuntimeProfile::Counter* _send_data_timer = nullptr;
95
    RuntimeProfile::Counter* _open_timer = nullptr;
96
    RuntimeProfile::Counter* _close_timer = nullptr;
97
98
#ifdef BE_TEST
99
    bool _skip_io = false;
100
#endif
101
};
102
103
} // namespace doris