| 246 | } |
| 247 | |
| 248 | void fillPartModel(const IStorage & storage, const IMergeTreeDataPart & part, Protos::DataModelPart & part_model, bool ignore_column_commit_time, UInt64 txn_id) |
| 249 | { |
| 250 | /// fill part info |
| 251 | Protos::DataModelPartInfo * model_info = part_model.mutable_part_info(); |
| 252 | fillPartInfoModel(part, *model_info); |
| 253 | |
| 254 | Protos::DataModelPartTTLInfo * model_ttl_info = part_model.mutable_part_ttl_info(); |
| 255 | fillPartTTLInfoModel(part, *model_ttl_info); |
| 256 | |
| 257 | part_model.set_size(part.bytes_on_disk); |
| 258 | part_model.set_rows_count(part.rows_count); |
| 259 | part_model.set_row_exists_count(part.row_exists_count.has_value() ? part.row_exists_count.value() : part.rows_count); |
| 260 | ///TODO: if we need marks_count in ce? |
| 261 | if (part.index_granularity_info.is_adaptive) |
| 262 | { |
| 263 | auto part_index_granularity = part.index_granularity.getIndexGranularities(); |
| 264 | part_model.mutable_index_granularities()->Add(part_index_granularity.begin(), part_index_granularity.end()); |
| 265 | } |
| 266 | |
| 267 | const auto cnch_part = std::dynamic_pointer_cast<const MergeTreeDataPartCNCH>(part.shared_from_this()); |
| 268 | if (cnch_part) |
| 269 | part_model.set_marks_count(cnch_part->getMarksCount()); |
| 270 | |
| 271 | /// Normally, the DataModelPart::txnID and DataModelPart::part_info::mutation are always the same. |
| 272 | /// But in some special cases(like ATTACH PARTITION, see CnchAttachProcessor::prepareParts), |
| 273 | /// the DataModelPart::txnID not equal to DataModelPart::part_info::mutation. |
| 274 | /// To handle this case, we need to set txnID and part_info::mutation separately. |
| 275 | /// And when getting txnID, use DataModelPart::txnID by default, and use mutation as fallback, see ServerDataPart::txnID() . |
| 276 | if (part.secondary_txn_id != IMergeTreeDataPart::NOT_INITIALIZED_COMMIT_TIME) |
| 277 | { |
| 278 | /// If we in a interactive transaction, use primary txn's txnid for this part |
| 279 | part_model.set_txnid(part.info.mutation); |
| 280 | } |
| 281 | else |
| 282 | { |
| 283 | part_model.set_txnid(txn_id ? txn_id : part.info.mutation); |
| 284 | } |
| 285 | part_model.set_bucket_number(part.bucket_number); |
| 286 | part_model.set_table_definition_hash(part.table_definition_hash); |
| 287 | part_model.set_commit_time(part.commit_time.toUInt64()); |
| 288 | // TODO support multiple namenode , mock 0 now. |
| 289 | part_model.set_data_path_id(0); |
| 290 | |
| 291 | if (part.deleted) |
| 292 | part_model.set_deleted(part.deleted); |
| 293 | if (part.mutation_commit_time) |
| 294 | part_model.set_mutation_commit_time(part.mutation_commit_time); |
| 295 | if (part.delete_flag) |
| 296 | part_model.set_delete_flag(part.delete_flag); |
| 297 | if (part.low_priority) |
| 298 | part_model.set_low_priority(part.low_priority); |
| 299 | if (part.last_modification_time) |
| 300 | part_model.set_last_modification_time(part.last_modification_time); |
| 301 | |
| 302 | if (!ignore_column_commit_time && part.columns_commit_time) |
| 303 | { |
| 304 | part_model.set_columns_commit_time(part.columns_commit_time); |
| 305 | } |
no test coverage detected