You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by ti...@apache.org on 2026/08/03 03:08:06 UTC
(opendal) branch main updated: feat(binding/cpp): expose batch deletion API to C++ (#8015)
This is an automated email from the ASF dual-hosted git repository.
tisonkun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 645278480 feat(binding/cpp): expose batch deletion API to C++ (#8015)
645278480 is described below
commit 645278480e4a5f42e504fa43ea3f6c2b766ff7db
Author: dentiny <de...@gmail.com>
AuthorDate: Sun Aug 2 20:08:00 2026 -0700
feat(binding/cpp): expose batch deletion API to C++ (#8015)
---
bindings/cpp/include/opendal.hpp | 1 +
bindings/cpp/src/lib.rs | 5 +++++
bindings/cpp/src/operator.cpp | 9 +++++++++
bindings/cpp/tests/basic_test.cpp | 17 +++++++++++++++++
4 files changed, 32 insertions(+)
diff --git a/bindings/cpp/include/opendal.hpp b/bindings/cpp/include/opendal.hpp
index c922a92b2..ca1407a36 100644
--- a/bindings/cpp/include/opendal.hpp
+++ b/bindings/cpp/include/opendal.hpp
@@ -179,6 +179,7 @@ class Operator {
*/
void Remove(std::string_view path);
void Remove(std::string_view path, const DeleteOptions &options);
+ void RemoveAll(const std::vector<std::string> &paths);
/**
* @brief Get the metadata of a file or directory
diff --git a/bindings/cpp/src/lib.rs b/bindings/cpp/src/lib.rs
index 6aa974207..e0651b20f 100644
--- a/bindings/cpp/src/lib.rs
+++ b/bindings/cpp/src/lib.rs
@@ -286,6 +286,7 @@ mod ffi {
) -> Result<()>;
fn remove(self: &Operator, path: &str) -> Result<()>;
fn remove_options(self: &Operator, path: &str, opts: FfiDeleteOptions) -> Result<()>;
+ fn remove_all(self: &Operator, paths: Vec<String>) -> Result<()>;
fn stat(self: &Operator, path: &str) -> Result<Metadata>;
fn stat_options(self: &Operator, path: &str, opts: FfiStatOptions) -> Result<Metadata>;
fn list(self: &Operator, path: &str) -> Result<Vec<Entry>>;
@@ -602,6 +603,10 @@ impl Operator {
Ok(self.0.delete_options(path, delete_options(opts))?)
}
+ fn remove_all(&self, paths: Vec<String>) -> Result<()> {
+ Ok(self.0.delete_iter(paths)?)
+ }
+
fn stat(&self, path: &str) -> Result<ffi::Metadata> {
Ok(self.0.stat(path)?.into())
}
diff --git a/bindings/cpp/src/operator.cpp b/bindings/cpp/src/operator.cpp
index 5be092cbe..23eba90c6 100644
--- a/bindings/cpp/src/operator.cpp
+++ b/bindings/cpp/src/operator.cpp
@@ -369,6 +369,15 @@ void Operator::Remove(std::string_view path, const DeleteOptions &options) {
operator_->remove_options(utils::rust_str(path), ToFfiOptions(options));
}
+void Operator::RemoveAll(const std::vector<std::string> &paths) {
+ rust::Vec<rust::String> rust_paths;
+ rust_paths.reserve(paths.size());
+ for (const auto &path : paths) {
+ rust_paths.push_back(utils::rust_string(path));
+ }
+ operator_->remove_all(std::move(rust_paths));
+}
+
Metadata Operator::Stat(std::string_view path) {
return parse_meta_data(operator_->stat(utils::rust_str(path)));
}
diff --git a/bindings/cpp/tests/basic_test.cpp b/bindings/cpp/tests/basic_test.cpp
index 841523406..a19cfe3bf 100644
--- a/bindings/cpp/tests/basic_test.cpp
+++ b/bindings/cpp/tests/basic_test.cpp
@@ -296,6 +296,23 @@ TEST(OpenDALOptionsTest, DeleteOptions) {
EXPECT_FALSE(op.Exists("delete_options/file"));
}
+TEST(OpenDALOptionsTest, RemoveAll) {
+ opendal::Operator op("memory");
+ std::vector<std::string> paths;
+ for (int index = 0; index < 8; ++index) {
+ auto path = "remove_all/file_" + std::to_string(index);
+ op.Write(path, "hello");
+ EXPECT_TRUE(op.Exists(path));
+ paths.push_back(path);
+ }
+
+ op.RemoveAll(paths);
+
+ for (const auto &path : paths) {
+ EXPECT_FALSE(op.Exists(path));
+ }
+}
+
TEST(OpenDALOptionsTest, StatOptions) {
opendal::Operator op("memory");
op.Write("stat_options", "hello");