Skip to main content

MvStore

Struct MvStore 

Source
pub struct MvStore<Clock: LogicalClock> { /* private fields */ }
Expand description

A multi-version concurrency control database.

Implementations§

Source§

impl<Clock: LogicalClock> MvStore<Clock>

Source

pub fn new(clock: Clock, storage: Storage) -> Self

Creates a new database.

Source

pub fn insert(&self, tx_id: TxID, row: Row) -> Result<()>

Inserts a new row into the database.

This function inserts a new row into the database within the context of the transaction tx_id.

§Arguments
  • tx_id - the ID of the transaction in which to insert the new row.
  • row - the row object containing the values to be inserted.
Source

pub fn update(&self, tx_id: TxID, row: Row) -> Result<bool>

Updates a row in the database with new values.

This function updates an existing row in the database within the context of the transaction tx_id. The row argument identifies the row to be updated as id and contains the new values to be inserted.

If the row identified by the id does not exist, this function does nothing and returns false. Otherwise, the function updates the row with the new values and returns true.

§Arguments
  • tx_id - the ID of the transaction in which to update the new row.
  • row - the row object containing the values to be updated.
§Returns

Returns true if the row was successfully updated, and false otherwise.

Source

pub fn upsert(&self, tx_id: TxID, row: Row) -> Result<()>

Inserts a row in the database with new values, previously deleting any old data if it existed. Bails on a delete error, e.g. write-write conflict.

Source

pub fn delete(&self, tx_id: TxID, id: RowID) -> Result<bool>

Deletes a row from the table with the given id.

This function deletes an existing row id in the database within the context of the transaction tx_id.

§Arguments
  • tx_id - the ID of the transaction in which to delete the new row.
  • id - the ID of the row to delete.
§Returns

Returns true if the row was successfully deleted, and false otherwise.

Source

pub fn read(&self, tx_id: TxID, id: RowID) -> Result<Option<Row>>

Retrieves a row from the table with the given id.

This operation is performed within the scope of the transaction identified by tx_id.

§Arguments
  • tx_id - The ID of the transaction to perform the read operation in.
  • id - The ID of the row to retrieve.
§Returns

Returns Some(row) with the row data if the row with the given id exists, and None otherwise.

Source

pub fn scan_row_ids(&self) -> Result<Vec<RowID>>

Gets all row ids in the database.

Source

pub fn scan_row_ids_for_table(&self, table_id: u64) -> Result<Vec<RowID>>

Gets all row ids in the database for a given table.

Source

pub fn get_row_id_range( &self, table_id: u64, start: i64, bucket: &mut Vec<RowID>, max_items: u64, ) -> Result<()>

Source

pub fn get_next_row_id_for_table( &self, table_id: u64, start: i64, ) -> Option<RowID>

Source

pub fn begin_tx(&self) -> TxID

Begins a new transaction in the database.

This function starts a new transaction in the database and returns a TxID value that you can use to perform operations within the transaction. All changes made within the transaction are isolated from other transactions until you commit the transaction.

Source

pub fn commit_tx(&self, tx_id: TxID) -> Result<()>

Commits a transaction with the specified transaction ID.

This function commits the changes made within the specified transaction and finalizes the transaction. Once a transaction has been committed, all changes made within the transaction are visible to other transactions that access the same data.

§Arguments
  • tx_id - The ID of the transaction to commit.
Source

pub fn rollback_tx(&self, tx_id: TxID)

Rolls back a transaction with the specified ID.

This function rolls back a transaction with the specified tx_id by discarding any changes made by the transaction.

§Arguments
  • tx_id - The ID of the transaction to abort.
Source

pub fn get_tx_id(&self) -> u64

Generates next unique transaction id

Source

pub fn get_timestamp(&self) -> u64

Gets current timestamp

Source

pub fn drop_unused_row_versions(&self) -> usize

Removes unused row versions with very loose heuristics, which sometimes leaves versions intact for too long. Returns the number of removed versions.

Source

pub fn recover(&self) -> Result<()>

Trait Implementations§

Source§

impl<Clock: Debug + LogicalClock> Debug for MvStore<Clock>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Clock> !Freeze for MvStore<Clock>

§

impl<Clock> !RefUnwindSafe for MvStore<Clock>

§

impl<Clock> !UnwindSafe for MvStore<Clock>

§

impl<Clock> Send for MvStore<Clock>
where Clock: Send,

§

impl<Clock> Sync for MvStore<Clock>
where Clock: Sync,

§

impl<Clock> Unpin for MvStore<Clock>
where Clock: Unpin,

§

impl<Clock> UnsafeUnpin for MvStore<Clock>
where Clock: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more