You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "luoyuxia (via GitHub)" <gi...@apache.org> on 2026/02/04 06:23:06 UTC

[PR] feat: support subscribe partition in cpp binding [fluss-rust]

luoyuxia opened a new pull request, #236:
URL: https://github.com/apache/fluss-rust/pull/236

   <!--
   *Thank you very much for contributing to Fluss - we are happy that you want to help us improve Fluss. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GitHub issue](https://github.com/apache/fluss-rust/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no issue.
   
     - Name the pull request in the format "[component] Title of the pull request", where *[component]* should be replaced by the name of the component being changed. Typically, this corresponds to the component label assigned to the issue (e.g., [kv], [log], [client], [flink]). Skip *[component]* if you are unsure about which is the best component.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
   
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes.
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
   
   
   **(The sections below can be removed for hotfixes or typos)**
   -->
   
   ### Purpose
   
   <!-- Linking this pull request to the issue -->
   Linked issue: close #xxx
   
   <!-- What is the purpose of the change -->
   
   ### Brief change log
   
   <!-- Please describe the changes made in this pull request and explain how they address the issue -->
   
   ### Tests
   
   <!-- List UT and IT cases to verify this change -->
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support subscribe partition in cpp binding [fluss-rust]

Posted by "luoyuxia (via GitHub)" <gi...@apache.org>.
luoyuxia merged PR #236:
URL: https://github.com/apache/fluss-rust/pull/236


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support subscribe partition in cpp binding [fluss-rust]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #236:
URL: https://github.com/apache/fluss-rust/pull/236#discussion_r2762417891


##########
bindings/cpp/src/table.cpp:
##########
@@ -265,6 +265,15 @@ Result LogScanner::Subscribe(const std::vector<BucketSubscription>& bucket_offse
     return utils::from_ffi_result(ffi_result);
 }
 
+Result LogScanner::SubscribePartition(int64_t partition_id, int32_t bucket_id, int64_t start_offset) {
+    if (!Available()) {
+        return utils::make_error(1, "LogScanner not available");
+    }
+

Review Comment:
   `SubscribePartition` passes `partition_id` straight through to the Rust FFI. On the Rust side, `-1` currently has a special meaning (it routes to the non-partition `subscribe` path), so calling `SubscribePartition(-1, ...)` will not do what the API name implies. Consider validating `partition_id` here (e.g., reject negative values) to prevent surprising behavior at the C++ API boundary.
   ```suggestion
   
       if (partition_id < 0) {
           return utils::make_error(2, "partition_id must be non-negative");
       }
   ```



##########
bindings/cpp/src/lib.rs:
##########
@@ -790,6 +819,15 @@ impl LogScanner {
         }
     }
 
+    fn subscribe_partition(
+        &self,
+        partition_id: i64,
+        bucket_id: i32,
+        start_offset: i64,
+    ) -> ffi::FfiResult {

Review Comment:
   `subscribe_partition` forwards `partition_id` into `do_subscribe`, where `-1` is treated as a sentinel meaning “no partition” and will call `subscribe` instead of `subscribe_partition`. This makes `partition_id = -1` behave unexpectedly for callers and leaks an internal sentinel into the public FFI API. Add an explicit validation in `subscribe_partition` (e.g., reject `partition_id < 0` with a clear error) and/or refactor `do_subscribe` to take `Option<PartitionId>` so the sentinel value is not part of the value space.
   ```suggestion
       ) -> ffi::FfiResult {
           if partition_id < 0 {
               return err_result(1, "partition_id must be non-negative".to_string());
           }
   ```



-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org