Aitozi commented on code in PR #51:
URL: https://github.com/apache/paimon-rust/pull/51#discussion_r1718137983


##########
crates/paimon/src/io/file_io.rs:
##########
@@ -133,54 +158,441 @@ impl FileIO {
     /// Has the semantics of Unix 'mkdir -p'. Existence of the directory 
hierarchy is not an error.
     ///
     /// Reference: 
<https://github.com/apache/paimon/blob/release-0.8.2/paimon-common/src/main/java/org/apache/paimon/fs/FileIO.java#L150>
-    pub async fn mkdirs(&self, path: &str) -> Result<()> {
-        self.op.create_dir(path).await.context(IoUnexpectedSnafu {
-            message: "Failed to create dir".to_string(),
-        })?;
+    pub async fn mkdirs(&self, path: impl AsRef<str>) -> Result<()> {
+        let (op, relative_path) = self.inner_storage.create_operator(&path)?;
+
+        op.create_dir(relative_path)
+            .await
+            .context(IoUnexpectedSnafu {
+                message: "opendal create directory failed",
+            })?;
+
         Ok(())
     }
 
     /// Renames the file/directory src to dst.
     ///
     /// Reference: 
<https://github.com/apache/paimon/blob/release-0.8.2/paimon-common/src/main/java/org/apache/paimon/fs/FileIO.java#L159>
-    pub async fn rename(&self, src: &str, dst: &str) -> Result<()> {
-        self.op.rename(src, dst).await.context(IoUnexpectedSnafu {
-            message: "Failed to rename file".to_string(),
-        })?;
+    pub async fn rename(&self, src: impl AsRef<str>, dst: impl AsRef<str>) -> 
Result<()> {
+        let (op_src, relative_path_src) = 
self.inner_storage.create_operator(&src)?;
+        let (_, relative_path_dst) = self.inner_storage.create_operator(&dst)?;
+
+        op_src
+            .rename(relative_path_src, relative_path_dst)
+            .await
+            .context(IoUnexpectedSnafu {
+                message: "opendal rename failed",
+            })?;
+
         Ok(())
     }
 }
 
-/// FileStatus represents the status of a file.
+#[derive(Debug)]
+pub struct FileIOBuilder {
+    scheme_str: Option<String>,
+    props: HashMap<String, String>,
+}
+
+impl FileIOBuilder {
+    pub fn new(scheme_str: impl ToString) -> Self {
+        Self {
+            scheme_str: Some(scheme_str.to_string()),
+            props: HashMap::default(),
+        }
+    }
+
+    pub fn new_fs_io() -> Self {

Review Comment:
   -> `new_fs_io_builder` ?



##########
crates/paimon/Cargo.toml:
##########
@@ -26,8 +26,19 @@ edition.workspace = true
 license.workspace = true
 version.workspace = true
 
+[features]
+default = ["storage-memory", "storage-fs"]
+storage-all = ["storage-memory", "storage-fs"]
+
+storage-memory = ["opendal/services-memory"]

Review Comment:
   nit: do we need services-memory? Since in paimon basic test should work 
around local fs?



-- 
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]

Reply via email to