(
array: &dyn Array,
options: &CastOptions,
)
| 39 | } |
| 40 | |
| 41 | pub(crate) fn value_to_string_view( |
| 42 | array: &dyn Array, |
| 43 | options: &CastOptions, |
| 44 | ) -> Result<ArrayRef, ArrowError> { |
| 45 | let mut builder = StringViewBuilder::with_capacity(array.len()); |
| 46 | let formatter = ArrayFormatter::try_new(array, &options.format_options)?; |
| 47 | let nulls = array.nulls(); |
| 48 | // buffer to avoid reallocating on each value |
| 49 | // TODO: replace with write to builder after https://github.com/apache/arrow-rs/issues/6373 |
| 50 | let mut buffer = String::new(); |
| 51 | for i in 0..array.len() { |
| 52 | match nulls.map(|x| x.is_null(i)).unwrap_or_default() { |
| 53 | true => builder.append_null(), |
| 54 | false => { |
| 55 | // write to buffer first and then copy into target array |
| 56 | buffer.clear(); |
| 57 | formatter.value(i).write(&mut buffer)?; |
| 58 | builder.append_value(&buffer) |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | Ok(Arc::new(builder.finish())) |
| 63 | } |
| 64 | |
| 65 | /// Parse UTF-8 |
| 66 | pub(crate) fn parse_string<P: Parser, O: OffsetSizeTrait>( |
no test coverage detected