|
15 | 15 | // specific language governing permissions and limitations |
16 | 16 | // under the License. |
17 | 17 |
|
18 | | -use once_cell::sync::Lazy; |
| 18 | +use cstr::cstr; |
19 | 19 | use std::collections::HashMap; |
20 | | -use std::ffi::CString; |
| 20 | +use std::ffi::{CStr, CString}; |
21 | 21 | use std::sync::Arc; |
22 | 22 |
|
23 | 23 | use arrow::array::{new_null_array, RecordBatch, RecordBatchReader}; |
@@ -60,9 +60,8 @@ use crate::{ |
60 | 60 | expr::{sort_expr::PySortExpr, PyExpr}, |
61 | 61 | }; |
62 | 62 |
|
63 | | -/// File-level static CString for the Arrow array stream capsule name. |
64 | | -static ARROW_ARRAY_STREAM_NAME: Lazy<CString> = |
65 | | - Lazy::new(|| CString::new("arrow_array_stream").unwrap()); |
| 63 | +/// File-level static CStr for the Arrow array stream capsule name. |
| 64 | +static ARROW_ARRAY_STREAM_NAME: &CStr = cstr!("arrow_array_stream"); |
66 | 65 |
|
67 | 66 | // https://github.com/apache/datafusion-python/pull/1016#discussion_r1983239116 |
68 | 67 | // - we have not decided on the table_provider approach yet |
@@ -972,7 +971,8 @@ impl PyDataFrame { |
972 | 971 | // destructor provided by PyO3 will drop the stream unless ownership is |
973 | 972 | // transferred to PyArrow during import. |
974 | 973 | let stream = FFI_ArrowArrayStream::new(reader); |
975 | | - let capsule = PyCapsule::new(py, stream, Some(ARROW_ARRAY_STREAM_NAME.clone()))?; |
| 974 | + let name = CString::new(ARROW_ARRAY_STREAM_NAME.to_bytes()).unwrap(); |
| 975 | + let capsule = PyCapsule::new(py, stream, Some(name))?; |
976 | 976 | Ok(capsule) |
977 | 977 | } |
978 | 978 |
|
|
0 commit comments