Trait lance::arrow::ListArrayExt

source ·
pub trait ListArrayExt {
    // Required method
    fn try_new<T: Array>(values: T, offsets: &Int32Array) -> Result<ListArray>;
}

Required Methods§

source

fn try_new<T: Array>(values: T, offsets: &Int32Array) -> Result<ListArray>

Create an ListArray from values and offsets.

use arrow_array::{Int32Array, Int64Array, ListArray};
use arrow_array::types::Int64Type;
use lance::arrow::ListArrayExt;

let offsets = Int32Array::from_iter([0, 2, 7, 10]);
let int_values = Int64Array::from_iter(0..10);
let list_arr = ListArray::try_new(int_values, &offsets).unwrap();
assert_eq!(list_arr,
    ListArray::from_iter_primitive::<Int64Type, _, _>(vec![
        Some(vec![Some(0), Some(1)]),
        Some(vec![Some(2), Some(3), Some(4), Some(5), Some(6)]),
        Some(vec![Some(7), Some(8), Some(9)]),
]))

Implementations on Foreign Types§

source§

impl ListArrayExt for ListArray

source§

fn try_new<T: Array>(values: T, offsets: &Int32Array) -> Result<Self>

Implementors§