MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
Public 成员函数 | Private 属性 | 所有成员列表
oceanbase::ObLsmTransaction类 参考

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. 更多...
 
ObLsmIteratornew_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 属性

ObLsmdb_ = 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.

构造及析构函数说明

◆ ObLsmTransaction()

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.

参数
dbA pointer to the ObLsm database on which this transaction operates.
tsThe timestamp for the transaction.

成员函数说明

◆ commit()

RC oceanbase::ObLsmTransaction::commit ( )

Commits the transaction, persisting all transaction changes to the database.

◆ new_iterator()

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.

参数
optionsThe ObLsmReadOptions that define the read behavior of the iterator.
返回
A pointer to the newly created ObLsmIterator object.

◆ remove()

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.

类成员变量说明

◆ db_

ObLsm* oceanbase::ObLsmTransaction::db_ = nullptr
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.

◆ inner_store_

map<string, string> oceanbase::ObLsmTransaction::inner_store_
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.

◆ ts_

uint64_t oceanbase::ObLsmTransaction::ts_ = 0
private

The transaction's unique timestamp.


该类的文档由以下文件生成: