Fix typos, fix some warnings, added more compile options, moved to forgejo CI
Some checks failed
Main LMDBAL workflow / Test LMDBAL with qt5 (push) Has been cancelled
Main LMDBAL workflow / Test LMDBAL with qt6 (push) Has been cancelled
Main LMDBAL workflow / Release documentation (push) Has been cancelled

This commit is contained in:
Blue 2025-05-02 18:19:06 +03:00
parent 3ae1fd15c0
commit 1585b8e4f5
Signed by: blue
GPG key ID: 9B203B252A63EE38
15 changed files with 204 additions and 120 deletions

View file

@ -28,13 +28,13 @@
* \brief Database abstraction
*
* This is a basic class that represents the database as a collection of storages.
* Storages is something key-value database has instead of tables in classic SQL databases.
* Storages are something that key-value databases have instead of tables in classic SQL databases.
*/
/**
* \brief Creates the database
*
* \param[in] _name - name of the database, it is going to affect folder name that is created to store data
* \param[in] _name - name of the database, it is going to affect the folder name that is created to store data
* \param[in] _mapSize - LMDB map size (MiB), multiplied by 1024^2 and passed to <a class="el" href="http://www.lmdb.tech/doc/group__mdb.html#gaa2506ec8dab3d969b0e609cd82e619e5">mdb_env_set_mapsize</a> during the call of LMDBAL::Base::open()
*/
LMDBAL::Base::Base(const QString& _name, uint16_t _mapSize):
@ -60,13 +60,13 @@ LMDBAL::Base::~Base() {
* \brief Closes the database
*
* Closes all lmdb handles, aborts all public transactions.
* This function will do nothing on closed database
* This function will do nothing on a closed database
*
* \exception LMDBAL::Unknown - thrown if something went wrong aborting transactions
*/
void LMDBAL::Base::close() {
if (opened) {
for (const std::pair<LMDBAL::TransactionID, LMDBAL::Transaction*> pair : transactions) {
for (const std::pair<TransactionID, Transaction*> pair : transactions) {
abortTransaction(pair.first, emptyName);
pair.second->reset();
}
@ -84,8 +84,8 @@ void LMDBAL::Base::close() {
* \brief Opens the database
*
* Almost every LMDBAL::Base require it to be opened, this function does it.
* It laso creates the directory for the database if it was an initial launch.
* This function will do nothing on opened database
* It also creates the directory for the database if it was an initial launch.
* This function will do nothing on an opened database
*
* \exception LMDBAL::Unknown - thrown if something went wrong opening storages and caches
*/
@ -94,15 +94,14 @@ void LMDBAL::Base::open() {
mdb_env_create(&environment);
QString path = createDirectory();
mdb_env_set_maxdbs(environment, storages.size());
mdb_env_set_maxdbs(environment, static_cast<MDB_dbi>(storages.size()));
mdb_env_set_mapsize(environment, size * 1024UL * 1024UL);
mdb_env_open(environment, path.toStdString().c_str(), 0, 0664);
TransactionID txn = beginPrivateTransaction(emptyName);
for (const std::pair<const std::string, StorageCommon*>& pair : storages) {
StorageCommon* storage = pair.second;
int rc = storage->open(txn);
if (rc)
if (const int rc = storage->open(txn))
throw Unknown(name, mdb_strerror(rc));
}
commitPrivateTransaction(txn, emptyName);
@ -113,9 +112,9 @@ void LMDBAL::Base::open() {
/**
* \brief Removes database directory
*
* \returns true if removal was successfull of if no directory was created where it's expected to be, false otherwise
* \returns true if removal was successful of if no directory was created where it's expected to be, false otherwise
*
* \exception LMDBAL::Opened - thrown if this function was called on opened database
* \exception LMDBAL::Opened - thrown if this function was called on an opened database
*/
bool LMDBAL::Base::removeDirectory() {
if (opened)
@ -141,7 +140,7 @@ bool LMDBAL::Base::removeDirectory() {
*
* \returns the path of the created directory
*
* \exception LMDBAL::Opened - thrown if called on opened database
* \exception LMDBAL::Opened - thrown if called on an opened database
* \exception LMDBAL::Directory - if the database couldn't create the folder
*/
QString LMDBAL::Base::createDirectory() {