tustvold commented on code in PR #3168: URL: https://github.com/apache/arrow-rs/pull/3168#discussion_r1031244881
########## arrow-array/src/array/string_array.rs: ########## @@ -216,8 +216,19 @@ impl<OffsetSize: OffsetSizeTrait> From<GenericBinaryArray<OffsetSize>> for GenericStringArray<OffsetSize> { fn from(v: GenericBinaryArray<OffsetSize>) -> Self { + let offsets = v.value_offsets(); + let values = v.data().buffers()[1].as_ref(); + + // We only need to validate that all values are valid UTF-8 + let validated = std::str::from_utf8(values).unwrap(); + for offset in offsets.iter() { + assert!(validated.is_char_boundary(offset.as_usize())) + } + let builder = v.into_data().into_builder().data_type(Self::DATA_TYPE); - Self::from(builder.build().unwrap()) + // SAFETY: + // Validated UTF-8 above Review Comment: ``` byte_array_to_string_array 20000 time: [13.252 µs 13.254 µs 13.257 µs] change: [-67.094% -67.073% -67.049%] (p = 0.00 < 0.05) Performance has improved. Found 7 outliers among 100 measurements (7.00%) 1 (1.00%) high mild 6 (6.00%) high severe ``` -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org