blackmwk commented on code in PR #2216:
URL: https://github.com/apache/iceberg-rust/pull/2216#discussion_r2915353718


##########
crates/storage/opendal/src/lib.rs:
##########
@@ -400,6 +498,40 @@ impl Storage for OpenDalStorage {
         Ok(op.remove_all(&path).await.map_err(from_opendal_error)?)
     }
 
+    async fn delete_stream(&self, mut paths: BoxStream<'static, String>) -> 
Result<()> {
+        let mut deleters: HashMap<String, opendal::Deleter> = HashMap::new();
+
+        while let Some(path) = paths.next().await {
+            let bucket = url::Url::parse(&path)
+                .ok()
+                .and_then(|u| u.host_str().map(|s| s.to_string()))
+                .unwrap_or_default();
+
+            let relative_path = if deleters.contains_key(&bucket) {
+                self.relativize_path(&path)?.to_string()
+            } else {
+                let (op, rel) = self.create_operator(&path)?;
+                let rel = rel.to_string();
+                let deleter = op.deleter().await.map_err(from_opendal_error)?;
+                deleters.insert(bucket.clone(), deleter);
+                rel
+            };
+
+            deleters
+                .get_mut(&bucket)
+                .unwrap()

Review Comment:
   nit: We could use `deleter.entry` api to avoid unwrap here.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to