/root/doris/be/src/cloud/pb_convert.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | #include "cloud/pb_convert.h" |
19 | | |
20 | | #include <common/logging.h> |
21 | | #include <gen_cpp/olap_file.pb.h> |
22 | | |
23 | | #include <utility> |
24 | | |
25 | | namespace doris::cloud { |
26 | | |
27 | 0 | RowsetMetaCloudPB doris_rowset_meta_to_cloud(const RowsetMetaPB& in) { |
28 | 0 | RowsetMetaCloudPB out; |
29 | 0 | doris_rowset_meta_to_cloud(&out, in); |
30 | 0 | return out; |
31 | 0 | } |
32 | | |
33 | 0 | RowsetMetaCloudPB doris_rowset_meta_to_cloud(RowsetMetaPB&& in) { |
34 | 0 | RowsetMetaCloudPB out; |
35 | 0 | doris_rowset_meta_to_cloud(&out, std::move(in)); |
36 | 0 | return out; |
37 | 0 | } |
38 | | |
39 | 0 | void doris_rowset_meta_to_cloud(RowsetMetaCloudPB* out, const RowsetMetaPB& in) { |
40 | | // ATTN: please keep the set order aligned with the definition of proto `TabletSchemaCloudPB`. |
41 | 0 | out->set_rowset_id(in.rowset_id()); |
42 | 0 | out->set_partition_id(in.partition_id()); |
43 | 0 | out->set_tablet_id(in.tablet_id()); |
44 | 0 | out->set_txn_id(in.txn_id()); |
45 | 0 | out->set_tablet_schema_hash(in.tablet_schema_hash()); |
46 | 0 | out->set_rowset_type(in.rowset_type()); |
47 | 0 | out->set_rowset_state(in.rowset_state()); |
48 | 0 | out->set_start_version(in.start_version()); |
49 | 0 | out->set_end_version(in.end_version()); |
50 | 0 | out->set_version_hash(in.version_hash()); |
51 | 0 | out->set_num_rows(in.num_rows()); |
52 | 0 | out->set_total_disk_size(in.total_disk_size()); |
53 | 0 | out->set_data_disk_size(in.data_disk_size()); |
54 | 0 | out->set_index_disk_size(in.index_disk_size()); |
55 | 0 | out->mutable_zone_maps()->CopyFrom(in.zone_maps()); |
56 | 0 | if (in.has_delete_predicate()) { |
57 | 0 | out->mutable_delete_predicate()->CopyFrom(in.delete_predicate()); |
58 | 0 | } |
59 | 0 | out->set_empty(in.empty()); |
60 | 0 | if (in.has_load_id()) { |
61 | 0 | out->mutable_load_id()->CopyFrom(in.load_id()); |
62 | 0 | } |
63 | 0 | out->set_delete_flag(in.delete_flag()); |
64 | 0 | out->set_creation_time(in.creation_time()); |
65 | 0 | if (in.has_tablet_uid()) { |
66 | 0 | out->mutable_tablet_uid()->CopyFrom(in.tablet_uid()); |
67 | 0 | } |
68 | 0 | out->set_num_segments(in.num_segments()); |
69 | 0 | out->set_rowset_id_v2(in.rowset_id_v2()); |
70 | 0 | out->set_resource_id(in.resource_id()); |
71 | 0 | out->set_newest_write_timestamp(in.newest_write_timestamp()); |
72 | 0 | out->mutable_segments_key_bounds()->CopyFrom(in.segments_key_bounds()); |
73 | 0 | if (in.has_tablet_schema()) { |
74 | 0 | doris_tablet_schema_to_cloud(out->mutable_tablet_schema(), in.tablet_schema()); |
75 | 0 | } |
76 | 0 | out->set_txn_expiration(in.txn_expiration()); |
77 | 0 | out->set_segments_overlap_pb(in.segments_overlap_pb()); |
78 | 0 | out->mutable_segments_file_size()->CopyFrom(in.segments_file_size()); |
79 | 0 | out->set_index_id(in.index_id()); |
80 | 0 | if (in.has_schema_version()) { |
81 | | // See cloud/src/meta-service/meta_service_schema.cpp for details. |
82 | 0 | out->set_schema_version(in.schema_version()); |
83 | 0 | } |
84 | 0 | out->set_enable_segments_file_size(in.enable_segments_file_size()); |
85 | 0 | out->set_has_variant_type_in_schema(in.has_has_variant_type_in_schema()); |
86 | 0 | out->set_enable_inverted_index_file_info(in.enable_inverted_index_file_info()); |
87 | 0 | out->mutable_inverted_index_file_info()->CopyFrom(in.inverted_index_file_info()); |
88 | 0 | } |
89 | | |
90 | 0 | void doris_rowset_meta_to_cloud(RowsetMetaCloudPB* out, RowsetMetaPB&& in) { |
91 | | // ATTN: please keep the set order aligned with the definition of proto `TabletSchemaCloudPB`. |
92 | 0 | out->set_rowset_id(in.rowset_id()); |
93 | 0 | out->set_partition_id(in.partition_id()); |
94 | 0 | out->set_tablet_id(in.tablet_id()); |
95 | 0 | out->set_txn_id(in.txn_id()); |
96 | 0 | out->set_tablet_schema_hash(in.tablet_schema_hash()); |
97 | 0 | out->set_rowset_type(in.rowset_type()); |
98 | 0 | out->set_rowset_state(in.rowset_state()); |
99 | 0 | out->set_start_version(in.start_version()); |
100 | 0 | out->set_end_version(in.end_version()); |
101 | 0 | out->set_version_hash(in.version_hash()); |
102 | 0 | out->set_num_rows(in.num_rows()); |
103 | 0 | out->set_total_disk_size(in.total_disk_size()); |
104 | 0 | out->set_data_disk_size(in.data_disk_size()); |
105 | 0 | out->set_index_disk_size(in.index_disk_size()); |
106 | 0 | out->mutable_zone_maps()->Swap(in.mutable_zone_maps()); |
107 | 0 | if (in.has_delete_predicate()) { |
108 | 0 | out->mutable_delete_predicate()->Swap(in.mutable_delete_predicate()); |
109 | 0 | } |
110 | 0 | out->set_empty(in.empty()); |
111 | 0 | if (in.has_load_id()) { |
112 | 0 | out->mutable_load_id()->CopyFrom(in.load_id()); |
113 | 0 | } |
114 | 0 | out->set_delete_flag(in.delete_flag()); |
115 | 0 | out->set_creation_time(in.creation_time()); |
116 | 0 | if (in.has_tablet_uid()) { |
117 | 0 | out->mutable_tablet_uid()->CopyFrom(in.tablet_uid()); |
118 | 0 | } |
119 | 0 | out->set_num_segments(in.num_segments()); |
120 | 0 | out->set_rowset_id_v2(in.rowset_id_v2()); |
121 | 0 | out->set_resource_id(in.resource_id()); |
122 | 0 | out->set_newest_write_timestamp(in.newest_write_timestamp()); |
123 | 0 | out->mutable_segments_key_bounds()->Swap(in.mutable_segments_key_bounds()); |
124 | 0 | if (in.has_tablet_schema()) { |
125 | 0 | doris_tablet_schema_to_cloud(out->mutable_tablet_schema(), |
126 | 0 | std::move(*in.mutable_tablet_schema())); |
127 | 0 | } |
128 | 0 | out->set_txn_expiration(in.txn_expiration()); |
129 | 0 | out->set_segments_overlap_pb(in.segments_overlap_pb()); |
130 | 0 | out->mutable_segments_file_size()->Swap(in.mutable_segments_file_size()); |
131 | 0 | out->set_index_id(in.index_id()); |
132 | 0 | if (in.has_schema_version()) { |
133 | | // See cloud/src/meta-service/meta_service_schema.cpp for details. |
134 | 0 | out->set_schema_version(in.schema_version()); |
135 | 0 | } |
136 | 0 | out->set_enable_segments_file_size(in.enable_segments_file_size()); |
137 | 0 | out->set_has_variant_type_in_schema(in.has_variant_type_in_schema()); |
138 | 0 | out->set_enable_inverted_index_file_info(in.enable_inverted_index_file_info()); |
139 | 0 | out->mutable_inverted_index_file_info()->Swap(in.mutable_inverted_index_file_info()); |
140 | 0 | } |
141 | | |
142 | | static void fill_schema_with_dict(const RowsetMetaCloudPB& in, RowsetMetaPB* out, |
143 | 0 | const SchemaCloudDictionary& dict) { |
144 | 0 | std::unordered_map<int32_t, ColumnPB*> unique_id_map; |
145 | | //init map |
146 | 0 | for (ColumnPB& column : *out->mutable_tablet_schema()->mutable_column()) { |
147 | 0 | unique_id_map[column.unique_id()] = &column; |
148 | 0 | } |
149 | | // column info |
150 | 0 | for (size_t i = 0; i < in.schema_dict_key_list().column_dict_key_list_size(); ++i) { |
151 | 0 | int dict_key = in.schema_dict_key_list().column_dict_key_list(i); |
152 | 0 | const ColumnPB& dict_val = dict.column_dict().at(dict_key); |
153 | 0 | ColumnPB& to_add = *out->mutable_tablet_schema()->add_column(); |
154 | 0 | to_add = dict_val; |
155 | 0 | VLOG_DEBUG << "fill dict column " << dict_val.ShortDebugString(); |
156 | 0 | } |
157 | | |
158 | | // index info |
159 | 0 | for (size_t i = 0; i < in.schema_dict_key_list().index_info_dict_key_list_size(); ++i) { |
160 | 0 | int dict_key = in.schema_dict_key_list().index_info_dict_key_list(i); |
161 | 0 | const TabletIndexPB& dict_val = dict.index_dict().at(dict_key); |
162 | 0 | *out->mutable_tablet_schema()->add_index() = dict_val; |
163 | 0 | VLOG_DEBUG << "fill dict index " << dict_val.ShortDebugString(); |
164 | 0 | } |
165 | | |
166 | | // sparse column info |
167 | 0 | for (size_t i = 0; i < in.schema_dict_key_list().sparse_column_dict_key_list_size(); ++i) { |
168 | 0 | int dict_key = in.schema_dict_key_list().sparse_column_dict_key_list(i); |
169 | 0 | const ColumnPB& dict_val = dict.column_dict().at(dict_key); |
170 | 0 | *unique_id_map.at(dict_val.parent_unique_id())->add_sparse_columns() = dict_val; |
171 | 0 | VLOG_DEBUG << "fill dict sparse column" << dict_val.ShortDebugString(); |
172 | 0 | } |
173 | 0 | } |
174 | | |
175 | | RowsetMetaPB cloud_rowset_meta_to_doris(const RowsetMetaCloudPB& in, |
176 | 0 | const SchemaCloudDictionary* dict) { |
177 | 0 | RowsetMetaPB out; |
178 | 0 | cloud_rowset_meta_to_doris(&out, in, dict); |
179 | 0 | return out; |
180 | 0 | } |
181 | | |
182 | 0 | RowsetMetaPB cloud_rowset_meta_to_doris(RowsetMetaCloudPB&& in, const SchemaCloudDictionary* dict) { |
183 | 0 | RowsetMetaPB out; |
184 | 0 | cloud_rowset_meta_to_doris(&out, std::move(in), dict); |
185 | 0 | return out; |
186 | 0 | } |
187 | | |
188 | | void cloud_rowset_meta_to_doris(RowsetMetaPB* out, const RowsetMetaCloudPB& in, |
189 | 0 | const SchemaCloudDictionary* dict) { |
190 | | // ATTN: please keep the set order aligned with the definition of proto `TabletSchemaCloudPB`. |
191 | 0 | out->set_rowset_id(in.rowset_id()); |
192 | 0 | out->set_partition_id(in.partition_id()); |
193 | 0 | out->set_tablet_id(in.tablet_id()); |
194 | 0 | out->set_txn_id(in.txn_id()); |
195 | 0 | out->set_tablet_schema_hash(in.tablet_schema_hash()); |
196 | 0 | out->set_rowset_type(in.rowset_type()); |
197 | 0 | out->set_rowset_state(in.rowset_state()); |
198 | 0 | out->set_start_version(in.start_version()); |
199 | 0 | out->set_end_version(in.end_version()); |
200 | 0 | out->set_version_hash(in.version_hash()); |
201 | 0 | out->set_num_rows(in.num_rows()); |
202 | 0 | out->set_total_disk_size(in.total_disk_size()); |
203 | 0 | out->set_data_disk_size(in.data_disk_size()); |
204 | 0 | out->set_index_disk_size(in.index_disk_size()); |
205 | 0 | out->mutable_zone_maps()->CopyFrom(in.zone_maps()); |
206 | 0 | if (in.has_delete_predicate()) { |
207 | 0 | out->mutable_delete_predicate()->CopyFrom(in.delete_predicate()); |
208 | 0 | } |
209 | 0 | out->set_empty(in.empty()); |
210 | 0 | out->mutable_load_id()->CopyFrom(in.load_id()); |
211 | 0 | out->set_delete_flag(in.delete_flag()); |
212 | 0 | out->set_creation_time(in.creation_time()); |
213 | 0 | if (in.has_tablet_uid()) { |
214 | 0 | out->mutable_tablet_uid()->CopyFrom(in.tablet_uid()); |
215 | 0 | } |
216 | 0 | out->set_num_segments(in.num_segments()); |
217 | 0 | out->set_rowset_id_v2(in.rowset_id_v2()); |
218 | 0 | out->set_resource_id(in.resource_id()); |
219 | 0 | out->set_newest_write_timestamp(in.newest_write_timestamp()); |
220 | 0 | out->mutable_segments_key_bounds()->CopyFrom(in.segments_key_bounds()); |
221 | 0 | if (in.has_tablet_schema()) { |
222 | 0 | cloud_tablet_schema_to_doris(out->mutable_tablet_schema(), in.tablet_schema()); |
223 | 0 | } |
224 | 0 | if (dict != nullptr) { |
225 | 0 | fill_schema_with_dict(in, out, *dict); |
226 | 0 | } |
227 | 0 | out->set_txn_expiration(in.txn_expiration()); |
228 | 0 | out->set_segments_overlap_pb(in.segments_overlap_pb()); |
229 | 0 | out->mutable_segments_file_size()->CopyFrom(in.segments_file_size()); |
230 | 0 | out->set_index_id(in.index_id()); |
231 | 0 | if (in.has_schema_version()) { |
232 | | // See cloud/src/meta-service/meta_service_schema.cpp for details. |
233 | 0 | out->set_schema_version(in.schema_version()); |
234 | 0 | } |
235 | 0 | out->set_enable_segments_file_size(in.enable_segments_file_size()); |
236 | 0 | out->set_enable_inverted_index_file_info(in.enable_inverted_index_file_info()); |
237 | 0 | out->mutable_inverted_index_file_info()->CopyFrom(in.inverted_index_file_info()); |
238 | 0 | } |
239 | | |
240 | | void cloud_rowset_meta_to_doris(RowsetMetaPB* out, RowsetMetaCloudPB&& in, |
241 | 0 | const SchemaCloudDictionary* dict) { |
242 | | // ATTN: please keep the set order aligned with the definition of proto `TabletSchemaCloudPB`. |
243 | 0 | out->set_rowset_id(in.rowset_id()); |
244 | 0 | out->set_partition_id(in.partition_id()); |
245 | 0 | out->set_tablet_id(in.tablet_id()); |
246 | 0 | out->set_txn_id(in.txn_id()); |
247 | 0 | out->set_tablet_schema_hash(in.tablet_schema_hash()); |
248 | 0 | out->set_rowset_type(in.rowset_type()); |
249 | 0 | out->set_rowset_state(in.rowset_state()); |
250 | 0 | out->set_start_version(in.start_version()); |
251 | 0 | out->set_end_version(in.end_version()); |
252 | 0 | out->set_version_hash(in.version_hash()); |
253 | 0 | out->set_num_rows(in.num_rows()); |
254 | 0 | out->set_total_disk_size(in.total_disk_size()); |
255 | 0 | out->set_data_disk_size(in.data_disk_size()); |
256 | 0 | out->set_index_disk_size(in.index_disk_size()); |
257 | 0 | out->mutable_zone_maps()->Swap(in.mutable_zone_maps()); |
258 | 0 | if (in.has_delete_predicate()) { |
259 | 0 | out->mutable_delete_predicate()->Swap(in.mutable_delete_predicate()); |
260 | 0 | } |
261 | 0 | out->set_empty(in.empty()); |
262 | 0 | out->mutable_load_id()->CopyFrom(in.load_id()); |
263 | 0 | out->set_delete_flag(in.delete_flag()); |
264 | 0 | out->set_creation_time(in.creation_time()); |
265 | 0 | if (in.has_tablet_uid()) { |
266 | 0 | out->mutable_tablet_uid()->CopyFrom(in.tablet_uid()); |
267 | 0 | } |
268 | 0 | out->set_num_segments(in.num_segments()); |
269 | 0 | out->set_rowset_id_v2(in.rowset_id_v2()); |
270 | 0 | out->set_resource_id(in.resource_id()); |
271 | 0 | out->set_newest_write_timestamp(in.newest_write_timestamp()); |
272 | 0 | out->mutable_segments_key_bounds()->Swap(in.mutable_segments_key_bounds()); |
273 | 0 | if (in.has_tablet_schema()) { |
274 | 0 | cloud_tablet_schema_to_doris(out->mutable_tablet_schema(), |
275 | 0 | std::move(*in.mutable_tablet_schema())); |
276 | 0 | } |
277 | 0 | if (dict != nullptr) { |
278 | 0 | fill_schema_with_dict(in, out, *dict); |
279 | 0 | } |
280 | 0 | out->set_txn_expiration(in.txn_expiration()); |
281 | 0 | out->set_segments_overlap_pb(in.segments_overlap_pb()); |
282 | 0 | out->mutable_segments_file_size()->Swap(in.mutable_segments_file_size()); |
283 | 0 | out->set_index_id(in.index_id()); |
284 | 0 | if (in.has_schema_version()) { |
285 | | // See cloud/src/meta-service/meta_service_schema.cpp for details. |
286 | 0 | out->set_schema_version(in.schema_version()); |
287 | 0 | } |
288 | 0 | out->set_enable_segments_file_size(in.enable_segments_file_size()); |
289 | 0 | out->set_enable_inverted_index_file_info(in.enable_inverted_index_file_info()); |
290 | 0 | out->mutable_inverted_index_file_info()->Swap(in.mutable_inverted_index_file_info()); |
291 | 0 | } |
292 | | |
293 | 0 | TabletSchemaCloudPB doris_tablet_schema_to_cloud(const TabletSchemaPB& in) { |
294 | 0 | TabletSchemaCloudPB out; |
295 | 0 | doris_tablet_schema_to_cloud(&out, in); |
296 | 0 | return out; |
297 | 0 | } |
298 | | |
299 | 0 | TabletSchemaCloudPB doris_tablet_schema_to_cloud(TabletSchemaPB&& in) { |
300 | | // ATTN: please keep the set order aligned with the definition of proto. |
301 | 0 | TabletSchemaCloudPB out; |
302 | 0 | doris_tablet_schema_to_cloud(&out, std::move(in)); |
303 | 0 | return out; |
304 | 0 | } |
305 | | |
306 | 0 | void doris_tablet_schema_to_cloud(TabletSchemaCloudPB* out, const TabletSchemaPB& in) { |
307 | | // ATTN: please keep the set order aligned with the definition of proto. |
308 | 0 | out->set_keys_type(in.keys_type()); |
309 | 0 | out->mutable_column()->CopyFrom(in.column()); |
310 | 0 | out->set_num_short_key_columns(in.num_short_key_columns()); |
311 | 0 | out->set_num_rows_per_row_block(in.num_rows_per_row_block()); |
312 | 0 | out->set_compress_kind(in.compress_kind()); |
313 | 0 | out->set_bf_fpp(in.bf_fpp()); |
314 | 0 | out->set_next_column_unique_id(in.next_column_unique_id()); |
315 | 0 | out->set_delete_sign_idx(in.delete_sign_idx()); |
316 | 0 | out->set_sequence_col_idx(in.sequence_col_idx()); |
317 | 0 | out->set_sort_type(in.sort_type()); |
318 | 0 | out->set_sort_col_num(in.sort_col_num()); |
319 | 0 | out->set_compression_type(in.compression_type()); |
320 | 0 | out->set_schema_version(in.schema_version()); |
321 | 0 | out->set_disable_auto_compaction(in.disable_auto_compaction()); |
322 | 0 | out->mutable_index()->CopyFrom(in.index()); |
323 | 0 | out->set_version_col_idx(in.version_col_idx()); |
324 | 0 | out->set_store_row_column(in.store_row_column()); |
325 | 0 | out->set_enable_single_replica_compaction(in.enable_single_replica_compaction()); |
326 | 0 | out->set_skip_write_index_on_load(in.skip_write_index_on_load()); |
327 | 0 | out->mutable_cluster_key_idxes()->CopyFrom(in.cluster_key_idxes()); |
328 | 0 | out->set_is_dynamic_schema(in.is_dynamic_schema()); |
329 | 0 | out->mutable_row_store_column_unique_ids()->CopyFrom(in.row_store_column_unique_ids()); |
330 | 0 | out->set_inverted_index_storage_format(in.inverted_index_storage_format()); |
331 | 0 | out->set_enable_variant_flatten_nested(in.variant_enable_flatten_nested()); |
332 | 0 | out->set_skip_bitmap_col_idx(in.skip_bitmap_col_idx()); |
333 | 0 | out->set_storage_page_size(in.storage_page_size()); |
334 | 0 | } |
335 | | |
336 | 0 | void doris_tablet_schema_to_cloud(TabletSchemaCloudPB* out, TabletSchemaPB&& in) { |
337 | 0 | out->set_keys_type(in.keys_type()); |
338 | 0 | out->mutable_column()->Swap(in.mutable_column()); |
339 | 0 | out->set_num_short_key_columns(in.num_short_key_columns()); |
340 | 0 | out->set_num_rows_per_row_block(in.num_rows_per_row_block()); |
341 | 0 | out->set_compress_kind(in.compress_kind()); |
342 | 0 | out->set_bf_fpp(in.bf_fpp()); |
343 | 0 | out->set_next_column_unique_id(in.next_column_unique_id()); |
344 | 0 | out->set_delete_sign_idx(in.delete_sign_idx()); |
345 | 0 | out->set_sequence_col_idx(in.sequence_col_idx()); |
346 | 0 | out->set_sort_type(in.sort_type()); |
347 | 0 | out->set_sort_col_num(in.sort_col_num()); |
348 | 0 | out->set_compression_type(in.compression_type()); |
349 | 0 | out->set_schema_version(in.schema_version()); |
350 | 0 | out->set_disable_auto_compaction(in.disable_auto_compaction()); |
351 | 0 | out->mutable_index()->Swap(in.mutable_index()); |
352 | 0 | out->set_version_col_idx(in.version_col_idx()); |
353 | 0 | out->set_store_row_column(in.store_row_column()); |
354 | 0 | out->set_enable_single_replica_compaction(in.enable_single_replica_compaction()); |
355 | 0 | out->set_skip_write_index_on_load(in.skip_write_index_on_load()); |
356 | 0 | out->mutable_cluster_key_idxes()->Swap(in.mutable_cluster_key_idxes()); |
357 | 0 | out->set_is_dynamic_schema(in.is_dynamic_schema()); |
358 | 0 | out->mutable_row_store_column_unique_ids()->Swap(in.mutable_row_store_column_unique_ids()); |
359 | 0 | out->set_inverted_index_storage_format(in.inverted_index_storage_format()); |
360 | 0 | out->set_enable_variant_flatten_nested(in.variant_enable_flatten_nested()); |
361 | 0 | out->set_skip_bitmap_col_idx(in.skip_bitmap_col_idx()); |
362 | 0 | out->set_storage_page_size(in.storage_page_size()); |
363 | 0 | } |
364 | | |
365 | 0 | TabletSchemaPB cloud_tablet_schema_to_doris(const TabletSchemaCloudPB& in) { |
366 | 0 | TabletSchemaPB out; |
367 | 0 | cloud_tablet_schema_to_doris(&out, in); |
368 | 0 | return out; |
369 | 0 | } |
370 | | |
371 | 0 | TabletSchemaPB cloud_tablet_schema_to_doris(TabletSchemaCloudPB&& in) { |
372 | 0 | TabletSchemaPB out; |
373 | 0 | cloud_tablet_schema_to_doris(&out, std::move(in)); |
374 | 0 | return out; |
375 | 0 | } |
376 | | |
377 | 0 | void cloud_tablet_schema_to_doris(TabletSchemaPB* out, const TabletSchemaCloudPB& in) { |
378 | | // ATTN: please keep the set order aligned with the definition of proto. |
379 | 0 | out->set_keys_type(in.keys_type()); |
380 | 0 | out->mutable_column()->CopyFrom(in.column()); |
381 | 0 | out->set_num_short_key_columns(in.num_short_key_columns()); |
382 | 0 | out->set_num_rows_per_row_block(in.num_rows_per_row_block()); |
383 | 0 | out->set_compress_kind(in.compress_kind()); |
384 | 0 | out->set_bf_fpp(in.bf_fpp()); |
385 | 0 | out->set_next_column_unique_id(in.next_column_unique_id()); |
386 | 0 | out->set_delete_sign_idx(in.delete_sign_idx()); |
387 | 0 | out->set_sequence_col_idx(in.sequence_col_idx()); |
388 | 0 | out->set_sort_type(in.sort_type()); |
389 | 0 | out->set_sort_col_num(in.sort_col_num()); |
390 | 0 | out->set_compression_type(in.compression_type()); |
391 | 0 | out->set_schema_version(in.schema_version()); |
392 | 0 | out->set_disable_auto_compaction(in.disable_auto_compaction()); |
393 | 0 | out->mutable_index()->CopyFrom(in.index()); |
394 | 0 | out->set_version_col_idx(in.version_col_idx()); |
395 | 0 | out->set_store_row_column(in.store_row_column()); |
396 | 0 | out->set_enable_single_replica_compaction(in.enable_single_replica_compaction()); |
397 | 0 | out->set_skip_write_index_on_load(in.skip_write_index_on_load()); |
398 | 0 | out->mutable_cluster_key_idxes()->CopyFrom(in.cluster_key_idxes()); |
399 | 0 | out->set_is_dynamic_schema(in.is_dynamic_schema()); |
400 | 0 | out->mutable_row_store_column_unique_ids()->CopyFrom(in.row_store_column_unique_ids()); |
401 | 0 | out->set_inverted_index_storage_format(in.inverted_index_storage_format()); |
402 | 0 | out->set_variant_enable_flatten_nested(in.enable_variant_flatten_nested()); |
403 | 0 | out->set_skip_bitmap_col_idx(in.skip_bitmap_col_idx()); |
404 | 0 | out->set_storage_page_size(in.storage_page_size()); |
405 | 0 | } |
406 | | |
407 | 0 | void cloud_tablet_schema_to_doris(TabletSchemaPB* out, TabletSchemaCloudPB&& in) { |
408 | | // ATTN: please keep the set order aligned with the definition of proto. |
409 | 0 | out->set_keys_type(in.keys_type()); |
410 | 0 | out->mutable_column()->Swap(in.mutable_column()); |
411 | 0 | out->set_num_short_key_columns(in.num_short_key_columns()); |
412 | 0 | out->set_num_rows_per_row_block(in.num_rows_per_row_block()); |
413 | 0 | out->set_compress_kind(in.compress_kind()); |
414 | 0 | out->set_bf_fpp(in.bf_fpp()); |
415 | 0 | out->set_next_column_unique_id(in.next_column_unique_id()); |
416 | 0 | out->set_delete_sign_idx(in.delete_sign_idx()); |
417 | 0 | out->set_sequence_col_idx(in.sequence_col_idx()); |
418 | 0 | out->set_sort_type(in.sort_type()); |
419 | 0 | out->set_sort_col_num(in.sort_col_num()); |
420 | 0 | out->set_compression_type(in.compression_type()); |
421 | 0 | out->set_schema_version(in.schema_version()); |
422 | 0 | out->set_disable_auto_compaction(in.disable_auto_compaction()); |
423 | 0 | out->mutable_index()->Swap(in.mutable_index()); |
424 | 0 | out->set_version_col_idx(in.version_col_idx()); |
425 | 0 | out->set_store_row_column(in.store_row_column()); |
426 | 0 | out->set_enable_single_replica_compaction(in.enable_single_replica_compaction()); |
427 | 0 | out->set_skip_write_index_on_load(in.skip_write_index_on_load()); |
428 | 0 | out->mutable_cluster_key_idxes()->Swap(in.mutable_cluster_key_idxes()); |
429 | 0 | out->set_is_dynamic_schema(in.is_dynamic_schema()); |
430 | 0 | out->mutable_row_store_column_unique_ids()->Swap(in.mutable_row_store_column_unique_ids()); |
431 | 0 | out->set_inverted_index_storage_format(in.inverted_index_storage_format()); |
432 | 0 | out->set_variant_enable_flatten_nested(in.enable_variant_flatten_nested()); |
433 | 0 | out->set_skip_bitmap_col_idx(in.skip_bitmap_col_idx()); |
434 | 0 | out->set_storage_page_size(in.storage_page_size()); |
435 | 0 | } |
436 | | |
437 | 0 | TabletMetaCloudPB doris_tablet_meta_to_cloud(const TabletMetaPB& in) { |
438 | 0 | TabletMetaCloudPB out; |
439 | 0 | doris_tablet_meta_to_cloud(&out, in); |
440 | 0 | return out; |
441 | 0 | } |
442 | | |
443 | 0 | TabletMetaCloudPB doris_tablet_meta_to_cloud(TabletMetaPB&& in) { |
444 | 0 | TabletMetaCloudPB out; |
445 | 0 | doris_tablet_meta_to_cloud(&out, std::move(in)); |
446 | 0 | return out; |
447 | 0 | } |
448 | | |
449 | 0 | void doris_tablet_meta_to_cloud(TabletMetaCloudPB* out, const TabletMetaPB& in) { |
450 | | // ATTN: please keep the set order aligned with the definition of proto. |
451 | 0 | out->set_table_id(in.table_id()); |
452 | 0 | out->set_partition_id(in.partition_id()); |
453 | 0 | out->set_tablet_id(in.tablet_id()); |
454 | 0 | out->set_schema_hash(in.schema_hash()); |
455 | 0 | out->set_shard_id(in.shard_id()); |
456 | 0 | out->set_creation_time(in.creation_time()); |
457 | 0 | out->set_cumulative_layer_point(in.cumulative_layer_point()); |
458 | 0 | out->set_tablet_state(in.tablet_state()); |
459 | 0 | if (in.has_schema()) { |
460 | 0 | doris_tablet_schema_to_cloud(out->mutable_schema(), in.schema()); |
461 | 0 | } |
462 | 0 | if (in.rs_metas_size()) { |
463 | 0 | out->mutable_rs_metas()->Reserve(in.rs_metas_size()); |
464 | 0 | for (const auto& rs_meta : in.rs_metas()) { |
465 | 0 | doris_rowset_meta_to_cloud(out->add_rs_metas(), rs_meta); |
466 | 0 | } |
467 | 0 | } |
468 | | // ATTN: inc_rs_metas are deprecated, ignored here. |
469 | 0 | if (in.has_alter_task()) { |
470 | 0 | out->mutable_alter_task()->CopyFrom(in.alter_task()); |
471 | 0 | } |
472 | 0 | out->set_in_restore_mode(in.in_restore_mode()); |
473 | 0 | out->mutable_tablet_uid()->CopyFrom(in.tablet_uid()); |
474 | 0 | out->set_end_rowset_id(in.end_rowset_id()); |
475 | 0 | out->set_preferred_rowset_type(in.preferred_rowset_type()); |
476 | 0 | out->set_tablet_type(in.tablet_type()); |
477 | 0 | if (in.stale_rs_metas_size()) { |
478 | 0 | out->mutable_stale_rs_metas()->Reserve(in.stale_rs_metas_size()); |
479 | 0 | for (const auto& rs_meta : in.stale_rs_metas()) { |
480 | 0 | doris_rowset_meta_to_cloud(out->add_stale_rs_metas(), rs_meta); |
481 | 0 | } |
482 | 0 | } |
483 | 0 | out->set_replica_id(in.replica_id()); |
484 | 0 | if (in.has_delete_bitmap()) { |
485 | 0 | out->mutable_delete_bitmap()->CopyFrom(in.delete_bitmap()); |
486 | 0 | } |
487 | 0 | out->set_enable_unique_key_merge_on_write(in.enable_unique_key_merge_on_write()); |
488 | 0 | out->set_storage_policy_id(in.storage_policy_id()); |
489 | 0 | out->mutable_cooldown_meta_id()->CopyFrom(in.cooldown_meta_id()); |
490 | 0 | if (in.has_binlog_config()) { |
491 | 0 | out->mutable_binlog_config()->CopyFrom(in.binlog_config()); |
492 | 0 | } |
493 | 0 | out->set_compaction_policy(in.compaction_policy()); |
494 | 0 | out->set_time_series_compaction_goal_size_mbytes(in.time_series_compaction_goal_size_mbytes()); |
495 | 0 | out->set_time_series_compaction_file_count_threshold( |
496 | 0 | in.time_series_compaction_file_count_threshold()); |
497 | 0 | out->set_time_series_compaction_time_threshold_seconds( |
498 | 0 | in.time_series_compaction_time_threshold_seconds()); |
499 | 0 | out->set_time_series_compaction_empty_rowsets_threshold( |
500 | 0 | in.time_series_compaction_empty_rowsets_threshold()); |
501 | 0 | out->set_time_series_compaction_level_threshold(in.time_series_compaction_level_threshold()); |
502 | 0 | out->set_index_id(in.index_id()); |
503 | 0 | out->set_is_in_memory(in.is_in_memory()); |
504 | 0 | out->set_is_persistent(in.is_persistent()); |
505 | 0 | out->set_table_name(in.table_name()); |
506 | 0 | out->set_ttl_seconds(in.ttl_seconds()); |
507 | 0 | if (in.has_schema_version()) { |
508 | 0 | out->set_schema_version(in.schema_version()); |
509 | 0 | } |
510 | 0 | } |
511 | | |
512 | 0 | void doris_tablet_meta_to_cloud(TabletMetaCloudPB* out, TabletMetaPB&& in) { |
513 | | // ATTN: please keep the set order aligned with the definition of proto. |
514 | 0 | out->set_table_id(in.table_id()); |
515 | 0 | out->set_partition_id(in.partition_id()); |
516 | 0 | out->set_tablet_id(in.tablet_id()); |
517 | 0 | out->set_schema_hash(in.schema_hash()); |
518 | 0 | out->set_shard_id(in.shard_id()); |
519 | 0 | out->set_creation_time(in.creation_time()); |
520 | 0 | out->set_cumulative_layer_point(in.cumulative_layer_point()); |
521 | 0 | out->set_tablet_state(in.tablet_state()); |
522 | 0 | if (in.has_schema()) { |
523 | 0 | doris_tablet_schema_to_cloud(out->mutable_schema(), std::move(*in.mutable_schema())); |
524 | 0 | } |
525 | 0 | if (in.rs_metas_size()) { |
526 | 0 | size_t rs_metas_size = in.rs_metas_size(); |
527 | 0 | out->mutable_rs_metas()->Reserve(rs_metas_size); |
528 | 0 | for (size_t i = 0; i < rs_metas_size; ++i) { |
529 | 0 | doris_rowset_meta_to_cloud(out->add_rs_metas(), std::move(*in.mutable_rs_metas(i))); |
530 | 0 | } |
531 | 0 | } |
532 | | // ATTN: inc_rs_metas are deprecated, ignored here. |
533 | 0 | if (in.has_alter_task()) { |
534 | 0 | out->mutable_alter_task()->Swap(in.mutable_alter_task()); |
535 | 0 | } |
536 | 0 | out->set_in_restore_mode(in.in_restore_mode()); |
537 | 0 | out->mutable_tablet_uid()->CopyFrom(in.tablet_uid()); |
538 | 0 | out->set_end_rowset_id(in.end_rowset_id()); |
539 | 0 | out->set_preferred_rowset_type(in.preferred_rowset_type()); |
540 | 0 | out->set_tablet_type(in.tablet_type()); |
541 | 0 | if (in.stale_rs_metas_size()) { |
542 | 0 | size_t rs_metas_size = in.stale_rs_metas_size(); |
543 | 0 | out->mutable_stale_rs_metas()->Reserve(rs_metas_size); |
544 | 0 | for (size_t i = 0; i < rs_metas_size; i++) { |
545 | 0 | doris_rowset_meta_to_cloud(out->add_stale_rs_metas(), |
546 | 0 | std::move(*in.mutable_stale_rs_metas(i))); |
547 | 0 | } |
548 | 0 | } |
549 | 0 | out->set_replica_id(in.replica_id()); |
550 | 0 | if (in.has_delete_bitmap()) { |
551 | 0 | out->mutable_delete_bitmap()->Swap(in.mutable_delete_bitmap()); |
552 | 0 | } |
553 | 0 | out->set_enable_unique_key_merge_on_write(in.enable_unique_key_merge_on_write()); |
554 | 0 | out->set_storage_policy_id(in.storage_policy_id()); |
555 | 0 | out->mutable_cooldown_meta_id()->CopyFrom(in.cooldown_meta_id()); |
556 | 0 | if (in.has_binlog_config()) { |
557 | 0 | out->mutable_binlog_config()->Swap(in.mutable_binlog_config()); |
558 | 0 | } |
559 | 0 | out->set_compaction_policy(in.compaction_policy()); |
560 | 0 | out->set_time_series_compaction_goal_size_mbytes(in.time_series_compaction_goal_size_mbytes()); |
561 | 0 | out->set_time_series_compaction_file_count_threshold( |
562 | 0 | in.time_series_compaction_file_count_threshold()); |
563 | 0 | out->set_time_series_compaction_time_threshold_seconds( |
564 | 0 | in.time_series_compaction_time_threshold_seconds()); |
565 | 0 | out->set_time_series_compaction_empty_rowsets_threshold( |
566 | 0 | in.time_series_compaction_empty_rowsets_threshold()); |
567 | 0 | out->set_time_series_compaction_level_threshold(in.time_series_compaction_level_threshold()); |
568 | 0 | out->set_index_id(in.index_id()); |
569 | 0 | out->set_is_in_memory(in.is_in_memory()); |
570 | 0 | out->set_is_persistent(in.is_persistent()); |
571 | 0 | out->set_table_name(in.table_name()); |
572 | 0 | out->set_ttl_seconds(in.ttl_seconds()); |
573 | 0 | if (in.has_schema_version()) { |
574 | 0 | out->set_schema_version(in.schema_version()); |
575 | 0 | } |
576 | 0 | } |
577 | | |
578 | 0 | TabletMetaPB cloud_tablet_meta_to_doris(const TabletMetaCloudPB& in) { |
579 | 0 | TabletMetaPB out; |
580 | 0 | cloud_tablet_meta_to_doris(&out, in); |
581 | 0 | return out; |
582 | 0 | } |
583 | | |
584 | 0 | TabletMetaPB cloud_tablet_meta_to_doris(TabletMetaCloudPB&& in) { |
585 | 0 | TabletMetaPB out; |
586 | 0 | cloud_tablet_meta_to_doris(&out, std::move(in)); |
587 | 0 | return out; |
588 | 0 | } |
589 | | |
590 | 0 | void cloud_tablet_meta_to_doris(TabletMetaPB* out, const TabletMetaCloudPB& in) { |
591 | | // ATTN: please keep the set order aligned with the definition of proto. |
592 | 0 | out->set_table_id(in.table_id()); |
593 | 0 | out->set_partition_id(in.partition_id()); |
594 | 0 | out->set_tablet_id(in.tablet_id()); |
595 | 0 | out->set_schema_hash(in.schema_hash()); |
596 | 0 | out->set_shard_id(in.shard_id()); |
597 | 0 | out->set_creation_time(in.creation_time()); |
598 | 0 | out->set_cumulative_layer_point(in.cumulative_layer_point()); |
599 | 0 | out->set_tablet_state(in.tablet_state()); |
600 | 0 | if (in.has_schema()) { |
601 | 0 | cloud_tablet_schema_to_doris(out->mutable_schema(), in.schema()); |
602 | 0 | } |
603 | 0 | if (in.rs_metas_size()) { |
604 | 0 | out->mutable_rs_metas()->Reserve(in.rs_metas_size()); |
605 | 0 | for (const auto& rs_meta : in.rs_metas()) { |
606 | 0 | cloud_rowset_meta_to_doris(out->add_rs_metas(), rs_meta); |
607 | 0 | } |
608 | 0 | } |
609 | | // ATTN: inc_rs_metas are deprecated, ignored here. |
610 | 0 | if (in.has_alter_task()) { |
611 | 0 | out->mutable_alter_task()->CopyFrom(in.alter_task()); |
612 | 0 | } |
613 | 0 | out->set_in_restore_mode(in.in_restore_mode()); |
614 | 0 | out->mutable_tablet_uid()->CopyFrom(in.tablet_uid()); |
615 | 0 | out->set_end_rowset_id(in.end_rowset_id()); |
616 | 0 | out->set_preferred_rowset_type(in.preferred_rowset_type()); |
617 | 0 | out->set_tablet_type(in.tablet_type()); |
618 | 0 | if (in.stale_rs_metas_size()) { |
619 | 0 | out->mutable_stale_rs_metas()->Reserve(in.stale_rs_metas_size()); |
620 | 0 | for (const auto& rs_meta : in.stale_rs_metas()) { |
621 | 0 | cloud_rowset_meta_to_doris(out->add_stale_rs_metas(), rs_meta); |
622 | 0 | } |
623 | 0 | } |
624 | 0 | out->set_replica_id(in.replica_id()); |
625 | 0 | if (in.has_delete_bitmap()) { |
626 | 0 | out->mutable_delete_bitmap()->CopyFrom(in.delete_bitmap()); |
627 | 0 | } |
628 | 0 | out->set_enable_unique_key_merge_on_write(in.enable_unique_key_merge_on_write()); |
629 | 0 | out->set_storage_policy_id(in.storage_policy_id()); |
630 | 0 | out->mutable_cooldown_meta_id()->CopyFrom(in.cooldown_meta_id()); |
631 | 0 | if (in.has_binlog_config()) { |
632 | 0 | out->mutable_binlog_config()->CopyFrom(in.binlog_config()); |
633 | 0 | } |
634 | 0 | out->set_compaction_policy(in.compaction_policy()); |
635 | 0 | out->set_time_series_compaction_goal_size_mbytes(in.time_series_compaction_goal_size_mbytes()); |
636 | 0 | out->set_time_series_compaction_file_count_threshold( |
637 | 0 | in.time_series_compaction_file_count_threshold()); |
638 | 0 | out->set_time_series_compaction_time_threshold_seconds( |
639 | 0 | in.time_series_compaction_time_threshold_seconds()); |
640 | 0 | out->set_time_series_compaction_empty_rowsets_threshold( |
641 | 0 | in.time_series_compaction_empty_rowsets_threshold()); |
642 | 0 | out->set_time_series_compaction_level_threshold(in.time_series_compaction_level_threshold()); |
643 | 0 | out->set_index_id(in.index_id()); |
644 | 0 | out->set_is_in_memory(in.is_in_memory()); |
645 | 0 | out->set_is_persistent(in.is_persistent()); |
646 | 0 | out->set_table_name(in.table_name()); |
647 | 0 | out->set_ttl_seconds(in.ttl_seconds()); |
648 | 0 | if (in.has_schema_version()) { |
649 | 0 | out->set_schema_version(in.schema_version()); |
650 | 0 | } |
651 | 0 | } |
652 | | |
653 | 0 | void cloud_tablet_meta_to_doris(TabletMetaPB* out, TabletMetaCloudPB&& in) { |
654 | | // ATTN: please keep the set order aligned with the definition of proto. |
655 | 0 | out->set_table_id(in.table_id()); |
656 | 0 | out->set_partition_id(in.partition_id()); |
657 | 0 | out->set_tablet_id(in.tablet_id()); |
658 | 0 | out->set_schema_hash(in.schema_hash()); |
659 | 0 | out->set_shard_id(in.shard_id()); |
660 | 0 | out->set_creation_time(in.creation_time()); |
661 | 0 | out->set_cumulative_layer_point(in.cumulative_layer_point()); |
662 | 0 | out->set_tablet_state(in.tablet_state()); |
663 | 0 | if (in.has_schema()) { |
664 | 0 | cloud_tablet_schema_to_doris(out->mutable_schema(), std::move(*in.mutable_schema())); |
665 | 0 | } |
666 | 0 | if (in.rs_metas_size()) { |
667 | 0 | size_t rs_metas_size = in.rs_metas_size(); |
668 | 0 | out->mutable_rs_metas()->Reserve(rs_metas_size); |
669 | 0 | for (size_t i = 0; i < rs_metas_size; ++i) { |
670 | 0 | cloud_rowset_meta_to_doris(out->add_rs_metas(), std::move(*in.mutable_rs_metas(i))); |
671 | 0 | } |
672 | 0 | } |
673 | | // ATTN: inc_rs_metas are deprecated, ignored here. |
674 | 0 | if (in.has_alter_task()) { |
675 | 0 | out->mutable_alter_task()->Swap(in.mutable_alter_task()); |
676 | 0 | } |
677 | 0 | out->set_in_restore_mode(in.in_restore_mode()); |
678 | 0 | out->mutable_tablet_uid()->CopyFrom(in.tablet_uid()); |
679 | 0 | out->set_end_rowset_id(in.end_rowset_id()); |
680 | 0 | out->set_preferred_rowset_type(in.preferred_rowset_type()); |
681 | 0 | out->set_tablet_type(in.tablet_type()); |
682 | 0 | if (in.stale_rs_metas_size()) { |
683 | 0 | size_t rs_metas_size = in.stale_rs_metas_size(); |
684 | 0 | out->mutable_stale_rs_metas()->Reserve(rs_metas_size); |
685 | 0 | for (size_t i = 0; i < rs_metas_size; i++) { |
686 | 0 | cloud_rowset_meta_to_doris(out->add_stale_rs_metas(), |
687 | 0 | std::move(*in.mutable_stale_rs_metas(i))); |
688 | 0 | } |
689 | 0 | } |
690 | 0 | out->set_replica_id(in.replica_id()); |
691 | 0 | if (in.has_delete_bitmap()) { |
692 | 0 | out->mutable_delete_bitmap()->Swap(in.mutable_delete_bitmap()); |
693 | 0 | } |
694 | 0 | out->set_enable_unique_key_merge_on_write(in.enable_unique_key_merge_on_write()); |
695 | 0 | out->set_storage_policy_id(in.storage_policy_id()); |
696 | 0 | out->mutable_cooldown_meta_id()->CopyFrom(in.cooldown_meta_id()); |
697 | 0 | if (in.has_binlog_config()) { |
698 | 0 | out->mutable_binlog_config()->Swap(in.mutable_binlog_config()); |
699 | 0 | } |
700 | 0 | out->set_compaction_policy(in.compaction_policy()); |
701 | 0 | out->set_time_series_compaction_goal_size_mbytes(in.time_series_compaction_goal_size_mbytes()); |
702 | 0 | out->set_time_series_compaction_file_count_threshold( |
703 | 0 | in.time_series_compaction_file_count_threshold()); |
704 | 0 | out->set_time_series_compaction_time_threshold_seconds( |
705 | 0 | in.time_series_compaction_time_threshold_seconds()); |
706 | 0 | out->set_time_series_compaction_empty_rowsets_threshold( |
707 | 0 | in.time_series_compaction_empty_rowsets_threshold()); |
708 | 0 | out->set_time_series_compaction_level_threshold(in.time_series_compaction_level_threshold()); |
709 | 0 | out->set_index_id(in.index_id()); |
710 | 0 | out->set_is_in_memory(in.is_in_memory()); |
711 | 0 | out->set_is_persistent(in.is_persistent()); |
712 | 0 | out->set_table_name(in.table_name()); |
713 | 0 | out->set_ttl_seconds(in.ttl_seconds()); |
714 | 0 | if (in.has_schema_version()) { |
715 | 0 | out->set_schema_version(in.schema_version()); |
716 | 0 | } |
717 | 0 | } |
718 | | |
719 | | } // namespace doris::cloud |