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

Function extend_valid_utf8

arrow-cast/src/cast/string.rs:341–347  ·  view source on GitHub ↗

A specified helper to cast from `GenericBinaryArray` to `GenericStringArray` when they have same offset size so re-encoding offset is unnecessary.

(builder: &mut B, iter: I)

Source from the content-addressed store, hash-verified

339/// A specified helper to cast from `GenericBinaryArray` to `GenericStringArray` when they have same
340/// offset size so re-encoding offset is unnecessary.
341fn extend_valid_utf8<'a, B, I>(builder: &mut B, iter: I)
342where
343 B: Extend<Option<&'a str>>,
344 I: Iterator<Item = Option<&'a [u8]>>,
345{
346 builder.extend(iter.map(|value| value.and_then(|bytes| std::str::from_utf8(bytes).ok())));
347}
348
349pub(crate) fn cast_binary_to_string<O: OffsetSizeTrait>(
350 array: &dyn Array,

Callers 2

cast_binary_to_stringFunction · 0.85

Calls 2

and_thenMethod · 0.80
extendMethod · 0.45

Tested by

no test coverage detected