pub trait Table:
Any
+ Send
+ Sync {
Show 22 methods
// Required methods
fn dyn_clone(&self) -> Box<dyn Table>;
fn as_any(&self) -> &dyn Any;
fn spec(&self) -> TableSpec;
fn clear(&mut self);
fn all(&self) -> Subset;
fn len(&self) -> usize;
fn version(&self) -> TableVersion;
fn updates_since(&self, offset: Offset) -> Subset;
fn scan_generic_bounded(
&self,
subset: SubsetRef<'_>,
start: Offset,
n: usize,
cs: &[Constraint],
f: impl FnMut(RowId, &[Value]),
) -> Option<Offset>
where Self: Sized;
fn get_row(&self, key: &[Value]) -> Option<Row>;
fn merge(&mut self, exec_state: &mut ExecutionState<'_>) -> TableChange;
fn new_buffer(&self) -> Box<dyn MutationBuffer>;
// Provided methods
fn rebuilder<'a>(
&'a self,
_cols: &[ColumnId],
) -> Option<Box<dyn Rebuilder + 'a>> { ... }
fn apply_rebuild(
&mut self,
_table_id: TableId,
_table: &WrappedTable,
_next_ts: Value,
_exec_state: &mut ExecutionState<'_>,
) { ... }
fn is_empty(&self) -> bool { ... }
fn scan_generic(
&self,
subset: SubsetRef<'_>,
f: impl FnMut(RowId, &[Value]),
)
where Self: Sized { ... }
fn refine_live(&self, subset: Subset) -> Subset { ... }
fn refine_one(&self, subset: Subset, c: &Constraint) -> Subset { ... }
fn refine(&self, subset: Subset, cs: &[Constraint]) -> Subset { ... }
fn fast_subset(&self, _: &Constraint) -> Option<Subset> { ... }
fn split_fast_slow(
&self,
cs: &[Constraint],
) -> (Subset, Pooled<Vec<Constraint>>, Pooled<Vec<Constraint>>) { ... }
fn get_row_column(&self, key: &[Value], col: ColumnId) -> Option<Value> { ... }
}Expand description
An interface for a table.
Required Methods§
Sourcefn dyn_clone(&self) -> Box<dyn Table>
fn dyn_clone(&self) -> Box<dyn Table>
A variant of clone that returns a boxed trait object; this trait object must contain all of the data associated with the current table.
Sourcefn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
A boilerplate method to make it easier to downcast values of Table.
Implementors should be able to implement this method by returning
self.
Sourcefn spec(&self) -> TableSpec
fn spec(&self) -> TableSpec
The schema of the table.
These are immutable properties of the table; callers can assume they will never change.
Sourcefn clear(&mut self)
fn clear(&mut self)
Clear all table contents. If the table is nonempty, this will change the generation of the table. This method also clears any pending data.
Sourcefn len(&self) -> usize
fn len(&self) -> usize
Get the length of the table.
This is not in general equal to the length of the all subset: the size
of a subset is allowed to be larger than the number of table entries in
range of the subset.
Sourcefn version(&self) -> TableVersion
fn version(&self) -> TableVersion
Sourcefn updates_since(&self, offset: Offset) -> Subset
fn updates_since(&self, offset: Offset) -> Subset
Get the subset of the table that has appeared since the last offset.
Sourcefn scan_generic_bounded(
&self,
subset: SubsetRef<'_>,
start: Offset,
n: usize,
cs: &[Constraint],
f: impl FnMut(RowId, &[Value]),
) -> Option<Offset>where
Self: Sized,
fn scan_generic_bounded(
&self,
subset: SubsetRef<'_>,
start: Offset,
n: usize,
cs: &[Constraint],
f: impl FnMut(RowId, &[Value]),
) -> Option<Offset>where
Self: Sized,
Iterate over the given subset of the table, starting at an opaque
start token, ending after up to n rows, returning the next start
token if more rows remain. Only invoke f on rows that match the given
constraints.
This method is not object safe, but it is used to define various
“default” implementations of object-safe methods like scan and
pivot.
Sourcefn get_row(&self, key: &[Value]) -> Option<Row>
fn get_row(&self, key: &[Value]) -> Option<Row>
Look up a single row by the given key values, if it is in the table.
The number of values specified by keys should match the number of
primary keys for the table.
Sourcefn merge(&mut self, exec_state: &mut ExecutionState<'_>) -> TableChange
fn merge(&mut self, exec_state: &mut ExecutionState<'_>) -> TableChange
Merge any updates to the table, and potentially update the generation for the table.
Sourcefn new_buffer(&self) -> Box<dyn MutationBuffer>
fn new_buffer(&self) -> Box<dyn MutationBuffer>
Create a new buffer for staging mutations on this table.
Provided Methods§
Sourcefn rebuilder<'a>(
&'a self,
_cols: &[ColumnId],
) -> Option<Box<dyn Rebuilder + 'a>>
fn rebuilder<'a>( &'a self, _cols: &[ColumnId], ) -> Option<Box<dyn Rebuilder + 'a>>
If this table can perform a table-level rebuild, construct a Rebuilder for it.
Sourcefn apply_rebuild(
&mut self,
_table_id: TableId,
_table: &WrappedTable,
_next_ts: Value,
_exec_state: &mut ExecutionState<'_>,
)
fn apply_rebuild( &mut self, _table_id: TableId, _table: &WrappedTable, _next_ts: Value, _exec_state: &mut ExecutionState<'_>, )
Rebuild the table according to the given Rebuilder implemented by table, if
there is one. Applying a rebuild can cause more mutations to be buffered, which can in turn
be flushed by a call to Table::merge.
Note that value-level rebuilds are only relevant for tables that opt into it. As a result, tables do nothing by default.
Sourcefn scan_generic(&self, subset: SubsetRef<'_>, f: impl FnMut(RowId, &[Value]))where
Self: Sized,
fn scan_generic(&self, subset: SubsetRef<'_>, f: impl FnMut(RowId, &[Value]))where
Self: Sized,
Iterate over the given subset of the table.
This is a variant of Table::scan_generic_bounded that iterates over
the entire table.
Sourcefn refine_live(&self, subset: Subset) -> Subset
fn refine_live(&self, subset: Subset) -> Subset
Filter a given subset of the table for the rows that are live
Sourcefn refine_one(&self, subset: Subset, c: &Constraint) -> Subset
fn refine_one(&self, subset: Subset, c: &Constraint) -> Subset
Filter a given subset of the table for the rows matching the single constraint.
Implementors must provide at least one of refine_one or refine.`
Sourcefn refine(&self, subset: Subset, cs: &[Constraint]) -> Subset
fn refine(&self, subset: Subset, cs: &[Constraint]) -> Subset
Filter a given subset of the table for the rows matching the given constraints.
Implementors must provide at least one of refine_one or refine.`
Sourcefn fast_subset(&self, _: &Constraint) -> Option<Subset>
fn fast_subset(&self, _: &Constraint) -> Option<Subset>
An optional method for quickly generating a subset from a constraint. The standard use-case here is to apply constraints based on a column that is known to be sorted.
These constraints are very helpful for query planning; it is a good idea to implement them.
Sourcefn split_fast_slow(
&self,
cs: &[Constraint],
) -> (Subset, Pooled<Vec<Constraint>>, Pooled<Vec<Constraint>>)
fn split_fast_slow( &self, cs: &[Constraint], ) -> (Subset, Pooled<Vec<Constraint>>, Pooled<Vec<Constraint>>)
A helper routine that leverages the existing fast_subset method to
preprocess a set of constraints into “fast” and “slow” ones, returning
the subet of indexes that match the fast one.