DisplacedTable

Struct DisplacedTable 

Source
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:

  1. (the only key): a value that is no longer canonical in the equivalence relation.
  2. The canonical value of the equivalence class.
  3. 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§

Trait Implementations§

Source§

impl Clone for DisplacedTable

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for DisplacedTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Table for DisplacedTable

Source§

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.
Source§

fn as_any(&self) -> &dyn Any

A boilerplate method to make it easier to downcast values of Table. Read more
Source§

fn spec(&self) -> TableSpec

The schema of the table. Read more
Source§

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.
Source§

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.
Source§

fn all(&self) -> Subset

Get a subset corresponding to all rows in the table.
Source§

fn len(&self) -> usize

Get the length of the table. Read more
Source§

fn version(&self) -> TableVersion

Get the current version for the table. RowIds and Subsets are only valid for a given major generation.
Source§

fn updates_since(&self, offset: Offset) -> Subset

Get the subset of the table that has appeared since the last offset.
Source§

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. Read more
Source§

fn refine_one(&self, subset: Subset, c: &Constraint) -> Subset

Filter a given subset of the table for the rows matching the single constraint. Read more
Source§

fn fast_subset(&self, constraint: &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. Read more
Source§

fn get_row(&self, key: &[Value]) -> Option<Row>

Look up a single row by the given key values, if it is in the table. Read more
Source§

fn get_row_column(&self, key: &[Value], col: ColumnId) -> Option<Value>

Look up the given column of single row by the given key values, if it is in the table. Read more
Source§

fn new_buffer(&self) -> Box<dyn MutationBuffer>

Create a new buffer for staging mutations on this table.
Source§

fn merge(&mut self, _: &mut ExecutionState<'_>) -> TableChange

Merge any updates to the table, and potentially update the generation for the table.
Source§

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. Read more
Source§

fn is_empty(&self) -> bool

Check if the table is empty.
Source§

fn scan_generic(&self, subset: SubsetRef<'_>, f: impl FnMut(RowId, &[Value]))
where Self: Sized,

Iterate over the given subset of the table. Read more
Source§

fn refine_live(&self, subset: Subset) -> Subset

Filter a given subset of the table for the rows that are live
Source§

fn refine(&self, subset: Subset, cs: &[Constraint]) -> Subset

Filter a given subset of the table for the rows matching the given constraints. Read more
Source§

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V