MCPcopy Create free account
hub / github.com/apache/datafusion / initcap_utf8view

Function initcap_utf8view

datafusion/functions/src/unicode/initcap.rs:245–273  ·  view source on GitHub ↗
(args: &[ArrayRef])

Source from the content-addressed store, hash-verified

243}
244
245fn initcap_utf8view(args: &[ArrayRef]) -> Result<ArrayRef> {
246 let string_view_array = as_string_view_array(&args[0])?;
247 let len = string_view_array.len();
248 let mut builder = StringViewArrayBuilder::with_capacity(len);
249 let mut container = String::new();
250
251 let nulls = string_view_array.nulls().cloned();
252 if let Some(ref n) = nulls {
253 for i in 0..len {
254 if n.is_null(i) {
255 builder.append_placeholder();
256 } else {
257 // SAFETY: not null per check above.
258 let s = unsafe { string_view_array.value_unchecked(i) };
259 initcap_string(s, &mut container);
260 builder.append_value(&container);
261 }
262 }
263 } else {
264 for i in 0..len {
265 // SAFETY: no null buffer means every index is valid.
266 let s = unsafe { string_view_array.value_unchecked(i) };
267 initcap_string(s, &mut container);
268 builder.append_value(&container);
269 }
270 }
271
272 Ok(Arc::new(builder.finish(nulls)?) as ArrayRef)
273}
274
275fn initcap_string(input: &str, container: &mut String) {
276 container.clear();

Callers

nothing calls this directly

Calls 10

as_string_view_arrayFunction · 0.85
newFunction · 0.85
initcap_stringFunction · 0.85
append_placeholderMethod · 0.80
lenMethod · 0.45
clonedMethod · 0.45
nullsMethod · 0.45
is_nullMethod · 0.45
append_valueMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…