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)
| 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 | |
| 467 | impl<OffsetSize: OffsetSizeTrait> From<ArrayData> for GenericListArray<OffsetSize> { |