Database

Struct Database 

Source
pub struct Database { /* private fields */ }
Expand description

A collection of tables and indexes over them.

A database also owns the memory pools used by its tables.

Implementations§

Source§

impl Database

Source

pub fn run_rule_set(&mut self, rule_set: &RuleSet) -> RuleSetReport

Source§

impl Database

Source

pub fn new() -> Database

Create an empty Database.

Queries are executed using the current rayon thread pool, which defaults to the global thread pool.

Source

pub fn new_rule_set(&mut self) -> RuleSetBuilder<'_>

Initialize a new rulse set to run against this database.

Source

pub fn add_external_function( &mut self, f: impl ExternalFunction + 'static, ) -> ExternalFunctionId

Add a new external function to the database.

Source

pub fn free_external_function(&mut self, id: ExternalFunctionId)

Free an existing external function. Make sure not to use id afterwards.

Source

pub fn base_values(&self) -> &BaseValues

Source

pub fn base_values_mut(&mut self) -> &mut BaseValues

Source

pub fn container_values(&self) -> &ContainerValues

Source

pub fn container_values_mut(&mut self) -> &mut ContainerValues

Source

pub fn rebuild_containers(&mut self, table_id: TableId) -> bool

Source

pub fn apply_rebuild( &mut self, func_id: TableId, to_rebuild: &[TableId], next_ts: Value, ) -> bool

Apply the value-level rebuild encoded by func_id to all the tables in to_rebuild.

The native Table::apply_rebuild method takes a next_ts argument for filling in new values in a table like crate::SortedWritesTable where values in a certain column need to be inserted in sorted order; the next_ts argument to this method is passed to apply_rebuild for this purpose.

Source

pub fn with_execution_state<R>( &self, f: impl FnOnce(&mut ExecutionState<'_>) -> R, ) -> R

Run f with access to an ExecutionState mapped to this database.

Source

pub fn estimate_size(&self, table: TableId, c: Option<Constraint>) -> usize

Estimate the size of the table. If a constraint is provided, return an estimate of the size of the subset of the table matching the constraint.

Source

pub fn add_counter(&mut self) -> CounterId

Create a new counter for this database.

These counters can be used to generate unique ids as part of an action.

Source

pub fn inc_counter(&self, counter: CounterId) -> usize

Increment the given counter and return its previous value.

Source

pub fn read_counter(&self, counter: CounterId) -> usize

Get the current value of the given counter.

Source

pub fn merge_all(&mut self) -> bool

A helper for merging all pending updates. Used to write to the database after updates have been staged. Returns true if any tuples were added.

Exposed for testing purposes.

Useful for out-of-band insertions into the database.

Source

pub fn merge_table(&mut self, table: TableId)

A low-level helper for merging pending updates to a particular function.

Callers should prefer merge_all, as the process of merging the data for a particular table may cause other updates to be buffered elesewhere. The merge_all method runs merges to a fixed point to avoid surprises here.

Source

pub fn next_table_id(&self) -> TableId

Get id of the next table to be added to the database.

This can be useful for “knot tying”, when tables need to reference their own id.

Source

pub fn add_table<T: Table + Sized + 'static>( &mut self, table: T, read_deps: impl IntoIterator<Item = TableId>, write_deps: impl IntoIterator<Item = TableId>, ) -> TableId

Add a table with the given schema to the database.

The table must have a compatible spec with types (e.g. same number of columns).

Source

pub fn get_table(&self, id: TableId) -> &WrappedTable

Get direct mutable access to the table.

This method is useful for out-of-band access to databse state.

Source

pub fn get_table_mut(&mut self, id: TableId) -> &mut dyn Table

Get direct mutable access to the table.

This method is useful for out-of-band access to databse state.

Trait Implementations§

Source§

impl Clone for Database

Source§

fn clone(&self) -> Database

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 Database

Source§

fn default() -> Database

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

impl Drop for Database

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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