Skip to main content

ListVector

Struct ListVector 

Source
pub struct ListVector<'a> { /* private fields */ }
Expand description

A list vector borrowed from a DataChunkHandle.

Stores list entry offsets and lengths; elements live in a separate child vector.

Regression guard for #673 — a ListVector must not outlive its parent chunk:

ⓘ
use duckdb::core::{DataChunkHandle, LogicalTypeHandle, LogicalTypeId};

let vec;
{
    let list_type = LogicalTypeHandle::list(&LogicalTypeId::Integer.into());
    let chunk = DataChunkHandle::new(&[list_type]);
    chunk.set_len(1);
    let v = chunk.list_vector(0);
    vec = v;
}
// chunk goes out of scope here; borrow checking rejects the outer use.
let _ = vec.get_entry(0);

Implementations§

Source§

impl<'a> ListVector<'a>

Source

pub fn len(&self) -> usize

Returns the number of child elements stored by the list vector.

This is the upper bound for the end of non-empty list entries, not the number of parent list rows.

Source

pub fn is_empty(&self) -> bool

Returns true if the list vector is empty.

Source

pub fn child(&self, capacity: usize) -> FlatVector<'a>

Returns the child vector, reserving space for capacity child values.

§Panics

Panics if DuckDB rejects the reserve.

Source

pub fn struct_child(&self, capacity: usize) -> StructVector<'a>

Take the child as StructVector, reserving space for capacity child values.

§Panics

Panics if DuckDB rejects the reserve.

Source

pub fn array_child(&self) -> ArrayVector<'a>

Take the child as ArrayVector.

Source

pub fn list_child(&self) -> ListVector<'a>

Take the child as ListVector.

Source

pub fn row_is_null(&self, row: u64) -> bool

Returns true if the row at the given index is null.

§Panics

Panics if row is outside the vector capacity.

Source

pub fn try_row_is_null(&self, row: u64) -> Result<bool>

Returns whether the row is null, or an error if it is out of range.

Source

pub unsafe fn set_child<T: Copy>(&self, data: &[T])

Set primitive data to the child node.

Reserves child storage and commits the list length to data.len().

§Panics

Panics if DuckDB rejects the reserve or size update.

§Safety

The caller must ensure T matches the child vector’s physical storage and no other references to the same storage exist during the copy.

Source

pub fn set_entry(&mut self, idx: usize, offset: usize, length: usize)

Set offset and length to the entry.

§Panics

Panics if idx is outside the vector capacity.

Source

pub fn get_entry(&self, idx: usize) -> (usize, usize)

Get offset and length for the entry at index.

§Panics

Panics if the entry is out of range or its offset or length cannot fit in usize on the current target.

Source

pub fn try_get_entry(&self, idx: usize) -> Result<(usize, usize)>

Returns the entry offset and length, or an error if the entry is out of range or cannot be represented on the current target.

Source

pub fn set_null(&mut self, row: usize)

Set row as null

Source

pub fn try_reserve(&self, capacity: usize) -> Result<()>

Reserve space for capacity child values.

This is public so callers can handle reservation errors without the panic-based convenience methods. Requests beyond DuckDB’s maximum vector size (2^37 elements) are rejected here as Err, because DuckDB reports them with a C++ exception the C API does not catch. Allocation failure inside DuckDB escapes the same way and aborts the process; it cannot be returned as an error through the current C API.

Source

pub fn set_len(&self, new_len: usize)

Reserve child storage and set the length of the list vector.

Panics if DuckDB rejects the reserve or size update. Use Self::try_set_len to handle that error explicitly.

Source

pub fn try_set_len(&self, new_len: usize) -> Result<()>

Reserve child storage and set the length of the list vector.

Auto Trait Implementations§

§

impl<'a> !Freeze for ListVector<'a>

§

impl<'a> !RefUnwindSafe for ListVector<'a>

§

impl<'a> !Send for ListVector<'a>

§

impl<'a> !Sync for ListVector<'a>

§

impl<'a> Unpin for ListVector<'a>

§

impl<'a> UnsafeUnpin for ListVector<'a>

§

impl<'a> UnwindSafe for ListVector<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.