zhaohaidao commented on issue #87: URL: https://github.com/apache/fluss-rust/issues/87#issuecomment-3734012575
> we can use `std::string_view` and `std::span` (C++20) respectively. @Kelvinyu1117 Hi, Kelvin, Thank you for your suggestion. Changing the type of `string_val` directly from `std::string` to `std::string_view` might have lifecycle issues, specifically: 1. `from_ffi_datum` receives `const ffi::FfiDatum& ffi_datum` (reference) and returns `Datum` (value). 2. `ffi_datum.string_val` is of type `rust::String`, and its underlying memory is managed by the Rust side. 3. After the function returns, the `Datum` will be held by the user, but the lifecycle of `ffi_datum` may have ended. If you wish to perform zero-copy optimization, I suggest exploring two approaches: 1. Leverage move semantics to transfer ownership. Specifically, transfer ownership of `string_val` from Rust to C++. 2. Explicitly introduce the `free` interface. When `string_val` is finished using, explicitly call the `free` interface to notify the Rust layer to release the relevant resources. cc @luoyuxia -- 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]
