pub struct Chunk { /* private fields */ }Expand description
A batch of columns of equal length.
Implementations§
Source§impl Chunk
impl Chunk
Sourcepub fn new(columns: Vec<Vector>) -> Result<Self>
pub fn new(columns: Vec<Vector>) -> Result<Self>
A chunk of columns, taking the row count from the first of them.
§Errors
If the columns are not all the same length, or if there are more rows than VECTOR_SIZE.
Sourcepub fn with_rows(columns: Vec<Vector>, rows: usize) -> Result<Self>
pub fn with_rows(columns: Vec<Vector>, rows: usize) -> Result<Self>
A chunk of columns that is rows long, for the case where there are no columns to take
the count from.
§Errors
If any column is not rows long, or if rows is more than VECTOR_SIZE.
Sourcepub fn empty(types: &[LogicalType]) -> Self
pub fn empty(types: &[LogicalType]) -> Self
A chunk of the given types with no rows in it.
What a scan of an empty table returns and what an operator returns when it is done. The types are kept, because a consumer asks a chunk what its columns are before it asks whether there are any.
Sourcepub fn into_columns(self) -> Vec<Vector>
pub fn into_columns(self) -> Vec<Vector>
The columns, given up.
Sourcepub fn types(&self) -> Vec<LogicalType>
pub fn types(&self) -> Vec<LogicalType>
The type of each column.
Sourcepub fn value_at(&self, row: usize, column: usize) -> Value
pub fn value_at(&self, row: usize, column: usize) -> Value
The value at a row and a column, or null if either is past the end.
The slow path, same as Vector::value_at. It is what a result set is read out with and
what a test asserts on.
Sourcepub fn select(self, selection: &Selection) -> Result<Self>
pub fn select(self, selection: &Selection) -> Result<Self>
The rows a selection kept, without moving any of the values.
Every column becomes a dictionary vector whose codes are the selection, which is the form
spec/07-execution.md section 7.1 asks a filter to produce rather than compacting. It takes
the chunk by value because that is what makes it free: the payload is moved into the new
vector rather than copied, so a filter that keeps one row in a thousand still costs the
selection and nothing else.
§Errors
If the selection points past the end of the chunk.
Sourcepub fn project(self, positions: &[usize]) -> Result<Self>
pub fn project(self, positions: &[usize]) -> Result<Self>
The columns at the given positions, in that order.
A position may appear twice, which is what SELECT x, x FROM t is, and the second one costs
a copy. Every other position is moved.
§Errors
If a position is past the end of the chunk.
Sourcepub fn flatten(&self) -> Result<Self>
pub fn flatten(&self) -> Result<Self>
The same rows with every column in flat form.
Costs a copy per column that was not already flat. It is here for the result set at the top of a query, where the dictionary vectors a filter left behind would otherwise be handed to a caller who has to understand them.
§Errors
If a column has a type that cannot be stored flat yet, which today means the nested types.