plusplusjiajia commented on code in PR #245:
URL: https://github.com/apache/paimon-rust/pull/245#discussion_r3086415356


##########
crates/paimon/src/table/schema_manager.rs:
##########
@@ -65,6 +66,40 @@ impl SchemaManager {
         format!("{}/{}{}", self.schema_directory(), SCHEMA_PREFIX, schema_id)
     }
 
+    /// List all schema ids sorted ascending. Returns an empty vector if the
+    /// schema directory is missing or empty.
+    ///
+    /// Mirrors Java 
[SchemaManager.listAllIds()](https://github.com/apache/paimon/blob/release-1.3/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManager.java).
+    pub async fn list_all_ids(&self) -> crate::Result<Vec<i64>> {
+        let mut ids: Vec<i64> = self
+            .file_io
+            .list_status(&self.schema_directory())
+            .await?
+            .into_iter()
+            .filter(|s| !s.is_dir)
+            .filter_map(|s| {
+                get_basename(s.path.as_str())
+                    .strip_prefix(SCHEMA_PREFIX)?
+                    .parse::<i64>()
+                    .ok()
+            })
+            .collect();
+        ids.sort_unstable();
+        Ok(ids)
+    }
+
+    /// List all schemas sorted by id ascending.
+    ///
+    /// Mirrors Java 
[SchemaManager.listAll()](https://github.com/apache/paimon/blob/release-1.3/paimon-core/src/main/java/org/apache/paimon/schema/SchemaManager.java).
+    pub async fn list_all(&self) -> crate::Result<Vec<Arc<TableSchema>>> {
+        let ids = self.list_all_ids().await?;
+        let mut schemas = Vec::with_capacity(ids.len());
+        for id in ids {
+            schemas.push(self.schema(id).await?);

Review Comment:
   @JingsongLi Good point, thanks! Done.



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