#include <transaction_manager.h>
Public Member Functions | |
bool | store (const drizzled::message::Transaction &transaction) |
bool | remove (uint64_t trx_id) |
bool | contains (uint64_t trx_id) |
uint32_t | getTransactionBufferSize (uint64_t trx_id) |
bool | getTransactionMessage (drizzled::message::Transaction &transaction, uint64_t trx_id, uint32_t position) |
Private Attributes | |
boost::unordered_map< uint64_t, MsgBufferType > | cache |
Simple (example) Transaction message buffer and content manager.
This class groups Transaction messages together by transaction ID and buffers them together in memory. Obviously, this could eat up a lot of memory if you have very large transactions. A more robust implementation would buffer larger transactions to disk rather than memory.
Definition at line 49 of file transaction_manager.h.
bool TransactionManager::contains | ( | uint64_t | trx_id | ) |
Check to see if any Transaction messages exist for a given transaction.
[in] | trx_id | The transaction ID to check for. |
true | Transaction messages exist |
false | No Transaction messages found |
Definition at line 49 of file transaction_manager.cc.
uint32_t TransactionManager::getTransactionBufferSize | ( | uint64_t | trx_id | ) |
Return number of cached elements for the given transaction ID.
[in] | trx_id | Transaction ID |
Definition at line 59 of file transaction_manager.cc.
bool TransactionManager::getTransactionMessage | ( | drizzled::message::Transaction & | transaction, |
uint64_t | trx_id, | ||
uint32_t | position | ||
) |
Retrieve a Transaction message from the managed cache.
Caller must supply a Transaction message to populate. The Transaction message to retrieve is indexed by a combination of transaction ID and position.
[out] | transaction | Transaction message to populate |
[in] | trx_id | Transaction ID |
[in] | position | Index into the buffer associated with trx_id |
true | Success |
false | Failure |
Definition at line 64 of file transaction_manager.cc.
bool TransactionManager::remove | ( | uint64_t | trx_id | ) |
Clear the buffer contents for a given transaction ID.
[in] | trx_id | The transaction ID for the transaction to remove |
true | Success |
false | Failure |
Definition at line 43 of file transaction_manager.cc.
bool TransactionManager::store | ( | const drizzled::message::Transaction & | transaction | ) |
Store the given Transaction message in a buffer.
[in] | transaction | Pointer to the Transaction message to store. |
true | Success |
false | Failure |
Definition at line 32 of file transaction_manager.cc.
boost::unordered_map<uint64_t,MsgBufferType> TransactionManager::cache [private] |
Our message buffer cache, mapped by the transaction ID.
We organize Transactions messages by grouping them by transaction ID, then storing the messages in std::vectors in std::string format. The string format is convenient because it can be easily copied around (GPB messages do not provide deep copying).
Definition at line 118 of file transaction_manager.h.