pub struct DataChunk { /* private fields */ }Expand description
A batch of rows in column-major format.
Columns are ValueVectors — either flat byte buffers from storage or
owned TypedValue vecs from operators. A SelectionVector maps logical
row indices to physical positions, enabling zero-copy filtering.
Implementations§
Source§impl DataChunk
impl DataChunk
Sourcepub fn from_vectors(
columns: Vec<ValueVector>,
selection: SelectionVector,
) -> Self
pub fn from_vectors( columns: Vec<ValueVector>, selection: SelectionVector, ) -> Self
Create from ValueVector columns + SelectionVector (scan path).
Sourcepub fn new(columns: Vec<Vec<TypedValue>>) -> Self
pub fn new(columns: Vec<Vec<TypedValue>>) -> Self
Create a new DataChunk from owned TypedValue columns (backward compat).
Sourcepub fn new_with_row_count(
columns: Vec<Vec<TypedValue>>,
num_rows: usize,
) -> Self
pub fn new_with_row_count( columns: Vec<Vec<TypedValue>>, num_rows: usize, ) -> Self
Create a DataChunk with a specific row count (for zero-column chunks).
Sourcepub fn empty(num_columns: usize) -> Self
pub fn empty(num_columns: usize) -> Self
Create an empty DataChunk with the given number of columns.
Sourcepub fn with_capacity(num_columns: usize, row_capacity: usize) -> Self
pub fn with_capacity(num_columns: usize, row_capacity: usize) -> Self
Create an empty DataChunk with pre-allocated column capacity.
Sourcepub fn single_empty_row(num_columns: usize) -> Self
pub fn single_empty_row(num_columns: usize) -> Self
Create a DataChunk with a single row of Null values.
Sourcepub fn from_rows(rows: &[Vec<TypedValue>], num_columns: usize) -> Self
pub fn from_rows(rows: &[Vec<TypedValue>], num_columns: usize) -> Self
Create a DataChunk from rows (row-major → column-major).
pub fn num_columns(&self) -> usize
pub fn num_rows(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn get_value(&self, row_idx: usize, col_idx: usize) -> TypedValue
pub fn get_value(&self, row_idx: usize, col_idx: usize) -> TypedValue
Get a single value by (logical) row and column index.
Sourcepub fn get_row(&self, row_idx: usize) -> Vec<TypedValue>
pub fn get_row(&self, row_idx: usize) -> Vec<TypedValue>
Get a row as a vector across all columns.
Sourcepub fn append_row(&mut self, row: &[TypedValue])
pub fn append_row(&mut self, row: &[TypedValue])
Append a single row. Only works when columns are Owned.
Sourcepub fn append(&mut self, other: &DataChunk)
pub fn append(&mut self, other: &DataChunk)
Append all rows from another chunk. Materializes self into Owned columns if needed (e.g., when self has Flat columns from storage).
Sourcepub fn selection(&self) -> &SelectionVector
pub fn selection(&self) -> &SelectionVector
Access the selection vector.
Sourcepub fn column(&self, col_idx: usize) -> &ValueVector
pub fn column(&self, col_idx: usize) -> &ValueVector
Direct access to a column’s ValueVector.
Sourcepub fn compact_column(&self, col_idx: usize) -> ValueVector
pub fn compact_column(&self, col_idx: usize) -> ValueVector
Extract a column compacted through the selection vector. When the selection is identity, clones the column directly (cheap for FlatVector/Owned). When non-identity, materializes selected values.
Sourcepub fn select_columns(self, indices: &[usize]) -> Self
pub fn select_columns(self, indices: &[usize]) -> Self
Create a new DataChunk containing only the specified columns (by move).
Sourcepub fn take_column(&mut self, col_idx: usize) -> ValueVector
pub fn take_column(&mut self, col_idx: usize) -> ValueVector
Move a column out of the chunk (replacing it with an empty Owned vec). For identity selection, avoids cloning the underlying data. For non-identity, materializes selected values.
Sourcepub fn with_selection(self, selection: SelectionVector) -> Self
pub fn with_selection(self, selection: SelectionVector) -> Self
Replace selection, keeping columns intact. Consumes self.
Sourcepub fn row_ref(&self, row_idx: usize) -> RowRef<'_>
pub fn row_ref(&self, row_idx: usize) -> RowRef<'_>
Get a zero-copy row reference for expression evaluation.
Sourcepub fn append_row_from_chunk(&mut self, source: &DataChunk, row_idx: usize)
pub fn append_row_from_chunk(&mut self, source: &DataChunk, row_idx: usize)
Copy a single row from a source chunk. Target must use Owned columns.
Sourcepub fn append_row_from_chunk_with_extra(
&mut self,
source: &DataChunk,
row_idx: usize,
extra: TypedValue,
)
pub fn append_row_from_chunk_with_extra( &mut self, source: &DataChunk, row_idx: usize, extra: TypedValue, )
Copy a row from source chunk and append an extra value as the last column.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DataChunk
impl RefUnwindSafe for DataChunk
impl Send for DataChunk
impl Sync for DataChunk
impl Unpin for DataChunk
impl UnsafeUnpin for DataChunk
impl UnwindSafe for DataChunk
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);