Struct rocksdb::Transaction

source ·
pub struct Transaction<'db, DB> { /* private fields */ }
Expand description

RocksDB Transaction.

To use transactions, you must first create a TransactionDB or OptimisticTransactionDB.

Implementations§

Write all batched keys to the DB atomically.

May return any error that could be returned by DB::write.

If this transaction was created by a TransactionDB, an error of the Expired kind may be returned if this transaction has lived longer than expiration time in TransactionOptions.

If this transaction was created by an OptimisticTransactionDB, an error of the Busy kind may be returned if the transaction could not guarantee that there are no write conflicts. An error of the TryAgain kind may be returned if the memtable history size is not large enough (see Options::set_max_write_buffer_size_to_maintain).

Returns snapshot associated with transaction if snapshot was enabled in TransactionOptions. Otherwise, returns a snapshot with nullptr inside which doesn’t effect read operations.

Discard all batched writes in this transaction.

Record the state of the transaction for future calls to rollback_to_savepoint. May be called multiple times to set multiple save points.

Undo all operations in this transaction since the most recent call to set_savepoint and removes the most recent set_savepoint.

Returns error if there is no previous call to set_savepoint.

Get the bytes associated with a key value.

See get_cf_opt for details.

Get the bytes associated with a key value and the given column family.

See get_cf_opt for details.

Get the key and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).

See get_for_update_cf_opt for details.

Get the key in the given column family and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).

See get_for_update_cf_opt for details.

Returns the bytes associated with a key value with read options.

See get_cf_opt for details.

Get the bytes associated with a key value and the given column family with read options.

This function will also read pending changes in this transaction. Currently, this function will return an error of the MergeInProgress kind if the most recent write to the queried key in this batch is a Merge.

Get the key with read options and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).

See get_for_update_cf_opt for details.

Get the key in the given column family with read options and ensure that this transaction will only be able to be committed if this key is not written outside this transaction after it has first been read (or after the snapshot if a snapshot is set in this transaction).

Currently, this function will return an error of the MergeInProgress if the most recent write to the queried key in this batch is a Merge.

If this transaction was created by a TransactionDB, it can return error of kind:

  • Busy if there is a write conflict.
  • TimedOut if a lock could not be acquired.
  • TryAgain if the memtable history size is not large enough.
  • MergeInProgress if merge operations cannot be resolved.
  • or other errors if this key could not be read.

If this transaction was created by an [OptimisticTransactionDB], get_for_update_opt can cause commit to fail. Otherwise, it could return any error that could be returned by [DB::get].

Return the values associated with the given keys.

Return the values associated with the given keys using read options.

Return the values associated with the given keys and column families.

Return the values associated with the given keys and column families using read options.

Put the key value in default column family and do conflict checking on the key.

See put_cf for details.

Put the key value in the given column famuly and do conflict checking on the key.

If this transaction was created by a TransactionDB, it can return error of kind:

  • Busy if there is a write conflict.
  • TimedOut if a lock could not be acquired.
  • TryAgain if the memtable history size is not large enough.
  • MergeInProgress if merge operations cannot be resolved.
  • or other errors on unexpected failures.

Merge value with existing value of key, and also do conflict checking on the key.

See merge_cf for details.

Merge value with existing value of key in the given column family, and also do conflict checking on the key.

If this transaction was created by a TransactionDB, it can return error of kind:

  • Busy if there is a write conflict.
  • TimedOut if a lock could not be acquired.
  • TryAgain if the memtable history size is not large enough.
  • MergeInProgress if merge operations cannot be resolved.
  • or other errors on unexpected failures.

Delete the key value if it exists and do conflict checking on the key.

See delete_cf for details.

Delete the key value in the given column family and do conflict checking.

If this transaction was created by a TransactionDB, it can return error of kind:

  • Busy if there is a write conflict.
  • TimedOut if a lock could not be acquired.
  • TryAgain if the memtable history size is not large enough.
  • MergeInProgress if merge operations cannot be resolved.
  • or other errors on unexpected failures.

Opens an iterator using the provided ReadOptions. This is used when you want to iterate over a specific ColumnFamily with a modified ReadOptions.

Opens an iterator with set_total_order_seek enabled. This must be used to iterate across prefixes when set_memtable_factory has been called with a Hash-based implementation.

Opens a raw iterator over the database, using the default read options

Opens a raw iterator over the given column family, using the default read options

Opens a raw iterator over the database, using the given read options

Opens a raw iterator over the given column family, using the given read options

Trait Implementations§

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.