List

Struct List 

Source
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>

Source

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}
Source

pub fn values(&self) -> &Vec<T>

Borrow the underlying values.

Source

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.

Source§

type Builder = GenericListBuilder<i32, <T as ArrowBinding>::Builder>

Concrete Arrow builder type used for this Rust type.
Source§

type Array = GenericListArray<i32>

Concrete Arrow array type produced by finish.
Source§

fn data_type() -> DataType

The Arrow DataType corresponding to this Rust type.
Source§

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)

Append a non-null value to the builder.
Source§

fn append_null(b: &mut Self::Builder)

Append a null to the builder.
Source§

fn finish(b: Self::Builder) -> Self::Array

Finish the builder and produce a typed Arrow array.
Source§

impl<T> ArrowBinding for List<T>

Source§

type Builder = GenericListBuilder<i32, <T as ArrowBinding>::Builder>

Concrete Arrow builder type used for this Rust type.
Source§

type Array = GenericListArray<i32>

Concrete Arrow array type produced by finish.
Source§

fn data_type() -> DataType

The Arrow DataType corresponding to this Rust type.
Source§

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)

Append a non-null value to the builder.
Source§

fn append_null(b: &mut Self::Builder)

Append a null to the builder.
Source§

fn finish(b: Self::Builder) -> Self::Array

Finish the builder and produce a typed Arrow array.
Source§

impl<T> From<Vec<T>> for List<T>

Source§

fn from(values: Vec<T>) -> Self

Convert a vector into a List<T>.

Source§

impl<T> FromIterator<T> for List<T>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,