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

Method from_nested_iter

arrow-array/src/array/list_array.rs:444–464  ·  view source on GitHub ↗

Creates a [`GenericListArray`] from a nested iterator of values. This method works for any values type that has a corresponding builder that implements the `Extend` trait. That includes all numeric types, booleans, binary and string types and also dictionary encoded binary and strings. # Example ``` # use arrow_array::ListArray; # use arrow_array::types::Int32Type; # use arrow_array::builder::Str

(iter: I)

Source from the content-addressed store, hash-verified

442 /// println!("{:?}", list_array);
443 /// ```
444 pub fn from_nested_iter<B, T, P, I>(iter: I) -> Self
445 where
446 B: ArrayBuilder + Default + Extend<Option<T>>,
447 P: IntoIterator<Item = Option<T>>,
448 I: IntoIterator<Item = Option<P>>,
449 {
450 let iter = iter.into_iter();
451 let size_hint = iter.size_hint().0;
452 let mut builder = GenericListBuilder::with_capacity(B::default(), size_hint);
453
454 for i in iter {
455 match i {
456 Some(p) => {
457 builder.values().extend(p);
458 builder.append(true);
459 }
460 None => builder.append(false),
461 }
462 }
463 builder.finish()
464 }
465}
466
467impl<OffsetSize: OffsetSizeTrait> From<ArrayData> for GenericListArray<OffsetSize> {

Callers

nothing calls this directly

Calls 7

defaultFunction · 0.85
into_iterMethod · 0.45
size_hintMethod · 0.45
extendMethod · 0.45
valuesMethod · 0.45
appendMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected