pub struct List<T>(/* private fields */);
Expand description
Wrapper denoting an Arrow ListArray
column with elements of T
.
Notes:
- List-level nullability: wrap the column in
Option<List<T>>
. - Item-level nullability: use
List<Option<T>>
when elements can be null.
Implementations§
Source§impl<T> List<T>
impl<T> List<T>
Sourcepub fn new(values: Vec<T>) -> Self
pub fn new(values: Vec<T>) -> Self
Construct a new list from a vector of values.
Examples found in repository?
examples/02_lists.rs (line 22)
12fn main() {
13 // DataTypes from compile-time mapping
14 println!(
15 "tags={:?}, scores={:?}",
16 <Row as ColAt<0>>::data_type(),
17 <Row as ColAt<1>>::data_type()
18 );
19
20 // Build a List<Utf8> column manually via ArrowBinding
21 let mut lb = <List<String> as ArrowBinding>::new_builder(2);
22 <List<String> as ArrowBinding>::append_value(&mut lb, &List::new(vec!["a".into(), "b".into()]));
23 <List<String> as ArrowBinding>::append_value(&mut lb, &List::new(vec!["x".into()]));
24 let la = <List<String> as ArrowBinding>::finish(lb);
25 println!(
26 "List<Utf8> len={}, first_list_len={}",
27 la.len(),
28 arrow_array::cast::as_list_array(&la).value_length(0)
29 );
30
31 // Build a nullable-list of nullable i32 items
32 let mut nullable_builder = <List<Option<i32>> as ArrowBinding>::new_builder(2);
33 <List<Option<i32>> as ArrowBinding>::append_value(
34 &mut nullable_builder,
35 &List::new(vec![Some(1), None]),
36 );
37 <List<Option<i32>> as ArrowBinding>::append_null(&mut nullable_builder);
38 let nullable_arr = <List<Option<i32>> as ArrowBinding>::finish(nullable_builder);
39 println!(
40 "List<Nullable<i32>> len={}, second_is_null={}",
41 nullable_arr.len(),
42 nullable_arr.is_null(1)
43 );
44}
Sourcepub fn into_inner(self) -> Vec<T>
pub fn into_inner(self) -> Vec<T>
Consume and return the underlying vector of values.
Trait Implementations§
Source§impl<T> ArrowBinding for List<Option<T>>
Provide ArrowBinding
for List<Option<T>>
so users can express
item-nullability via Option
in the type parameter.
impl<T> ArrowBinding for List<Option<T>>
Provide ArrowBinding
for List<Option<T>>
so users can express
item-nullability via Option
in the type parameter.
Source§type Builder = GenericListBuilder<i32, <T as ArrowBinding>::Builder>
type Builder = GenericListBuilder<i32, <T as ArrowBinding>::Builder>
Concrete Arrow builder type used for this Rust type.
Source§type Array = GenericListArray<i32>
type Array = GenericListArray<i32>
Concrete Arrow array type produced by
finish
.Source§fn new_builder(_capacity: usize) -> Self::Builder
fn new_builder(_capacity: usize) -> Self::Builder
Create a new builder with an optional capacity hint.
Source§fn append_value(b: &mut Self::Builder, v: &Self)
fn append_value(b: &mut Self::Builder, v: &Self)
Append a non-null value to the builder.
Source§fn append_null(b: &mut Self::Builder)
fn append_null(b: &mut Self::Builder)
Append a null to the builder.
Source§impl<T> ArrowBinding for List<T>
impl<T> ArrowBinding for List<T>
Source§type Builder = GenericListBuilder<i32, <T as ArrowBinding>::Builder>
type Builder = GenericListBuilder<i32, <T as ArrowBinding>::Builder>
Concrete Arrow builder type used for this Rust type.
Source§type Array = GenericListArray<i32>
type Array = GenericListArray<i32>
Concrete Arrow array type produced by
finish
.Source§fn new_builder(_capacity: usize) -> Self::Builder
fn new_builder(_capacity: usize) -> Self::Builder
Create a new builder with an optional capacity hint.
Source§fn append_value(b: &mut Self::Builder, v: &Self)
fn append_value(b: &mut Self::Builder, v: &Self)
Append a non-null value to the builder.
Source§fn append_null(b: &mut Self::Builder)
fn append_null(b: &mut Self::Builder)
Append a null to the builder.
Source§impl<T> FromIterator<T> for List<T>
impl<T> FromIterator<T> for List<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Collect an iterator into a List<T>
.
Auto Trait Implementations§
impl<T> Freeze for List<T>
impl<T> RefUnwindSafe for List<T>where
T: RefUnwindSafe,
impl<T> Send for List<T>where
T: Send,
impl<T> Sync for List<T>where
T: Sync,
impl<T> Unpin for List<T>where
T: Unpin,
impl<T> UnwindSafe for List<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more