Skip to main content

DataChunk

Struct DataChunk 

Source
pub struct DataChunk {
    pub fields: Vec<Arc<dyn Array>>,
    pub field_types: Vec<PhysicalTypeID>,
    pub size: usize,
    pub field_names: Vec<String>,
    pub sel_vector: Option<SelectionVector>,
}
Expand description

A contiguous batch of columnar data — the fundamental unit of data exchange between physical operators.

Each DataChunk holds zero or more Arrow ArrayRef columns of equal length. Operators consume input chunks and produce output chunks, forming a pipeline.

§Selection vectors

When sel_vector is set, only the rows indicated by the selection are “active”. Call active_rows() or iter_rows() to respect the selection; do not iterate 0..size directly.

§Example

let chunk = DataChunk::new(fields, field_types).with_names(names);
for row in chunk.iter_rows() {
    let val = chunk.get_value(0, row); // column 0, current row
}

Fields§

§fields: Vec<Arc<dyn Array>>§field_types: Vec<PhysicalTypeID>§size: usize§field_names: Vec<String>§sel_vector: Option<SelectionVector>

Optional selection vector for zero-copy filtering. When set, only the rows at sel_vector.indices[0..sel_vector.size] are considered active. Operators should iterate using the sel_vector rather than size for correct results.

Implementations§

Source§

impl DataChunk

Source

pub fn new( fields: Vec<Arc<dyn Array>>, field_types: Vec<PhysicalTypeID>, ) -> DataChunk

Create a new DataChunk from Arrow arrays and their physical types.

The chunk size is set to the length of the first field. All fields must have the same length.

Source

pub fn from_legacy(legacy_fields: Vec<LegacyValueVector>) -> DataChunk

Construct a DataChunk from legacy vectors (for backward-compatibility in benchmarks)

Source

pub fn with_names(self, names: Vec<String>) -> DataChunk

Attach column names to this chunk (builder pattern).

Source

pub fn with_sel(self, sel: SelectionVector) -> DataChunk

Attach a selection vector to this chunk.

Source

pub fn field(&self, idx: usize) -> &Arc<dyn Array>

Return a reference to the Arrow array at the given column index.

Source

pub fn num_fields(&self) -> usize

Return the number of columns in this chunk.

Source

pub fn resize(&mut self, new_size: usize)

Resize the chunk (and all its fields) to the given number of rows.

Source

pub fn active_rows(&self) -> usize

Return the number of active rows, taking the selection vector into account.

Source

pub fn iter_rows(&self) -> RowIter<'_>

Iterate over active row indices. When a selection vector is present, yields the selected indices. Otherwise, yields 0..size.

Source

pub fn materialize(&mut self)

Materialize the selection vector into physical data. After calling this, sel_vector is None and only the selected rows remain in the data buffers. This is a no-op if sel_vector is already None.

Source

pub fn is_null(&self, field_idx: usize, row_idx: usize) -> bool

Return true if the value at (field_idx, row_idx) is null.

Source

pub fn get_i64(&self, field_idx: usize, row_idx: usize) -> Option<i64>

Read an i64 value from column field_idx at row_idx, or None if null.

Returns None if the column is not physically an Int64 array (e.g. a UInt64 column) — callers reading UInt64 columns must use get_u64.

Source

pub fn get_u64(&self, field_idx: usize, row_idx: usize) -> Option<u64>

Read a u64 value from column field_idx at row_idx, or None if null.

Source

pub fn get_i32(&self, field_idx: usize, row_idx: usize) -> Option<i32>

Read an i32 value from column field_idx at row_idx, or None if null.

Source

pub fn get_f64(&self, field_idx: usize, row_idx: usize) -> Option<f64>

Read an f64 value from column field_idx at row_idx, or None if null.

Source

pub fn get_f32(&self, field_idx: usize, row_idx: usize) -> Option<f32>

Read an f32 value from column field_idx at row_idx, or None if null.

Source

pub fn get_bool(&self, field_idx: usize, row_idx: usize) -> Option<bool>

Read a bool value from column field_idx at row_idx, or None if null.

Source

pub fn get_string(&self, field_idx: usize, row_idx: usize) -> Option<&str>

Read a string slice from column field_idx at row_idx, or None if null.

Source

pub fn get_value(&self, field_idx: usize, row_idx: usize) -> Option<Value>

Read a value from column field_idx at row_idx, returning a boxed Value.

Returns None if the cell is null. The physical type of the column determines which Value variant is produced.

Trait Implementations§

Source§

impl Clone for DataChunk

Source§

fn clone(&self) -> DataChunk

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataChunk

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. 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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.