This is an automated email from the ASF dual-hosted git repository.
yuxia pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fluss-rust.git
The following commit(s) were added to refs/heads/main by this push:
new 8b583a8 feat: introduce list partitions in cpp binding (#260)
8b583a8 is described below
commit 8b583a81a196581393ced5062a599b9e865bbd18
Author: yuxia Luo <[email protected]>
AuthorDate: Fri Feb 6 12:08:20 2026 +0800
feat: introduce list partitions in cpp binding (#260)
---
bindings/cpp/include/fluss.hpp | 8 ++++++++
bindings/cpp/src/admin.cpp | 21 ++++++++++++++++++++
bindings/cpp/src/lib.rs | 44 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+)
diff --git a/bindings/cpp/include/fluss.hpp b/bindings/cpp/include/fluss.hpp
index 3ff9a26..9461f68 100644
--- a/bindings/cpp/include/fluss.hpp
+++ b/bindings/cpp/include/fluss.hpp
@@ -403,6 +403,11 @@ struct LakeSnapshot {
std::vector<BucketOffset> bucket_offsets;
};
+struct PartitionInfo {
+ int64_t partition_id;
+ std::string partition_name;
+};
+
class AppendWriter;
class LogScanner;
class Admin;
@@ -464,6 +469,9 @@ public:
const OffsetQuery& offset_query,
std::unordered_map<int32_t, int64_t>& out);
+ Result ListPartitionInfos(const TablePath& table_path,
+ std::vector<PartitionInfo>& out);
+
private:
Result DoListOffsets(const TablePath& table_path,
const std::vector<int32_t>& bucket_ids,
diff --git a/bindings/cpp/src/admin.cpp b/bindings/cpp/src/admin.cpp
index e410614..d19e444 100644
--- a/bindings/cpp/src/admin.cpp
+++ b/bindings/cpp/src/admin.cpp
@@ -162,4 +162,25 @@ Result Admin::ListPartitionOffsets(const TablePath&
table_path,
return DoListOffsets(table_path, bucket_ids, offset_query, out,
&partition_name);
}
+Result Admin::ListPartitionInfos(const TablePath& table_path,
+ std::vector<PartitionInfo>& out) {
+ if (!Available()) {
+ return utils::make_error(1, "Admin not available");
+ }
+
+ auto ffi_path = utils::to_ffi_table_path(table_path);
+ auto ffi_result = admin_->list_partition_infos(ffi_path);
+
+ auto result = utils::from_ffi_result(ffi_result.result);
+ if (result.Ok()) {
+ out.clear();
+ out.reserve(ffi_result.partition_infos.size());
+ for (const auto& pi : ffi_result.partition_infos) {
+ out.push_back({pi.partition_id, std::string(pi.partition_name)});
+ }
+ }
+
+ return result;
+}
+
} // namespace fluss
diff --git a/bindings/cpp/src/lib.rs b/bindings/cpp/src/lib.rs
index d6e3a9a..afdb7c0 100644
--- a/bindings/cpp/src/lib.rs
+++ b/bindings/cpp/src/lib.rs
@@ -175,6 +175,16 @@ mod ffi {
lake_snapshot: FfiLakeSnapshot,
}
+ struct FfiPartitionInfo {
+ partition_id: i64,
+ partition_name: String,
+ }
+
+ struct FfiListPartitionInfosResult {
+ result: FfiResult,
+ partition_infos: Vec<FfiPartitionInfo>,
+ }
+
extern "Rust" {
type Connection;
type Admin;
@@ -219,6 +229,10 @@ mod ffi {
bucket_ids: Vec<i32>,
offset_query: &FfiOffsetQuery,
) -> FfiListOffsetsResult;
+ fn list_partition_infos(
+ self: &Admin,
+ table_path: &FfiTablePath,
+ ) -> FfiListPartitionInfosResult;
// Table
unsafe fn delete_table(table: *mut Table);
@@ -551,6 +565,36 @@ impl Admin {
) -> ffi::FfiListOffsetsResult {
self.do_list_offsets(table_path, Some(&partition_name), bucket_ids,
offset_query)
}
+
+ fn list_partition_infos(
+ &self,
+ table_path: &ffi::FfiTablePath,
+ ) -> ffi::FfiListPartitionInfosResult {
+ let path = fcore::metadata::TablePath::new(
+ table_path.database_name.clone(),
+ table_path.table_name.clone(),
+ );
+ let result = RUNTIME.block_on(async {
self.inner.list_partition_infos(&path).await });
+ match result {
+ Ok(infos) => {
+ let partition_infos: Vec<ffi::FfiPartitionInfo> = infos
+ .into_iter()
+ .map(|info| ffi::FfiPartitionInfo {
+ partition_id: info.get_partition_id(),
+ partition_name: info.get_partition_name(),
+ })
+ .collect();
+ ffi::FfiListPartitionInfosResult {
+ result: ok_result(),
+ partition_infos,
+ }
+ }
+ Err(e) => ffi::FfiListPartitionInfosResult {
+ result: err_result(1, e.to_string()),
+ partition_infos: vec![],
+ },
+ }
+ }
}
// Table implementation