QuakeWang commented on code in PR #1476:
URL: https://github.com/apache/paimon-rust/pull/1476#discussion_r4653395170


##########
bindings/c/src/bucket_router.rs:
##########
@@ -0,0 +1,170 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::ffi::{c_char, c_void};
+use std::ptr;
+
+use paimon::spec::TableSchema;
+use paimon::table::BucketRouter;
+
+use crate::error::{check_non_null, paimon_error, validate_cstr, 
PaimonErrorCode};
+use crate::result::paimon_result_bucket_router;
+use crate::types::paimon_bucket_router;
+use crate::write::import_record_batch;
+
+fn router_error(error: *mut paimon_error) -> paimon_result_bucket_router {
+    paimon_result_bucket_router {
+        router: ptr::null_mut(),
+        error,
+    }
+}
+
+fn router_ok(router: BucketRouter) -> paimon_result_bucket_router {
+    let inner = Box::into_raw(Box::new(router)) as *mut c_void;
+    paimon_result_bucket_router {
+        router: Box::into_raw(Box::new(paimon_bucket_router { inner })),
+        error: ptr::null_mut(),
+    }
+}
+
+/// Create a stateless bucket router directly from a Paimon TableSchema JSON.
+///
+/// Does not open a catalog, touch storage, or allocate file writers. Supports
+/// fixed-bucket (`default`, `mod`, `hive`) and postpone-bucket schemas.

Review Comment:
   For `bucket=-2`, this router uses only `postpone.default-bucket-num`. If the 
writer uses a different bucket count for the partition, the router may return 
different bucket IDs.



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

Reply via email to