pragma once and minor change in transactions
Some checks failed
Main LMDBAL workfow / Test LMDBAL with qt5 (push) Failing after 1m8s
Main LMDBAL workfow / Test LMDBAL with qt6 (push) Successful in 1m24s
Main LMDBAL workfow / Release documentation (push) Has been skipped

This commit is contained in:
Blue 2024-12-17 20:03:48 +02:00
parent 43d4900809
commit 56d35d4832
Signed by: blue
GPG Key ID: 9B203B252A63EE38
29 changed files with 79 additions and 143 deletions

View File

@ -1,5 +1,9 @@
# Changelog
# LMDBAL 0.6.0 (UNRELEASED)
### Improvements
- Less dereferencing
# LMDBAL 0.5.4 (November 30, 2024)
### Improvements
- Technical release just to resolve build issues

View File

@ -10,7 +10,7 @@ depends=( 'lmdb' )
makedepends=('cmake>=3.16' 'gcc')
optdepends=()
source=("lmdbal-$pkgver.tar.gz::https://git.macaw.me/blue/lmdbal/archive/$pkgver.tar.gz")
source=("lmdbal-$pkgver-$pkgrel.tar.gz::https://git.macaw.me/blue/lmdbal/archive/$pkgver.tar.gz")
sha256sums=('SKIP')
build() {
cd "$srcdir/lmdbal"

View File

@ -43,7 +43,7 @@ LMDBAL::Base::Base(const QString& _name, uint16_t _mapSize):
size(_mapSize),
environment(),
storages(),
transactions(new Transactions())
transactions()
{}
/**
@ -52,8 +52,6 @@ LMDBAL::Base::Base(const QString& _name, uint16_t _mapSize):
LMDBAL::Base::~Base() {
close();
delete transactions;
for (const std::pair<const std::string, iStorage*>& pair : storages)
delete pair.second;
}
@ -68,14 +66,14 @@ LMDBAL::Base::~Base() {
*/
void LMDBAL::Base::close() {
if (opened) {
for (const LMDBAL::TransactionID id : *transactions)
for (const LMDBAL::TransactionID id : transactions)
abortTransaction(id, emptyName);
for (const std::pair<const std::string, iStorage*>& pair : storages)
pair.second->close();
mdb_env_close(environment);
transactions->clear();
transactions.clear();
opened = false;
}
}
@ -301,7 +299,7 @@ LMDBAL::TransactionID LMDBAL::Base::beginReadOnlyTransaction(const std::string&
throw Closed("beginReadOnlyTransaction", name, storageName);
TransactionID txn = beginPrivateReadOnlyTransaction(storageName);
transactions->emplace(txn);
transactions.emplace(txn);
for (const std::pair<const std::string, LMDBAL::iStorage*>& pair : storages)
pair.second->transactionStarted(txn, true);
@ -325,7 +323,7 @@ LMDBAL::TransactionID LMDBAL::Base::beginTransaction(const std::string& storageN
throw Closed("beginTransaction", name, storageName);
TransactionID txn = beginPrivateTransaction(storageName);
transactions->emplace(txn);
transactions.emplace(txn);
for (const std::pair<const std::string, LMDBAL::iStorage*>& pair : storages)
pair.second->transactionStarted(txn, false);
@ -349,15 +347,15 @@ void LMDBAL::Base::abortTransaction(LMDBAL::TransactionID id, const std::string&
if (!opened)
throw Closed("abortTransaction", name, storageName);
Transactions::iterator itr = transactions->find(id);
if (itr == transactions->end()) //TODO may be it's a good idea to make an exception class for this
Transactions::iterator itr = transactions.find(id);
if (itr == transactions.end()) //TODO may be it's a good idea to make an exception class for this
throw Unknown(name, "unable to abort transaction: transaction was not found", storageName);
abortPrivateTransaction(id, storageName);
for (const std::pair<const std::string, LMDBAL::iStorage*>& pair : storages)
pair.second->transactionAborted(id);
transactions->erase(itr);
transactions.erase(itr);
}
/**
@ -376,15 +374,15 @@ void LMDBAL::Base::commitTransaction(LMDBAL::TransactionID id, const std::string
if (!opened)
throw Closed("abortTransaction", name, storageName);
Transactions::iterator itr = transactions->find(id);
if (itr == transactions->end()) //TODO may be it's a good idea to make an exception class for this
Transactions::iterator itr = transactions.find(id);
if (itr == transactions.end()) //TODO may be it's a good idea to make an exception class for this
throw Unknown(name, "unable to commit transaction: transaction was not found", storageName);
commitPrivateTransaction(id, storageName);
for (const std::pair<const std::string, LMDBAL::iStorage*>& pair : storages)
pair.second->transactionCommited(id);
transactions->erase(itr);
transactions.erase(itr);
}
/**

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_BASE_H
#define LMDBAL_BASE_H
#pragma once
#include <map>
#include <set>
@ -106,7 +105,7 @@ private:
uint16_t size; /**<\brief lmdb map size in MiB*/
MDB_env* environment; /**<\brief lmdb environment handle*/
Storages storages; /**<\brief Registered storages and caches*/
Transactions* transactions; /**<\brief Active public transactions*/
mutable Transactions transactions; /**<\brief Active public transactions*/
inline static const std::string emptyName = ""; /**<\brief Empty string for general fallback purposes*/
};
@ -215,5 +214,3 @@ template <class K, class V>
LMDBAL::Cache<K, V>* LMDBAL::Base::getCache(const std::string& storageName) {
return static_cast<Cache<K, V>*>(storages.at(storageName));
}
#endif //LMDBAL_BASE_H

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_CACHE_H
#define LMDBAL_CACHE_H
#pragma once
#include <map>
#include <set>
@ -134,5 +133,3 @@ protected:
}
#include "cache.hpp"
#endif // LMDBAL_CACHE_H

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_CACHE_HPP
#define LMDBAL_CACHE_HPP
#pragma once
#include "cache.h"
#include "exceptions.h"
@ -898,5 +897,3 @@ void LMDBAL::Cache<K, V>::destroyTransactionEntry(const Entry& entry) const {
break;
}
}
#endif //LMDBAL_CACHE_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_CURSOR_H
#define LMDBAL_CURSOR_H
#pragma once
#include <string>
@ -105,5 +104,3 @@ private:
#include "cursor.hpp"
#endif //LMDBAL_CURSOR_H

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_CURSOR_HPP
#define LMDBAL_CURSOR_HPP
#pragma once
#include "cursor.h"
#include <iostream>
@ -657,5 +656,3 @@ void LMDBAL::Cursor<K, V>::operateCursorRead(
else
storage->discoveredRecord(key, value, storage->_mdbCursorTxn(cursor));
}
#endif //LMDBAL_CURSOR_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_EXCEPTIONS_H
#define LMDBAL_EXCEPTIONS_H
#pragma once
#include <stdexcept>
#include <string>
@ -237,5 +236,3 @@ private:
};
}
#endif //LMDBAL_EXCEPTIONS_H

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_OPERATORS_HPP
#define LMDBAL_OPERATORS_HPP
#pragma once
#include <map>
#include <set>
@ -209,5 +208,3 @@ QDataStream& operator >> (QDataStream &in, std::list<K>& container) {
return in;
}
#endif //LMDBAL_OPERATORS_HPP

View File

@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_H
#define LMDBAL_SERIALIZER_H
#pragma once
#include <cstring>
@ -68,5 +68,3 @@ private:
#include "serializer_stdstring.hpp"
#include "serializer_qstring.hpp"
#include "serializer_qbytearray.hpp"
#endif // LMDBAL_SERIALIZER_H

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_HPP
#define LMDBAL_SERIALIZER_HPP
#pragma once
#include "serializer.h"
@ -159,5 +158,3 @@ MDB_val LMDBAL::Serializer<T>::getData() {
return val;
}
#endif //LMDBAL_SERIALIZER_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_DOUBLE_HPP
#define LMDBAL_SERIALIZER_DOUBLE_HPP
#pragma once
namespace LMDBAL {
@ -53,7 +52,5 @@ private:
}
#endif //LMDBAL_SERIALIZER_DOUBLE_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_FLOAT_HPP
#define LMDBAL_SERIALIZER_FLOAT_HPP
#pragma once
namespace LMDBAL {
@ -52,8 +51,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_FLOAT_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_INT16_HPP
#define LMDBAL_SERIALIZER_INT16_HPP
#pragma once
#include <stdint.h>
@ -54,5 +53,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_INT16_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_INT32_HPP
#define LMDBAL_SERIALIZER_INT32_HPP
#pragma once
#include <stdint.h>
@ -54,8 +53,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_INT32_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_INT64_HPP
#define LMDBAL_SERIALIZER_INT64_HPP
#pragma once
#include <stdint.h>
@ -54,8 +53,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_INT64_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_INT8_HPP
#define LMDBAL_SERIALIZER_INT8_HPP
#pragma once
#include <stdint.h>
@ -54,8 +53,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_INT8_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_QBYTEARRAY_HPP
#define LMDBAL_SERIALIZER_QBYTEARRAY_HPP
#pragma once
#include <QByteArray>
@ -56,9 +55,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_QBYTEARRAY_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_QSTRING_HPP
#define LMDBAL_SERIALIZER_QSTRING_HPP
#pragma once
#include <QString>
#include <QByteArray>
@ -56,10 +55,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_QSTRING_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_STDSTRING_HPP
#define LMDBAL_SERIALIZER_STDSTRING_HPP
#pragma once
#include <string>
@ -54,9 +53,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_STDSTRING_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_UINT16_HPP
#define LMDBAL_SERIALIZER_UINT16_HPP
#pragma once
#include <stdint.h>
@ -54,7 +53,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_UINT16_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_UINT32_HPP
#define LMDBAL_SERIALIZER_UINT32_HPP
#pragma once
#include <stdint.h>
@ -54,5 +53,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_UINT32_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_UINT64_HPP
#define LMDBAL_SERIALIZER_UINT64_HPP
#pragma once
#include <stdint.h>
@ -54,6 +53,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_UINT64_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_SERIALIZER_UINT8_HPP
#define LMDBAL_SERIALIZER_UINT8_HPP
#pragma once
#include <stdint.h>
@ -54,8 +53,3 @@ private:
};
}
#endif //LMDBAL_SERIALIZER_UINT8_HPP

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_STORAGE_H
#define LMDBAL_STORAGE_H
#pragma once
#include <type_traits>
#include <cstring>
@ -199,5 +198,3 @@ protected:
}
#include "storage.hpp"
#endif //LMDBAL_STORAGE_H

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LMDBAL_STORAGE_HPP
#define LMDBAL_STORAGE_HPP
#pragma once
#include "storage.h"
#include "exceptions.h"
@ -1182,5 +1181,3 @@ template<>
inline std::string LMDBAL::iStorage::toString(const std::string& value) {
return value;
}
#endif //LMDBAL_STORAGE_HPP

View File

@ -1,3 +1,21 @@
/*
* LMDB Abstraction Layer.
* Copyright (C) 2023 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "transaction.h"
/**

View File

@ -1,3 +1,21 @@
/*
* LMDB Abstraction Layer.
* Copyright (C) 2023 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base.h"