Skip to main content

ListVector

Struct ListVector 

Source
pub struct ListVector;
Expand description

Operations on LIST vectors.

A LIST vector stores a duckdb_list_entry { offset: u64, length: u64 } per row in the parent vector, and all element values in a flat child vector.

§Write workflow

  1. reserve — ensure child vector has capacity.
  2. Write element values into the child via get_child + VectorWriter.
  3. set_size — tell DuckDB how many elements were written.
  4. set_entry — write the offset/length for each parent row.

Implementations§

Source§

impl ListVector

Source

pub unsafe fn get_child(vector: duckdb_vector) -> duckdb_vector

Returns the child vector containing all list elements (flat, across all rows).

§Safety
  • vector must be a valid DuckDB LIST vector.
  • The returned handle is borrowed from vector.
Source

pub unsafe fn get_size(vector: duckdb_vector) -> usize

Returns the total number of elements currently in the child vector.

§Safety

vector must be a valid DuckDB LIST vector.

Source

pub unsafe fn set_size(vector: duckdb_vector, size: usize)

Sets the number of elements in the child vector.

Call after writing all element values. DuckDB uses this to know how many child elements are valid.

§Safety
  • vector must be a valid DuckDB LIST vector.
  • size must equal the number of elements written into the child vector.
Source

pub unsafe fn reserve(vector: duckdb_vector, capacity: usize)

Reserves capacity in the child vector for at least capacity elements.

Call before writing elements to ensure the child vector has enough space.

§Safety

vector must be a valid DuckDB LIST vector.

Source

pub unsafe fn set_entry( vector: duckdb_vector, row_idx: usize, offset: u64, length: u64, )

Writes the offset/length metadata entry for a parent row.

This tells DuckDB where in the flat child vector this row’s elements start and how many elements it has.

§Safety
  • vector must be a valid DuckDB LIST vector.
  • row_idx must be a valid row index in the parent vector.
  • offset + length must not exceed the size of the child vector.
Source

pub unsafe fn get_entry( vector: duckdb_vector, row_idx: usize, ) -> duckdb_list_entry

Returns the duckdb_list_entry for a given row (for reading).

§Safety
  • vector must be a valid DuckDB LIST vector.
  • row_idx must be a valid row index.
Source

pub unsafe fn child_writer(vector: duckdb_vector) -> VectorWriter

Creates a VectorWriter for the child vector (elements).

§Safety
  • vector must be a valid DuckDB LIST vector.
  • The child must have been reserved with at least capacity elements.
Source

pub unsafe fn child_reader( vector: duckdb_vector, element_count: usize, ) -> VectorReader

Creates a VectorReader for the child vector (reading list elements).

§Safety
  • vector must be a valid DuckDB LIST vector.
  • element_count must equal the total number of elements in the child.

Auto Trait Implementations§

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.