fluss/rpc/message/
update_metadata.rs1use crate::metadata::{PhysicalTablePath, TablePath};
19use crate::proto::{MetadataResponse, PbPhysicalTablePath, PbTablePath};
20use crate::rpc::api_key::ApiKey;
21use crate::rpc::api_version::ApiVersion;
22use crate::rpc::frame::ReadError;
23use crate::rpc::frame::WriteError;
24use crate::rpc::message::{ReadVersionedType, RequestBody, WriteVersionedType};
25use std::collections::HashSet;
26use std::sync::Arc;
27
28use crate::{impl_read_version_type, impl_write_version_type, proto};
29use bytes::{Buf, BufMut};
30use prost::Message;
31
32pub struct UpdateMetadataRequest {
33 pub inner_request: proto::MetadataRequest,
34}
35
36impl UpdateMetadataRequest {
37 pub fn new(
38 table_paths: &HashSet<&TablePath>,
39 physical_table_paths: &HashSet<&Arc<PhysicalTablePath>>,
40 partition_ids: Vec<i64>,
41 ) -> Self {
42 UpdateMetadataRequest {
43 inner_request: proto::MetadataRequest {
44 table_path: table_paths
45 .iter()
46 .map(|path| PbTablePath {
47 database_name: path.database().to_string(),
48 table_name: path.table().to_string(),
49 })
50 .collect(),
51 partitions_path: physical_table_paths
52 .iter()
53 .map(|path| PbPhysicalTablePath {
54 database_name: path.get_database_name().to_string(),
55 table_name: path.get_table_name().to_string(),
56 partition_name: path.get_partition_name().map(|pn| pn.to_string()),
57 })
58 .collect(),
59 partitions_id: partition_ids,
60 },
61 }
62 }
63}
64
65impl RequestBody for UpdateMetadataRequest {
66 type ResponseBody = MetadataResponse;
67
68 const API_KEY: ApiKey = ApiKey::MetaData;
69
70 const REQUEST_VERSION: ApiVersion = ApiVersion(0);
71}
72
73impl_write_version_type!(UpdateMetadataRequest);
74impl_read_version_type!(MetadataResponse);