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

Function reverse_impl

datafusion/functions/src/unicode/reverse.rs:122–155  ·  view source on GitHub ↗
(
    string_array: &StringArrType,
    mut array_builder: B,
)

Source from the content-addressed store, hash-verified

120}
121
122fn reverse_impl<'a, StringArrType, B>(
123 string_array: &StringArrType,
124 mut array_builder: B,
125) -> Result<ArrayRef>
126where
127 StringArrType: StringArrayType<'a>,
128 B: BulkNullStringArrayBuilder,
129{
130 let item_len = string_array.len();
131 // Null-preserving: reuse the input null buffer as the output null buffer.
132 let nulls = string_array.nulls().cloned();
133 let mut string_buf = String::new();
134 let mut byte_buf = Vec::<u8>::new();
135
136 if let Some(ref n) = nulls {
137 for i in 0..item_len {
138 if n.is_null(i) {
139 array_builder.append_placeholder();
140 } else {
141 // SAFETY: `n.is_null(i)` was false in the branch above.
142 let s = unsafe { string_array.value_unchecked(i) };
143 append_reversed(s, &mut array_builder, &mut byte_buf, &mut string_buf);
144 }
145 }
146 } else {
147 for i in 0..item_len {
148 // SAFETY: no null buffer means every index is valid.
149 let s = unsafe { string_array.value_unchecked(i) };
150 append_reversed(s, &mut array_builder, &mut byte_buf, &mut string_buf);
151 }
152 }
153
154 array_builder.finish(nulls)
155}
156
157#[inline]
158fn append_reversed<B: BulkNullStringArrayBuilder>(

Callers 1

reverseFunction · 0.85

Calls 8

newFunction · 0.85
append_reversedFunction · 0.85
append_placeholderMethod · 0.80
lenMethod · 0.45
clonedMethod · 0.45
nullsMethod · 0.45
is_nullMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…