MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
|
A class representing a transaction in oblsm. 更多...
#include <ob_lsm_transaction.h>
Public 成员函数 | |
ObLsmTransaction (ObLsm *db, uint64_t ts) | |
Constructor. 更多... | |
RC | get (const string_view &key, string *value) |
RC | put (const string_view &key, const string_view &value) |
Adds or updates a key-value pair within the transaction's in-memory store. | |
RC | remove (const string_view &key) |
Removes a key from the database within the transaction's scope. 更多... | |
ObLsmIterator * | new_iterator (ObLsmReadOptions options) |
RC | commit () |
Commits the transaction, persisting all transaction changes to the database. 更多... | |
RC | rollback () |
Rollback the transaction, discarding all uncommitted changes. | |
Private 属性 | |
ObLsm * | db_ = nullptr |
Pointer to the associated ObLsm database. 更多... | |
uint64_t | ts_ = 0 |
The transaction's unique timestamp. 更多... | |
map< string, string > | inner_store_ |
In-memory store for transactional changes. 更多... | |
A class representing a transaction in oblsm.
The ObLsmTransaction
class provides functionality for transactional operations on oblsm. It enables reading, writing, deleting, and iterating over keys/values in the database within a transactional scope. Transactions can be committed or rollback, ensuring atomicity and isolation.
oceanbase::ObLsmTransaction::ObLsmTransaction | ( | ObLsm * | db, |
uint64_t | ts | ||
) |
Constructor.
Initializes a transaction object and associates it with a specific LSM database. Assigns a unique timestamp (ts
) to the transaction.
db | A pointer to the ObLsm database on which this transaction operates. |
ts | The timestamp for the transaction. |
RC oceanbase::ObLsmTransaction::commit | ( | ) |
Commits the transaction, persisting all transaction changes to the database.
ObLsmIterator * oceanbase::ObLsmTransaction::new_iterator | ( | ObLsmReadOptions | options | ) |
The iterator allows traversal of keys and values within the database. Options can define how data is accessed, such as timestamp.
options | The ObLsmReadOptions that define the read behavior of the iterator. |
ObLsmIterator
object. RC oceanbase::ObLsmTransaction::remove | ( | const string_view & | key | ) |
Removes a key from the database within the transaction's scope.
This method marks the specified key for removal, but it is not persisted to the database until the transaction is committed.
|
private |
Pointer to the associated ObLsm
database.
This member variable links the transaction to its underlying database, ensuring that all transactional operations target the correct storage layer.
|
private |
In-memory store for transactional changes.
This map holds key-value pairs that have been inserted or removed within the transaction scope but not yet committed to the database. It's used to track changes and ensure atomicity during commit operations.
|
private |
The transaction's unique timestamp.