pub struct MvStore<Clock: LogicalClock> { /* private fields */ }Expand description
A multi-version concurrency control database.
Implementations§
Source§impl<Clock: LogicalClock> MvStore<Clock>
impl<Clock: LogicalClock> MvStore<Clock>
Sourcepub fn insert(&self, tx_id: TxID, row: Row) -> Result<()>
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.
Sourcepub fn update(&self, tx_id: TxID, row: Row) -> Result<bool>
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.
Sourcepub fn upsert(&self, tx_id: TxID, row: Row) -> Result<()>
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.
Sourcepub fn delete(&self, tx_id: TxID, id: RowID) -> Result<bool>
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.
Sourcepub fn read(&self, tx_id: TxID, id: RowID) -> Result<Option<Row>>
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.
Sourcepub fn scan_row_ids(&self) -> Result<Vec<RowID>>
pub fn scan_row_ids(&self) -> Result<Vec<RowID>>
Gets all row ids in the database.
Sourcepub fn scan_row_ids_for_table(&self, table_id: u64) -> Result<Vec<RowID>>
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.
pub fn get_row_id_range( &self, table_id: u64, start: i64, bucket: &mut Vec<RowID>, max_items: u64, ) -> Result<()>
pub fn get_next_row_id_for_table( &self, table_id: u64, start: i64, ) -> Option<RowID>
Sourcepub fn begin_tx(&self) -> TxID
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.
Sourcepub fn commit_tx(&self, tx_id: TxID) -> Result<()>
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.
Sourcepub fn rollback_tx(&self, tx_id: TxID)
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.
Sourcepub fn get_timestamp(&self) -> u64
pub fn get_timestamp(&self) -> u64
Gets current timestamp
Sourcepub fn drop_unused_row_versions(&self) -> usize
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.