alamb commented on issue #7383: URL: https://github.com/apache/arrow-rs/issues/7383#issuecomment-3107146545
> Hi [@alamb](https://github.com/alamb) and [@Dandandan](https://github.com/Dandandan), I'm looking into this issue and wanted to clarify what you meant by "using `Vec` directly." From what I see, the code is already using a `Vec`, so I assume you're suggesting a refactor like this: > > let mut intermediate = Vec::with_capacity(offsets.len() - 1); > for &offset in &offsets[1..] { > intermediate.push(offset + shift); > } > to use extend > > let mut intermediate = Vec::with_capacity(offsets.len() - 1); > intermediate.extend(offsets[1..].iter().map(|&offset| offset + shift)); > so that the code is more concise and the performance may improve. > > Am I right? Thanks! i think @Dandandan was referring to using the ArrayBuilders So for example, things that use a builder like ```rust let mut builder = Int32Builder::new() for i in 0..100 { builder.append_value(i) } let array = builder.build() ``` Is typically much faster to implement using Vec directly: ```rust let data: Vec<_> = (0..100).collect(); let array = Int32Array::from(data) ``` This is certainly true for primitive arrays. It is not clear to me it is the same for StringArrays, StringViewArray, etc. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
