naivedogger commented on code in PR #5: URL: https://github.com/apache/fluss-rust/pull/5#discussion_r2335964850
########## crates/fluss/src/metadata/database.rs: ########## @@ -0,0 +1,240 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use crate::error::Result; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use crate::metadata::JsonSerde; +use serde_json::{json, Value}; +use crate::error::Error::JsonSerdeError; + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct DatabaseDescriptor { + comment: Option<String>, + custom_properties: HashMap<String, String>, +} + +#[derive(Debug, Clone)] +pub struct DatabaseInfo { + database_name: String, + database_descriptor: DatabaseDescriptor, + created_time: i64, + modified_time: i64, +} + +impl DatabaseInfo { + pub fn new( + database_name: String, + database_descriptor: DatabaseDescriptor, + created_time: i64, + modified_time: i64, + ) -> Self { + Self { + database_name, + database_descriptor, + created_time, + modified_time, + } + } + + pub fn database_name(&self) -> &str { + &self.database_name + } + + pub fn database_descriptor(&self) -> &DatabaseDescriptor { + &self.database_descriptor + } + + pub fn created_time(&self) -> i64 { + self.created_time + } + + pub fn modified_time(&self) -> i64 { + self.modified_time + } +} + +#[derive(Debug, Default)] +pub struct DatabaseDescriptorBuilder { + comment: Option<String>, + custom_properties: HashMap<String, String>, +} + +impl DatabaseDescriptor { + pub fn builder() -> DatabaseDescriptorBuilder { + DatabaseDescriptorBuilder::default() + } + + pub fn comment(&self) -> Option<&str> { + self.comment.as_deref() + } + + pub fn custom_properties(&self) -> &HashMap<String, String> { + &self.custom_properties + } +} + +impl DatabaseDescriptorBuilder { + pub fn new() -> Self { + Self::default() + } + + pub fn comment(mut self, comment: &str) -> Self { + self.comment = Some(comment.to_string()); + self + } + + pub fn custom_properties(mut self, properties: HashMap<String, String>) -> Self { + self.custom_properties = properties; + self + } + + pub fn custom_property(mut self, key: &str, value: &str) -> Self { + self.custom_properties.insert(key.to_string(), value.to_string()); + self + } + + pub fn build(self) -> Result<DatabaseDescriptor> { + Ok(DatabaseDescriptor { + comment: self.comment, + custom_properties: self.custom_properties, + }) + } +} + +impl DatabaseDescriptor { + const CUSTOM_PROPERTIES_NAME: &'static str = "custom_properties"; + const COMMENT_NAME: &'static str = "comment"; + const VERSION_KEY: &'static str = "version"; + const VERSION: u32 = 1; + + fn deserialize_properties(node: &Value) -> Result<HashMap<String, String>> { Review Comment: fixed ########## crates/fluss/src/metadata/database.rs: ########## @@ -0,0 +1,240 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use crate::error::Result; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use crate::metadata::JsonSerde; +use serde_json::{json, Value}; +use crate::error::Error::JsonSerdeError; + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct DatabaseDescriptor { + comment: Option<String>, + custom_properties: HashMap<String, String>, +} + +#[derive(Debug, Clone)] +pub struct DatabaseInfo { + database_name: String, + database_descriptor: DatabaseDescriptor, + created_time: i64, + modified_time: i64, +} + +impl DatabaseInfo { + pub fn new( + database_name: String, + database_descriptor: DatabaseDescriptor, + created_time: i64, + modified_time: i64, + ) -> Self { + Self { + database_name, + database_descriptor, + created_time, + modified_time, + } + } + + pub fn database_name(&self) -> &str { + &self.database_name + } + + pub fn database_descriptor(&self) -> &DatabaseDescriptor { + &self.database_descriptor + } + + pub fn created_time(&self) -> i64 { + self.created_time + } + + pub fn modified_time(&self) -> i64 { + self.modified_time + } +} + +#[derive(Debug, Default)] +pub struct DatabaseDescriptorBuilder { + comment: Option<String>, + custom_properties: HashMap<String, String>, +} + +impl DatabaseDescriptor { + pub fn builder() -> DatabaseDescriptorBuilder { + DatabaseDescriptorBuilder::default() + } + + pub fn comment(&self) -> Option<&str> { + self.comment.as_deref() + } + + pub fn custom_properties(&self) -> &HashMap<String, String> { + &self.custom_properties + } +} + +impl DatabaseDescriptorBuilder { + pub fn new() -> Self { Review Comment: fixed ########## crates/fluss/src/client/table/mod.rs: ########## @@ -29,6 +27,9 @@ mod append; mod scanner; mod writer; +pub use append::{TableAppend, AppendWriter}; Review Comment: Right. Fixed this. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
