MCPcopy Create free account
hub / github.com/apache/arrow-rs / value_to_string_view

Function value_to_string_view

arrow-cast/src/cast/string.rs:41–63  ·  view source on GitHub ↗
(
    array: &dyn Array,
    options: &CastOptions,
)

Source from the content-addressed store, hash-verified

39}
40
41pub(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
66pub(crate) fn parse_string<P: Parser, O: OffsetSizeTrait>(

Callers 2

cast_with_optionsFunction · 0.85
cast_from_decimalFunction · 0.85

Calls 10

try_newFunction · 0.85
lenMethod · 0.45
nullsMethod · 0.45
is_nullMethod · 0.45
append_nullMethod · 0.45
clearMethod · 0.45
writeMethod · 0.45
valueMethod · 0.45
append_valueMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected