pub struct DisplacedTable { /* private fields */ }Expand description
A special table backed by a union-find used to efficiently implement egglog-style canonicaliztion.
To canonicalize columns, we need to efficiently discover values that have ceased to be canonical. To do that we keep a table of displaced values:
This table has three columns:
- (the only key): a value that is no longer canonical in the equivalence relation.
- The canonical value of the equivalence class.
- The timestamp at which the key stopped being canonical.
We do not store the second value explicitly: instead, we compute it on-the-fly using a union-find data-structure.
This is related to the ‘Leader’ encoding in some versions of egglog: Displaced is a version of Leader that only stores ids when they cease to be canonical. Rows are also “automatically updated” with the current leader, rather than requiring the DB to replay history or canonicalize redundant values in the table.
To union new ids l, and r, stage an update Displaced(l, r, ts) where
ts is the current timestamp. Note that all tie-breaks and other encoding
decisions are made internally, so there may not literally be a row added
with this value.
Implementations§
Source§impl DisplacedTable
impl DisplacedTable
pub fn underlying_uf(&self) -> &UnionFind<Value>
Trait Implementations§
Source§impl Clone for DisplacedTable
impl Clone for DisplacedTable
Source§impl Default for DisplacedTable
impl Default for DisplacedTable
Source§impl Table for DisplacedTable
impl Table for DisplacedTable
Source§fn dyn_clone(&self) -> Box<dyn Table>
fn dyn_clone(&self) -> Box<dyn Table>
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Table. Read moreSource§fn rebuilder<'a>(&'a self, cols: &[ColumnId]) -> Option<Box<dyn Rebuilder + 'a>>
fn rebuilder<'a>(&'a self, cols: &[ColumnId]) -> Option<Box<dyn Rebuilder + 'a>>
Rebuilder for it.Source§fn clear(&mut self)
fn clear(&mut self)
Source§fn version(&self) -> TableVersion
fn version(&self) -> TableVersion
Source§fn updates_since(&self, offset: Offset) -> Subset
fn updates_since(&self, offset: Offset) -> Subset
Source§fn 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,
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. Read moreSource§fn refine_one(&self, subset: Subset, c: &Constraint) -> Subset
fn refine_one(&self, subset: Subset, c: &Constraint) -> Subset
Source§fn fast_subset(&self, constraint: &Constraint) -> Option<Subset>
fn fast_subset(&self, constraint: &Constraint) -> Option<Subset>
Source§fn get_row(&self, key: &[Value]) -> Option<Row>
fn get_row(&self, key: &[Value]) -> Option<Row>
Source§fn get_row_column(&self, key: &[Value], col: ColumnId) -> Option<Value>
fn get_row_column(&self, key: &[Value], col: ColumnId) -> Option<Value>
Source§fn new_buffer(&self) -> Box<dyn MutationBuffer>
fn new_buffer(&self) -> Box<dyn MutationBuffer>
Source§fn merge(&mut self, _: &mut ExecutionState<'_>) -> TableChange
fn merge(&mut self, _: &mut ExecutionState<'_>) -> TableChange
Source§fn 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<'_>, )
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. Read moreSource§fn 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,
Source§fn refine_live(&self, subset: Subset) -> Subset
fn refine_live(&self, subset: Subset) -> Subset
Source§fn refine(&self, subset: Subset, cs: &[Constraint]) -> Subset
fn refine(&self, subset: Subset, cs: &[Constraint]) -> Subset
Source§fn 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>>)
fast_subset method to
preprocess a set of constraints into “fast” and “slow” ones, returning
the subet of indexes that match the fast one.Auto Trait Implementations§
impl Freeze for DisplacedTable
impl RefUnwindSafe for DisplacedTable
impl Send for DisplacedTable
impl Sync for DisplacedTable
impl Unpin for DisplacedTable
impl UnwindSafe for DisplacedTable
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> 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 more