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

Function concat_structs

arrow-select/src/concat.rs:304–343  ·  view source on GitHub ↗
(arrays: &[&dyn Array], fields: &Fields)

Source from the content-addressed store, hash-verified

302}
303
304fn concat_structs(arrays: &[&dyn Array], fields: &Fields) -> Result<ArrayRef, ArrowError> {
305 let mut len = 0;
306 let mut has_nulls = false;
307 let structs = arrays
308 .iter()
309 .map(|a| {
310 len += a.len();
311 has_nulls |= a.null_count() > 0;
312 a.as_struct()
313 })
314 .collect::<Vec<_>>();
315
316 let nulls = has_nulls.then(|| {
317 let mut b = BooleanBufferBuilder::new(len);
318 for s in &structs {
319 match s.nulls() {
320 Some(n) => b.append_buffer(n.inner()),
321 None => b.append_n(s.len(), true),
322 }
323 }
324 NullBuffer::new(b.finish())
325 });
326
327 let column_concat_result = (0..fields.len())
328 .map(|i| {
329 let extracted_cols = structs
330 .iter()
331 .map(|s| s.column(i).as_ref())
332 .collect::<Vec<_>>();
333 concat(&extracted_cols)
334 })
335 .collect::<Result<Vec<_>, ArrowError>>()?;
336
337 Ok(Arc::new(StructArray::try_new_with_length(
338 fields.clone(),
339 column_concat_result,
340 nulls,
341 len,
342 )?))
343}
344
345/// Concatenate multiple RunArray instances into a single RunArray.
346///

Callers

nothing calls this directly

Calls 13

concatFunction · 0.85
as_structMethod · 0.80
iterMethod · 0.45
lenMethod · 0.45
null_countMethod · 0.45
nullsMethod · 0.45
append_bufferMethod · 0.45
innerMethod · 0.45
append_nMethod · 0.45
finishMethod · 0.45
as_refMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected