lance_arrow

Function try_new_generic_list_array

Source
pub fn try_new_generic_list_array<T: Array, Offset: ArrowNumericType>(
    values: T,
    offsets: &PrimitiveArray<Offset>,
) -> Result<GenericListArray<Offset::Native>, ArrowError>
where Offset::Native: OffsetSizeTrait,
Expand description

Create an GenericListArray from values and offsets.

use arrow_array::{Int32Array, Int64Array, ListArray};
use arrow_array::types::Int64Type;
use lance_arrow::try_new_generic_list_array;

let offsets = Int32Array::from_iter([0, 2, 7, 10]);
let int_values = Int64Array::from_iter(0..10);
let list_arr = try_new_generic_list_array(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)]),
]))