tlm365 commented on code in PR #6719:
URL: https://github.com/apache/arrow-rs/pull/6719#discussion_r1838456182
##########
arrow-cast/src/cast/string.rs:
##########
@@ -38,6 +38,22 @@ pub(crate) fn value_to_string<O: OffsetSizeTrait>(
Ok(Arc::new(builder.finish()))
}
+pub(crate) fn value_to_string_view(
+ array: &dyn Array,
+ options: &CastOptions,
+) -> Result<ArrayRef, ArrowError> {
+ let mut builder = StringViewBuilder::with_capacity(array.len());
+ let formatter = ArrayFormatter::try_new(array, &options.format_options)?;
+ let nulls = array.nulls();
+ for i in 0..array.len() {
+ match nulls.map(|x| x.is_null(i)).unwrap_or_default() {
+ false => builder.append_value(formatter.value(i).try_to_string()?),
Review Comment:
@tustvold Thanks so much for reviewing.
> It would be more optimal to use the std::fmt::write support as for
StringArray above.
> As written this will allocate for every value which will be very expensive
I get it now. Will try to implement it. TYSM ❤️
--
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]