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

Method build

arrow-array/src/builder/union_builder.rs:284–318  ·  view source on GitHub ↗

Builds this builder creating a new `UnionArray`.

(self)

Source from the content-addressed store, hash-verified

282
283 /// Builds this builder creating a new `UnionArray`.
284 pub fn build(self) -> Result<UnionArray, ArrowError> {
285 let mut children = Vec::with_capacity(self.fields.len());
286 let union_fields = self
287 .fields
288 .into_iter()
289 .map(
290 |(
291 name,
292 FieldData {
293 type_id,
294 data_type,
295 mut values_buffer,
296 slots,
297 mut null_buffer_builder,
298 },
299 )| {
300 let array_ref = make_array(unsafe {
301 ArrayDataBuilder::new(data_type.clone())
302 .add_buffer(values_buffer.finish())
303 .len(slots)
304 .nulls(null_buffer_builder.finish())
305 .build_unchecked()
306 });
307 children.push(array_ref);
308 (type_id, Arc::new(Field::new(name, data_type, false)))
309 },
310 )
311 .collect();
312 UnionArray::try_new(
313 union_fields,
314 self.type_id_builder.into(),
315 self.value_offset_builder.map(Into::into),
316 children,
317 )
318 }
319
320 /// Builds this builder creating a new `UnionArray` without consuming the builder.
321 ///

Callers 15

test_null_count_handlingFunction · 0.45
test_generic_listFunction · 0.45
test_generic_list_viewFunction · 0.45
test_union_sparse_arrayFunction · 0.45
test_union_dense_arrayFunction · 0.45
test_fixed_size_listFunction · 0.45
test_list_viewFunction · 0.45

Calls 11

try_newFunction · 0.85
collectMethod · 0.80
add_bufferMethod · 0.80
make_arrayFunction · 0.50
lenMethod · 0.45
into_iterMethod · 0.45
build_uncheckedMethod · 0.45
nullsMethod · 0.45
cloneMethod · 0.45
finishMethod · 0.45
pushMethod · 0.45

Tested by 15

test_null_count_handlingFunction · 0.36
test_generic_listFunction · 0.36
test_generic_list_viewFunction · 0.36
test_union_sparse_arrayFunction · 0.36
test_union_dense_arrayFunction · 0.36
test_fixed_size_listFunction · 0.36
test_list_viewFunction · 0.36