be/src/cloud/cloud_rowset_builder.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 <map> |
21 | | |
22 | | #include "storage/rowset_builder.h" |
23 | | |
24 | | namespace doris { |
25 | | |
26 | | class CloudTablet; |
27 | | class PCloudLoadMowSnapshot; |
28 | | class PCloudLoadMowResult; |
29 | | class CloudStorageEngine; |
30 | | |
31 | | class CloudRowsetBuilder : public BaseRowsetBuilder { |
32 | | public: |
33 | | CloudRowsetBuilder(CloudStorageEngine& engine, const WriteRequest& req, |
34 | | RuntimeProfile* profile); |
35 | | |
36 | | ~CloudRowsetBuilder() override; |
37 | | |
38 | | Status init() override; |
39 | | |
40 | | Status commit_txn() override; |
41 | | |
42 | | static Status validate_partial_rowset_meta(const RowsetMetaPB& base_meta, |
43 | | const RowsetMetaPB& partial_meta, |
44 | | int32_t segment_start_id, int32_t segment_capacity); |
45 | | // Inputs have already passed validate_partial_rowset_meta at the stream boundary. |
46 | | static Status assemble_rowset_meta_from_partials( |
47 | | const RowsetMetaPB& base_meta, |
48 | | const std::map<int32_t, RowsetMetaPB>& partial_rowset_metas, |
49 | | int32_t max_segments_per_rowset, RowsetMetaPB* result); |
50 | | |
51 | | Status build_rowset_from_assembled_meta(const RowsetMetaPB& meta); |
52 | | Status get_mow_snapshot_for_sink(PCloudLoadMowSnapshot* snapshot); |
53 | | Status merge_sink_mow_bitmap(const PCloudLoadMowResult& result); |
54 | | |
55 | | static Status validate_sink_mow_result(const PCloudLoadMowResult& result, |
56 | | int64_t snapshot_version); |
57 | | |
58 | | virtual void update_tablet_stats(); |
59 | | |
60 | | const RowsetMetaSharedPtr& rowset_meta(); |
61 | | |
62 | | virtual bool is_s3_storage() const; |
63 | | |
64 | | virtual Status commit_rowset(const std::string& job_id, int64_t table_id); |
65 | | |
66 | | virtual Status set_txn_related_info(); |
67 | | |
68 | 151k | virtual void set_skip_writing_rowset_metadata(bool skip) { |
69 | 151k | _skip_writing_rowset_metadata = skip; |
70 | 151k | } |
71 | | |
72 | | protected: |
73 | | // Convert `_tablet` from `BaseTablet` to `CloudTablet` |
74 | | CloudTablet* cloud_tablet(); |
75 | | |
76 | | Status check_tablet_version_count(); |
77 | | |
78 | | CloudStorageEngine& _engine; |
79 | | std::unique_ptr<PCloudLoadMowSnapshot> _mow_snapshot_for_sink; |
80 | | |
81 | | // whether to skip writing rowset metadata to meta service. |
82 | | // This is used for empty rowset when config::skip_writing_empty_rowset_metadata is true. |
83 | | bool _skip_writing_rowset_metadata = false; |
84 | | }; |
85 | | |
86 | | class CloudGroupRowsetBuilder final : public CloudRowsetBuilder { |
87 | | public: |
88 | | CloudGroupRowsetBuilder(CloudStorageEngine& engine, const WriteRequest& group_build_req, |
89 | | const WriteRequest& sub_data_req, |
90 | | const WriteRequest& sub_row_binlog_req, RuntimeProfile* profile); |
91 | | |
92 | | Status init() override; |
93 | | |
94 | | Status build_rowset() override; |
95 | | |
96 | | Status submit_calc_delete_bitmap_task() override; |
97 | | |
98 | | Status wait_calc_delete_bitmap() override; |
99 | | |
100 | | void update_tablet_stats() override; |
101 | | |
102 | | Status commit_rowset(const std::string& job_id, int64_t table_id) override; |
103 | | |
104 | | Status set_txn_related_info() override; |
105 | | |
106 | | void set_skip_writing_rowset_metadata(bool skip) override; |
107 | | |
108 | 1.14k | const BaseTabletSPtr& tablet_sptr() const override { return _data_builder->tablet_sptr(); } |
109 | | |
110 | 0 | const RowsetSharedPtr& rowset() const override { return _data_builder->rowset(); } |
111 | | |
112 | 1.14k | const TabletSchemaSPtr& tablet_schema() const override { |
113 | 1.14k | return _data_builder->tablet_schema(); |
114 | 1.14k | } |
115 | | |
116 | 1.14k | const std::shared_ptr<PartialUpdateInfo>& get_partial_update_info() const override { |
117 | 1.14k | return _data_builder->get_partial_update_info(); |
118 | 1.14k | } |
119 | | |
120 | 783 | bool is_s3_storage() const override { return _data_builder->is_s3_storage(); } |
121 | | |
122 | | CloudRowsetBuilder* data_builder() { return _data_builder.get(); } |
123 | | |
124 | | CloudRowsetBuilder* row_binlog_builder() { return _row_binlog_builder.get(); } |
125 | | |
126 | | private: |
127 | | std::shared_ptr<CloudRowsetBuilder> _data_builder; |
128 | | std::shared_ptr<CloudRowsetBuilder> _row_binlog_builder; |
129 | | }; |
130 | | |
131 | | } // namespace doris |