pub struct MemoryTable { /* private fields */ }Expand description
A table held in memory as a sequence of chunks.
Implementations§
Source§impl MemoryTable
impl MemoryTable
Sourcepub fn new(types: Vec<LogicalType>) -> Self
pub fn new(types: Vec<LogicalType>) -> Self
An empty table of the given column types.
Sourcepub fn types(&self) -> &[LogicalType]
pub fn types(&self) -> &[LogicalType]
The column types.
Sourcepub fn chunk_count(&self) -> usize
pub fn chunk_count(&self) -> usize
How many chunks a scan will read.
Sourcepub fn append(&mut self, chunk: Chunk) -> Result<()>
pub fn append(&mut self, chunk: Chunk) -> Result<()>
Appends a chunk, which has to have the table’s column types.
An empty chunk is dropped rather than stored, because a scan that has to skip empty chunks is a scan with a branch in it that exists only because an operator upstream was sloppy.
§Errors
If the chunk’s columns are not the table’s columns.
Sourcepub fn append_rows(&mut self, rows: &[Vec<Value>]) -> Result<()>
pub fn append_rows(&mut self, rows: &[Vec<Value>]) -> Result<()>
Appends rows given one at a time, splitting them into chunks.
The slow way in, for an INSERT and for a test. It transposes, which is the whole cost:
rows arrive across the columns and a chunk is down them.
§Errors
If a row is not as wide as the table, or if a value is not one its column can hold.
Sourcepub fn read(&self, chunk: usize, columns: &[usize]) -> Result<Chunk>
pub fn read(&self, chunk: usize, columns: &[usize]) -> Result<Chunk>
One chunk’s worth of the named columns, in the order they are named.
The columns are copied, because a vector owns its buffer and there is nothing to borrow
from yet. Borrowed buffers with a pin are the M2 item in spec/07-execution.md section 7.1,
and this is the call that will stop copying when they arrive. Asking for the columns rather
than taking them all is what makes that copy proportional to the query instead of to the
table, which is the same reason projection pushdown exists.
§Errors
If there is no such chunk, or if a column is past the end of the table.
Trait Implementations§
Source§impl Clone for MemoryTable
impl Clone for MemoryTable
Source§fn clone(&self) -> MemoryTable
fn clone(&self) -> MemoryTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more