devillove084 commented on code in PR #51:
URL: https://github.com/apache/paimon-rust/pull/51#discussion_r1719762443
##########
crates/paimon/src/io/file_io.rs:
##########
@@ -85,42 +99,47 @@ impl FileIO {
/// References:
<https://github.com/apache/paimon/blob/release-0.8.2/paimon-common/src/main/java/org/apache/paimon/fs/FileIO.java#L105>
///
/// FIXME: how to handle large dir? Better to return a stream instead?
- pub async fn list_status(&self, path: &str) -> Result<Vec<FileStatus>> {
- let entries = self
- .op
- .list_with(path)
- .metakey(Metakey::ContentLength | Metakey::LastModified)
- .await
- .context(IoUnexpectedSnafu {
- message: "Failed to list file status".to_string(),
- })?;
+ pub async fn list_status(&self, path: String) -> Result<Vec<FileStatus>> {
+ let (op, relative_path) = self.inner_storage.create_operator(&path)?;
+
+ let entries = op.list(relative_path).await.context(IoUnexpectedSnafu {
+ message: "opendal list status failed",
+ })?;
+
+ let mut statuses = Vec::new();
- Ok(entries
- .into_iter()
- .map(|meta| FileStatus {
- size: meta.metadata().content_length(),
- is_dir: meta.metadata().is_dir(),
- last_modified: meta.metadata().last_modified(),
- path: format!("{}{}", path, meta.name()),
- })
- .collect())
+ for entry in entries {
+ let meta = entry.metadata();
+ statuses.push(FileStatus {
+ size: meta.content_length(),
+ is_dir: meta.is_dir(),
+ path: path.clone(),
+ last_modified: meta.last_modified(),
+ });
+ }
+
+ Ok(statuses)
}
/// Check if exists.
///
/// References:
<https://github.com/apache/paimon/blob/release-0.8.2/paimon-common/src/main/java/org/apache/paimon/fs/FileIO.java#L128>
- pub async fn exists(&self, path: &str) -> Result<bool> {
- self.op.is_exist(path).await.context(IoUnexpectedSnafu {
- message: "Failed to check file existence".to_string(),
+ pub async fn exists(&self, path: impl AsRef<str>) -> Result<bool> {
Review Comment:
Right
--
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]