Skip to main content

DataChunk

Struct DataChunk 

Source
pub struct DataChunk {
    pub rows: Vec<Vec<Value>>,
    pub typed_columns: Option<Vec<TypedColumn>>,
    pub selection: Option<Vec<usize>>,
    pub multiplicity: u64,
    pub schema: Arc<Schema>,
    pub layout: Arc<SlotLayout>,
    pub memory_reservation: Option<MemoryReservation>,
    pub columnar_stats: Option<Arc<ColumnarStats>>,
    /* private fields */
}
Expand description

A chunk of rows processed in streaming execution

Fields§

§rows: Vec<Vec<Value>>

Row data with Value types

§typed_columns: Option<Vec<TypedColumn>>

Optional typed column layout.

§selection: Option<Vec<usize>>

Selection vector.

§multiplicity: u64

Symbolic row multiplicity (Ladybug ResultSet::multiplicity analogue).

Transparent operators may bump this instead of physically duplicating rows. 1 means every visible row appears once. The expanded (flat) row count is visible_count * multiplicity.

§schema: Arc<Schema>

Schema information (column names and types)

§layout: Arc<SlotLayout>

Slot layout for slot-based value access.

§memory_reservation: Option<MemoryReservation>

Memory reservation for this chunk’s data.

§columnar_stats: Option<Arc<ColumnarStats>>

Query-level columnar fast-path counters (observability).

Implementations§

Source§

impl DataChunk

Source

pub fn new(rows: Vec<Vec<Value>>, schema: Arc<Schema>) -> Self

Source

pub fn with_memory_reservation(self, reservation: MemoryReservation) -> Self

Source

pub fn with_columnar_stats(self, stats: Arc<ColumnarStats>) -> Self

Source

pub fn take_memory_reservation(&mut self) -> Option<MemoryReservation>

Source

pub fn new_with_layout(rows: Vec<Vec<Value>>, layout: Arc<SlotLayout>) -> Self

Source

pub fn try_new_with_layout( rows: Vec<Vec<Value>>, layout: Arc<SlotLayout>, ) -> Result<Self, QueryError>

Source

pub fn from_rows(rows: Vec<Vec<Value>>) -> Self

Source

pub fn from_rows_with_col_names( rows: Vec<Vec<Value>>, col_names: Option<Vec<String>>, ) -> Self

Source

pub fn project_columns( columns: Vec<Vec<Value>>, layout: Arc<SlotLayout>, ) -> Self

Columnar projection assembly: build an output chunk from evaluated output columns without a row intermediate.

This is the designated constructor for the streaming Project fast path (passthrough / constant columns gathered or broadcast upstream). Row storage stays authoritative downstream; the transpose into rows is the single compatibility edge until the chunk itself is columnar. The typed rebuild here is unconditional by design: projected outputs are bounded by the input chunk size, unlike join outputs which honor the shared columnar gate.

Source

pub fn from_batch(batch: &MaterializedBatch, layout: Arc<SlotLayout>) -> Self

Build a row chunk from a columnar batch slice.

Coexistence API: the batch stays the operator state authority while the chunk carries the row view downstream. A transpose is still performed internally until the chunk itself becomes columnar.

Source

pub fn slice_from_batch( batch: &MaterializedBatch, offset: usize, len: usize, layout: Arc<SlotLayout>, ) -> Self

Build a row chunk from a row range of a columnar batch.

Source

pub fn to_batch(&self) -> MaterializedBatch

Convert this chunk back into a columnar batch (single transpose edge).

Source

pub fn estimated_bytes(&self) -> usize

Memory estimate for the visible expanded rows (visible_count * multiplicity), used for pool/tracker accounting.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn num_columns(&self) -> usize

Source

pub fn col_names(&self) -> Vec<String>

Source

pub fn col_name(&self, index: usize) -> Option<String>

Source

pub fn col_name_index(&self) -> HashMap<String, usize>

Source

pub fn get_layout(&self) -> Arc<SlotLayout> ⓘ

Source

pub fn get_by_slot(&self, row_idx: usize, slot: SlotId) -> Option<Value>

Source

pub fn get_column(&mut self, slot: SlotId) -> Option<Vec<Value>>

Column view over Values, derived on demand from the typed layout.

New expression code should prefer typed_column; this stays for join keys and fallback paths that require owned Value columns. The column is rebuilt from the typed layout (or cloned from rows) on every call and never cached: row storage is authoritative.

Source

pub fn column_ref(&self, slot: SlotId) -> Option<Vec<&Value>>

Source

pub fn get_typed_by_slot(&self, row_idx: usize, slot: SlotId) -> Option<Value>

Source

pub fn row_at(&self, i: usize) -> &[Value]

Source

pub fn take_rows_for_reuse(&mut self) -> Vec<Vec<Value>>

Take the physical rows out for buffer reuse, resetting selection, multiplicity, and derived typed state.

Unlike Clone (documented deep copy), this moves the allocation out so the caller can return the drained buffers to super::pool::RowBufferPool via release_rows instead of dropping them. Prefer move-first construction plus this pool over cloning.

Source

pub fn build_typed_columns(&mut self, use_columnar: bool) -> usize

Build the typed column layout for this chunk.

use_columnar carries the adaptive [ColumnarPolicy] decision from the producing operator: when the learned hit rate falls below the threshold the chunk stays row-based. The typed layout is otherwise always attempted (there is no global off switch). Returns the number of extra typed bytes allocated.

Source

pub fn typed_column(&self, slot: SlotId) -> Option<&TypedColumn>

Source

pub fn typed_len(&self) -> Option<usize>

Row count served by the typed layout when the row view was skipped.

Rowless chunks (storage scans whose planner annotation proved the direct consumer never reads rows) carry data only in typed_columns; every typed arm implements len, and assembly keeps the arms in lockstep exactly like rows. Returns None when there is no typed layout, so row-based consumers keep their existing empty semantics.

Source

pub fn ensure_typed_columns(&mut self) -> usize

Rebuild the typed layout when construction deferred it.

Join outputs skip the eager build and set the deferred flag; the first typed consumer calls this to pay the build cost lazily. The columnar policy gate already ran at construction, so the rebuild is unconditional. Returns the extra typed bytes allocated.

Source§

impl DataChunk

Source

pub fn evaluate_expressions( &mut self, expressions: &[Expression], env: Option<&EvalEnv>, ) -> Result<Vec<Vec<Value>>, ExpressionError>

Source

pub fn try_evaluate_expressions_typed( &mut self, expressions: &[Expression], env: Option<&EvalEnv>, ) -> Result<Option<Vec<Vec<Value>>>, ExpressionError>

Batch-evaluate a list of output expressions, preferring the typed columnar path.

Returns Ok(None) as soon as any expression is not covered by the typed fast path (no typed_columns, a kind mismatch, or an operator outside the typed batch set), letting the caller fall back to the compiled-over-rows path with unchanged semantics. This is the entry point the Project/Filter hot path uses so a chunk that carries a typed layout is evaluated on raw scalars instead of per-row Values.

Source

pub fn evaluate_expression( &mut self, expression: &Expression, env: Option<&EvalEnv>, ) -> Result<Vec<Value>, ExpressionError>

Source

pub fn evaluate_expression_visible( &mut self, expression: &Expression, env: Option<&EvalEnv>, ) -> Result<Vec<Value>, ExpressionError>

Source§

impl DataChunk

Source

pub fn multiplicity(&self) -> u64

Symbolic multiplicity: how many times each visible row occurs.

Source

pub fn set_multiplicity(&mut self, multiplicity: u64)

Source

pub fn with_multiplicity(self, multiplicity: u64) -> Self

Source

pub fn logical_len(&self) -> u64

Expanded (flat) visible row count: visible_count * multiplicity. Saturates instead of overflowing so metrics paths stay total.

Source

pub fn visible_rows(&self) -> impl Iterator<Item = &Vec<Value>>

Borrow visible rows in upstream order (respects selection).

Source

pub fn expand_visible_rows(&mut self) -> Vec<Vec<Value>>

Move visible rows out, repeating each row multiplicity times.

This is the single terminal move: rows are moved out with mem::take with no per-Value clone on the move itself (multiplicity == 1 returns the moved rows directly; larger factors repeat them). After the call the chunk is empty with selection=None and derived column caches cleared.

Opaque order-preserving operators assume multiplicity == 1; a future multiplicity producer must expand at those boundaries with this call first (see the module-level multiplicity contract).

Source

pub fn with_selection(self, indices: Vec<usize>) -> Self

Source

pub fn selection(&self) -> Option<&[usize]>

Source

pub fn visible_count(&self) -> usize

Source

pub fn visible_indices(&self) -> Vec<usize>

Source

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

Source

pub fn take_selection(&mut self) -> Option<Vec<usize>>

Source

pub fn expand_multiplicity_in_place(&mut self) -> bool

Expand a symbolic multiplicity > 1 into physical rows in place.

Opaque operators (sort/window/join/aggregate) cannot carry the factor symbolically, so they must call this (directly or via DataChunk::normalize_for_opaque) before consuming rows. Returns true when an expansion happened. Visible selection is preserved: only visible rows are replicated, hidden rows are dropped. Derived column caches are cleared, matching expand_visible_rows.

Source

pub fn normalize_for_opaque(&mut self, op: &'static str) -> bool

Unified opaque-operator boundary: expand multiplicity, then materialize any attached selection. Returns true when either step changed the chunk. op must be one of SELECTION_BOUNDARY_OPS.

This is the single entry point opaque operators should use instead of calling DataChunk::materialize_selection_by directly.

Source

pub fn materialize_selection_by(&mut self, op: &'static str) -> bool

Contract: materialize any attached selection (opaque-operator boundary). Returns true when a selection was actually materialized.

Prefer DataChunk::normalize_for_opaque: this method alone does not expand multiplicity, so opaque operators calling it directly must guarantee multiplicity == 1 (debug-asserted by callers via the normalize path).

This is the single boundary-materialization entry point; op must be one of SELECTION_BOUNDARY_OPS so per-operator counters stay exact (ad-hoc names fall back to the unattributed counter).

Source

pub fn take_indices(&mut self, indices: &[usize]) -> Self

Source

pub fn slice(&mut self, start: usize, end: usize) -> Self

Trait Implementations§

Source§

impl Clone for DataChunk

Source§

fn clone(&self) -> Self

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

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> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
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> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more