Skip to main content

DataChunkHandle

Struct DataChunkHandle 

Source
pub struct DataChunkHandle { /* private fields */ }
Expand description

An owned-or-borrowed DuckDB data chunk. A DuckDB data chunk: a batch of rows laid out column-wise, one VectorRef/ VectorMut per column.

Either owned by this handle (allocated via DataChunkHandle::new and destroyed on drop) or borrowed from a DuckDB callback frame (via a crate- internal constructor), in which case DuckDB owns the chunk itself and it must not be destroyed out from under it.

This is a separate type from the crate’s internal, read-only raw::data_chunk::DataChunk — that type’s Drop unconditionally destroys the chunk and its next_row destroys-and-nulls on exhaustion, both of which would double-free a chunk DuckDB owns.

Implementations§

Source§

impl DataChunkHandle

Source

pub fn new(types: &[LogicalType]) -> Result<Self>

Allocates a new data chunk with the given column types.

§Errors

Returns an error if DuckDB fails to allocate the chunk.

Source

pub fn vector(&self, idx: usize) -> Result<VectorRef<'_>>

Returns a read-only view of column idx.

§Errors

Returns an error if idx is out of range.

Source

pub fn vector_mut(&mut self, idx: usize) -> Result<VectorMut<'_>>

Returns an exclusive, writable view of column idx.

§Errors

Returns an error if idx is out of range.

Source

pub fn vectors_mut(&mut self) -> Result<Vec<VectorMut<'_>>>

Returns a writable view of every column, in column order.

The views are disjoint by construction (distinct column indices), so they may be held simultaneously despite each being individually exclusive.

§Errors

Returns an error if a column vector cannot be obtained.

Source

pub fn len(&self) -> usize

The number of rows currently in this chunk.

Source

pub fn is_empty(&self) -> bool

Returns true if this chunk has no rows.

Source

pub fn num_columns(&self) -> usize

The number of columns in this chunk.

Source

pub fn set_len(&mut self, n: usize) -> Result<()>

Sets the number of valid rows in this chunk.

§Errors

Returns an error if n exceeds DataChunkHandle::capacity.

Source

pub fn capacity(&self) -> usize

The maximum number of rows this chunk can hold — DuckDB’s build-time vector size, not a fixed constant. Never hardcode a row-count limit; always read it from here.

Trait Implementations§

Source§

impl Drop for DataChunkHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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.