You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/24 01:48:11 UTC

[GitHub] [arrow-rs] HaoYang670 commented on a diff in pull request #3168: Faster ByteArray to StringArray conversion

HaoYang670 commented on code in PR #3168:
URL: https://github.com/apache/arrow-rs/pull/3168#discussion_r1030986250


##########
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:
   👍
   How much performance improvement can we get?



-- 
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-unsubscribe@arrow.apache.org

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