LMDBAL 0.5.4
LMDB (Lightning Memory-Mapped Database Manager) Abstraction Layer
|
Public Member Functions | |
virtual void | drop () |
Drops content of a storage interface. | |
virtual int | drop (const WriteTransaction &txn) |
Drops content of a storage interface (public transaction variant) | |
virtual SizeType | count () const |
Storage size. | |
virtual SizeType | count (const Transaction &txn) const |
Storage size (public transaction variant) | |
template<> | |
std::string | toString (const QString &value) |
A method to cast a value (which can be a value or a key) to string. | |
template<> | |
std::string | toString (const std::string &value) |
A method to cast a value (which can be a value or a key) to string. | |
Protected Member Functions | |
iStorage (Base *parent, const std::string &name, bool duplicates=false) | |
Constructs a storage interface. | |
virtual | ~iStorage () |
Destroys a storage interface. | |
virtual int | open (MDB_txn *transaction)=0 |
A private virtual function I need to open each storage in the database. | |
virtual void | close () |
A private virtual function I need to close each storage in the database. | |
virtual void | handleDrop () |
A method where database additionally handles drop. | |
bool | isDBOpened () const |
Is database opened. | |
const std::string & | dbName () const |
Database name. | |
void | ensureOpened (const std::string &methodName) const |
Helper function, thows exception if the database is not opened. | |
void | throwDuplicateOrUnknown (int rc, const std::string &key) const |
Throws LMDBAL::Exist or LMDBAL::Unknown. | |
void | throwDuplicateOrUnknown (int rc, TransactionID txn, const std::string &key) const |
Throws LMDBAL::Exist or LMDBAL::Unknown (transaction vairiant) | |
void | throwNotFoundOrUnknown (int rc, const std::string &key) const |
Throws LMDBAL::NotFound or LMDBAL::Unknown (transaction variant) | |
void | throwNotFoundOrUnknown (int rc, TransactionID txn, const std::string &key) const |
Throws LMDBAL::NotFound or LMDBAL::Unknown (transaction vairiant) | |
void | throwUnknown (int rc, TransactionID txn) const |
Throws LMDBAL::Unknown (transaction vairiant) | |
void | throwUnknown (int rc) const |
Throws LMDBAL::Unknown. | |
void | throwUnknown (const std::string &message) const |
Throws LMDBAL::Unknown. | |
void | throwDuplicate (const std::string &key) const |
Throws LMDBAL::Exist. | |
void | throwNotFound (const std::string &key) const |
Throws LMDBAL::NotFound. | |
void | throwCursorNotReady (const std::string &method) const |
Throws LMDBAL::CursorNotReady. | |
TransactionID | extractTransactionId (const Transaction &txn, const std::string &action="") const |
Checks if the transaction is still active, returns inner TransactionID. | |
TransactionID | beginReadOnlyTransaction () const |
Begins read-only transaction. | |
TransactionID | beginTransaction () const |
Begins writable transaction. | |
void | commitTransaction (TransactionID id) |
Commits transaction. | |
void | abortTransaction (TransactionID id) const |
Aborts transaction. | |
virtual void | transactionStarted (TransactionID txn, bool readOnly) const |
called on beginning of public transaction | |
virtual void | transactionCommited (TransactionID txn) |
called on commitment of public transaction | |
virtual void | transactionAborted (TransactionID txn) const |
called on abortion of public transaction | |
virtual int | drop (TransactionID transaction) |
Drops content of a storage interface (transaction variant) | |
virtual SizeType | count (TransactionID txn) const |
Storage size (private transaction variant) | |
int | _mdbOpen (MDB_txn *txn, unsigned int flags=0) |
int | _mdbPut (MDB_txn *txn, MDB_val &key, MDB_val &data, unsigned int flags=0) |
int | _mdbGet (MDB_txn *txn, MDB_val &key, MDB_val &data) const |
int | _mdbDel (MDB_txn *txn, MDB_val &key) |
int | _mdbDel (MDB_txn *txn, MDB_val &key, MDB_val &data) |
int | _mdbStat (MDB_txn *txn, MDB_stat &stat) const |
int | _mdbFlags (MDB_txn *txn, uint32_t &flags) const |
int | _mdbCursorOpen (MDB_txn *txn, MDB_cursor **cursor) const |
void | _mdbCursorClose (MDB_cursor *cursor) const |
int | _mdbCursorGet (MDB_cursor *cursor, MDB_val &key, MDB_val &data, MDB_cursor_op operation) const |
int | _mdbCursorSet (MDB_cursor *cursor, MDB_val &key) const |
int | _mdbCursorDel (MDB_cursor *cursor, unsigned int flags=0) |
int | _mdbCursorPut (MDB_cursor *cursor, MDB_val &key, MDB_val &data, unsigned int flags=0) |
int | _mdbCursorRenew (MDB_txn *txn, MDB_cursor *cursor) const |
MDB_txn * | _mdbCursorTxn (MDB_cursor *cursor) const |
template<class K , class V > | |
int | makeStorage (MDB_txn *transaction, bool duplicates=false) |
A functiion to actually open MDB_dbi storage. | |
Static Protected Member Functions | |
template<class T > | |
static std::string | toString (const T &value) |
A method to cast a value (which can be a value or a key) to string. | |
Protected Attributes | |
MDB_dbi | dbi |
lmdb storage handle | |
Base * | db |
parent database pointer (borrowed) | |
const std::string | name |
this storage name | |
const bool | duplicates |
true if storage supports duplicates | |
Friends | |
class | Base |
Storage interface.
This is a interface-like class, it's designed to be an inner database interface to be used as a polymorphic entity, and provide protected interaction with the database from the heirs code
|
protected |
Constructs a storage interface.
[in] | parent | - LMDBAL::Base pointer for the owning database (borrowed) |
[in] | name | - the name of the storage |
[in] | duplicates | - true if key duplicates are allowed (false by default) |
|
protected |
Aborts transaction.
Ment to be called from heirs, name is reported to the database just to be displayed in std::exception::what() message
|
protected |
Begins read-only transaction.
Ment to be called from heirs, name is reported to the database just to be displayed in std::exception::what() message
|
protected |
Begins writable transaction.
Ment to be called from heirs, name is reported to the database just to be displayed in std::exception::what() message
|
protectedvirtual |
A private virtual function I need to close each storage in the database.
Reimplemented in LMDBAL::Storage< K, V >.
|
protected |
Commits transaction.
Ment to be called from heirs, name is reported to the database just to be displayed in std::exception::what() message
LMDBAL::Unknown | thrown if something unexpected happened |
|
virtual |
Storage size.
LMDBAL::Closed | thrown if the database was closed |
LMDBAL::Unknown | thrown if something unexpected happened |
Reimplemented in LMDBAL::Cache< K, V >.
|
virtual |
Storage size (public transaction variant)
[in] | txn | - transaction, can be read-only transaction |
LMDBAL::Closed | thrown if the database was closed |
LMDBAL::Unknown | thrown if something unexpected happened |
LMDBAL::TransactionTerminated | thrown if the passed transaction not active, any action with it's inner ID is an error |
|
protectedvirtual |
Storage size (private transaction variant)
[in] | txn | - transaction ID, can be read-only transaction |
LMDBAL::Unknown | thrown if something unexpected happened |
Reimplemented in LMDBAL::Cache< K, V >.
|
protected |
Database name.
Ment to be used in heirs, to provide some sort of interface to acces to some of the database information
|
virtual |
Drops content of a storage interface.
Designed to drop storage content
LMDBAL::Closed | thrown if the database was closed |
LMDBAL::Unknown | thrown if something unexpected happened |
Reimplemented in LMDBAL::Storage< K, V >.
|
virtual |
Drops content of a storage interface (public transaction variant)
Just performs content drop
[in] | txn | - transaction ID, must be writable transaction! |
LMDBAL::TransactionTerminated | thrown if the transaction was not active |
Reimplemented in LMDBAL::Cache< K, V >, and LMDBAL::Storage< K, V >.
|
protectedvirtual |
Drops content of a storage interface (transaction variant)
Just performs content drop
[in] | transaction | - transaction ID, must be writable transaction! |
Reimplemented in LMDBAL::Storage< K, V >.
|
protected |
Helper function, thows exception if the database is not opened.
[in] | methodName | - name of the method this function is called from, just for display in std::exception::what() message |
LMDBAL::Closed | thrown if the database was closed |
|
protected |
Checks if the transaction is still active, returns inner TransactionID.
This method is for internal usage only
[in] | txn | - a transaction, you want to extract ID from |
[in] | action | - a description of what you're going to do, in case of exception the error description will be verbose |
LMDBAL::TransactionTerminated | thrown if the passed transaction not active, any action with it's inner ID is an error |
|
protectedvirtual |
A method where database additionally handles drop.
It's a protected method that is called to optimise drop process after the transaction is commited. Used just for optimisations.
Reimplemented in LMDBAL::Cache< K, V >.
|
protected |
Is database opened.
Ment to be used in heirs, to provide some sort of interface to acces to some of the database information
|
inlineprotected |
A functiion to actually open MDB_dbi storage.
K | type of keys in opening storage |
[in] | transaction | - lmdb transaction to call mdb_dbi_open, must be a writable transaction! |
[in] | duplicates | - true if key duplicates are allowed (false by default) |
This is a way to optimise database using MDB_INTEGERKEY flag, when the key is actually kind of an integer This infrastructure also allowes us to customize mdb_dbi_open call in the future
|
protectedpure virtual |
A private virtual function I need to open each storage in the database.
[in] | transaction | - lmdb transaction to call mdb_dbi_open |
Implemented in LMDBAL::Storage< K, V >.
|
protected |
Throws LMDBAL::CursorNotReady.
Helper function ment to be used in heirs and reduce the code a bit
[in] | method | - called cursor method name, just to show in std::exception::what() message |
LMDBAL::CursorNotReady | thrown everytime |
|
protected |
Throws LMDBAL::Exist.
Helper function ment to be used in heirs and reduce the code a bit
[in] | key | - requested key string representation, just to show in std::exception::what() message |
LMDBAL::Exist | thrown everytime |
|
protected |
Throws LMDBAL::Exist or LMDBAL::Unknown.
Helper function ment to be used in heirs and reduce the code a bit
[in] | rc | - result of lmdb low level operation |
[in] | key | - requested key string representation, just to show in std::exception::what() message |
LMDBAL::Exist | thrown if rc == MDB_KEYEXIST |
LMDBAL::Unknown | thrown if rc != MDB_KEYEXIST |
|
protected |
Throws LMDBAL::Exist or LMDBAL::Unknown (transaction vairiant)
Helper function ment to be used in heirs and reduce the code a bit
[in] | rc | - result of lmdb low level operation |
[in] | txn | - transaction ID to be aborted, any transaction |
[in] | key | - requested key string representation, just to show in std::exception::what() message |
LMDBAL::Exist | thrown if rc == MDB_KEYEXIST |
LMDBAL::Unknown | thrown if rc != MDB_KEYEXIST |
|
protected |
Throws LMDBAL::NotFound.
Helper function ment to be used in heirs and reduce the code a bit
[in] | key | - requested key string representation, just to show in std::exception::what() message |
LMDBAL::NotFound | thrown everytime |
|
protected |
Throws LMDBAL::NotFound or LMDBAL::Unknown (transaction variant)
Helper function ment to be used in heirs and reduce the code a bit
[in] | rc | - result of lmdb low level operation |
[in] | key | - requested key string representation, just to show in std::exception::what() message |
LMDBAL::NotFound | thrown if rc == MDB_NOTFOUND |
LMDBAL::Unknown | thrown if rc != MDB_NOTFOUND |
|
protected |
Throws LMDBAL::NotFound or LMDBAL::Unknown (transaction vairiant)
Helper function ment to be used in heirs and reduce the code a bit
[in] | rc | - result of lmdb low level operation |
[in] | txn | - transaction ID to be aborted, any transaction |
[in] | key | - requested key string representation, just to show in std::exception::what() message |
LMDBAL::NotFound | thrown if rc == MDB_NOTFOUND |
LMDBAL::Unknown | thrown if rc != MDB_NOTFOUND |
|
protected |
Throws LMDBAL::Unknown.
Helper function ment to be used in heirs and reduce the code a bit
[in] | message | - a message you wish to appear in the exception reason |
LMDBAL::Unknown | thrown everytime |
|
protected |
Throws LMDBAL::Unknown.
Helper function ment to be used in heirs and reduce the code a bit
[in] | rc | - result of lmdb low level operation |
LMDBAL::Unknown | thrown everytime |
|
protected |
Throws LMDBAL::Unknown (transaction vairiant)
Helper function ment to be used in heirs and reduce the code a bit
[in] | rc | - result of lmdb low level operation |
[in] | txn | - transaction ID to be aborted, any transaction |
LMDBAL::Unknown | thrown everytime |
|
inline |
A method to cast a value (which can be a value or a key) to string.
QString spectialization
[in] | value | a value that should be converted to string |
|
inline |
A method to cast a value (which can be a value or a key) to string.
std::string spectialization
[in] | value | a value that should be converted to string |
|
inlinestaticprotected |
A method to cast a value (which can be a value or a key) to string.
This function is mainly used in exceptions, to report which key was duplicated or not found. You can define your own specializations to this function in case std::to_string doesn't cover your case
[in] | value | a value that should be converted to string |
|
protectedvirtual |
called on abortion of public transaction
This function is called on every storage of the database when user calls LMDBAL::Base::abortTransaction(LMDBAL::TransactionID)
This function is met to be reimplemented in heirs if the heir code requires some transaction custom handling
[in] | txn | - ID of started transaction |
Reimplemented in LMDBAL::Cache< K, V >.
|
protectedvirtual |
called on commitment of public transaction
This function is called on every storage of the database when user calls LMDBAL::Base::commitTransaction(LMDBAL::TransactionID)
This function is met to be reimplemented in heirs if the heir code requires some transaction custom handling
[in] | txn | - ID of started transaction |
Reimplemented in LMDBAL::Cache< K, V >.
|
protectedvirtual |
called on beginning of public transaction
This function is called on every storage of the database when user calls LMDBAL::Base::beginTransaction() or LMDBAL::Base::beginReadOnlyTransaction()
This function is met to be reimplemented in heirs if the heir code requires some transaction custom handling
[in] | txn | - ID of started transaction |
[in] | readOnly | - true if transaction is read-only, false otherwise |
Reimplemented in LMDBAL::Cache< K, V >.