Skip to content

feat(io): Add delete_stream to Storage trait#2216

Open
CTTY wants to merge 6 commits intoapache:mainfrom
CTTY:ctty/delete-stream-new
Open

feat(io): Add delete_stream to Storage trait#2216
CTTY wants to merge 6 commits intoapache:mainfrom
CTTY:ctty/delete-stream-new

Conversation

@CTTY
Copy link
Collaborator

@CTTY CTTY commented Mar 6, 2026

Which issue does this PR close?

What changes are included in this PR?

  • Add delete_stream to Storage trait to support batch delete
  • Expose delete_stream in FileIO as well

Are these changes tested?

Added uts
Addded integtests for opendal

}
}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't add this for gcs because fake-gcs-server doesn't support batch delete

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't get your point.

/// # Arguments
///
/// * paths: A stream of absolute paths starting with the scheme string used to construct [`FileIO`].
pub async fn delete_stream(&self, paths: BoxStream<'static, String>) -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We could make this api more general as following:

fn delete_stream(&self, paths: impl Stream<Item=String>) 


// Use relativize_path for remaining paths to avoid rebuilding the operator each time.
while let Some(path) = paths.next().await {
let relative_path = self.relativize_path(&path)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some problems with this approach, what if we are deleting things as following:

s3://bucket1/a.txt
s3://bucketb/b.txt

}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't get your point.

}

#[tokio::test]
async fn test_file_io_s3_delete_stream() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only s3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support batch delete in Storage

2 participants