lance_arrow

Trait FixedSizeListArrayExt

Source
pub trait FixedSizeListArrayExt {
    // Required methods
    fn try_new_from_values<T: Array + 'static>(
        values: T,
        list_size: i32,
    ) -> Result<FixedSizeListArray, ArrowError>;
    fn sample(&self, n: usize) -> Result<FixedSizeListArray, ArrowError>;
}

Required Methods§

Source

fn try_new_from_values<T: Array + 'static>( values: T, list_size: i32, ) -> Result<FixedSizeListArray, ArrowError>

Create an FixedSizeListArray from values and list size.

use arrow_array::{Int64Array, FixedSizeListArray};
use arrow_array::types::Int64Type;
use lance_arrow::FixedSizeListArrayExt;

let int_values = Int64Array::from_iter(0..10);
let fixed_size_list_arr = FixedSizeListArray::try_new_from_values(int_values, 2).unwrap();
assert_eq!(fixed_size_list_arr,
    FixedSizeListArray::from_iter_primitive::<Int64Type, _, _>(vec![
        Some(vec![Some(0), Some(1)]),
        Some(vec![Some(2), Some(3)]),
        Some(vec![Some(4), Some(5)]),
        Some(vec![Some(6), Some(7)]),
        Some(vec![Some(8), Some(9)])
], 2))
Source

fn sample(&self, n: usize) -> Result<FixedSizeListArray, ArrowError>

Sample n rows from the FixedSizeListArray

use arrow_array::{Int64Array, FixedSizeListArray, Array};
use lance_arrow::FixedSizeListArrayExt;

let int_values = Int64Array::from_iter(0..256);
let fixed_size_list_arr = FixedSizeListArray::try_new_from_values(int_values, 16).unwrap();
let sampled = fixed_size_list_arr.sample(10).unwrap();
assert_eq!(sampled.len(), 10);
assert_eq!(sampled.value_length(), 16);
assert_eq!(sampled.values().len(), 160);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FixedSizeListArrayExt for FixedSizeListArray

Source§

fn try_new_from_values<T: Array + 'static>( values: T, list_size: i32, ) -> Result<Self, ArrowError>

Source§

fn sample(&self, n: usize) -> Result<FixedSizeListArray, ArrowError>

Implementors§