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

Function concat_elements_binary_view_array

arrow-string/src/concat_elements.rs:230–260  ·  view source on GitHub ↗

Concatenates two `BinaryViewArray`s element-wise. If either element is `Null`, the result element is also `Null`. # Errors - Returns an error if the input arrays have different lengths. - Returns an error if any concatenated value exceeds `u32::MAX` in length.

(
    left: &BinaryViewArray,
    right: &BinaryViewArray,
)

Source from the content-addressed store, hash-verified

228/// - Returns an error if the input arrays have different lengths.
229/// - Returns an error if any concatenated value exceeds `u32::MAX` in length.
230pub fn concat_elements_binary_view_array(
231 left: &BinaryViewArray,
232 right: &BinaryViewArray,
233) -> Result<BinaryViewArray, ArrowError> {
234 if left.len() != right.len() {
235 return Err(ArrowError::ComputeError(format!(
236 "Arrays must have the same length: {} != {}",
237 left.len(),
238 right.len()
239 )));
240 }
241 let mut result = BinaryViewBuilder::with_capacity(left.len());
242
243 // Avoid reallocations by writing to a reused buffer
244 let mut buffer = MutableBuffer::new(0);
245
246 // Pre-compute combined null bitmap, so the per-row NULL check is efficient
247 let nulls = NullBuffer::union(left.nulls(), right.nulls());
248
249 for i in 0..left.len() {
250 if nulls.as_ref().is_some_and(|n| n.is_null(i)) {
251 result.append_null();
252 } else {
253 buffer.clear();
254 buffer.extend_from_slice(left.value(i));
255 buffer.extend_from_slice(right.value(i));
256 result.try_append_value(&buffer)?;
257 }
258 }
259 Ok(result.finish())
260}
261
262/// Concatenates two `StringViewArray`s element-wise.
263/// If either element is `Null`, the result element is also `Null`.

Callers 5

concat_elements_dynFunction · 0.85
test_binary_view_concatFunction · 0.85

Calls 10

extend_from_sliceMethod · 0.80
lenMethod · 0.45
nullsMethod · 0.45
as_refMethod · 0.45
is_nullMethod · 0.45
append_nullMethod · 0.45
clearMethod · 0.45
valueMethod · 0.45
try_append_valueMethod · 0.45
finishMethod · 0.45

Tested by 4

test_binary_view_concatFunction · 0.68