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 09:04:01 UTC

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

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


##########
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())

Review Comment:
   Does it basically remove full validation cost?



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