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 2020/12/27 12:45:30 UTC

[GitHub] [arrow] Dandandan commented on a change in pull request #9016: ARROW-11037: [Rust] Optimized creation of string array from iterator.

Dandandan commented on a change in pull request #9016:
URL: https://github.com/apache/arrow/pull/9016#discussion_r549109082



##########
File path: rust/arrow/src/array/array_string.rs
##########
@@ -126,25 +126,28 @@ impl<OffsetSize: StringOffsetSizeTrait> GenericStringArray<OffsetSize> {
     }
 
     pub(crate) fn from_vec(v: Vec<&str>) -> Self {
-        let mut offsets = Vec::with_capacity(v.len() + 1);
-        let mut values = Vec::new();
+        let mut offsets =
+            MutableBuffer::new((v.len() + 1) * std::mem::size_of::<OffsetSize>());
+        let mut values = MutableBuffer::new(0);

Review comment:
       Might be interesting to test here whether it is cheaper to calculate offsets + total size first for `values` buffer based on final `length_so_far` so that it doesn't require extra allocations.




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

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