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>
impl<'a> ListVector<'a>
Sourcepub fn len(&self) -> usize
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.
Sourcepub fn child(&self, capacity: usize) -> FlatVector<'a>
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.
Sourcepub fn struct_child(&self, capacity: usize) -> StructVector<'a>
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.
Sourcepub fn array_child(&self) -> ArrayVector<'a>
pub fn array_child(&self) -> ArrayVector<'a>
Take the child as ArrayVector.
Sourcepub fn list_child(&self) -> ListVector<'a>
pub fn list_child(&self) -> ListVector<'a>
Take the child as ListVector.
Sourcepub fn row_is_null(&self, row: u64) -> bool
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.
Sourcepub fn try_row_is_null(&self, row: u64) -> Result<bool>
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.
Sourcepub unsafe fn set_child<T: Copy>(&self, data: &[T])
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.
Sourcepub fn get_entry(&self, idx: usize) -> (usize, usize)
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.
Sourcepub fn try_get_entry(&self, idx: usize) -> Result<(usize, usize)>
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.
Sourcepub fn try_reserve(&self, capacity: usize) -> Result<()>
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.
Sourcepub fn set_len(&self, new_len: usize)
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.
Sourcepub fn try_set_len(&self, new_len: usize) -> Result<()>
pub fn try_set_len(&self, new_len: usize) -> Result<()>
Reserve child storage and set the length of the list vector.