more duplicates test, misinterpreted something about duplicates, had to fallback
This commit is contained in:
parent
06e1aca45a
commit
180c40370c
8 changed files with 126 additions and 89 deletions
|
@ -43,10 +43,10 @@
|
|||
*
|
||||
* \param[in] parent - LMDBAL::Base pointer for the owning database (borrowed)
|
||||
* \param[in] name - the name of the storage
|
||||
* \param[in] duplicates - LMDBAL::Duplicates duplicates mode (uniqueKey by default)
|
||||
* \param[in] duplicates - true if key duplicates are allowed (false by default)
|
||||
*/
|
||||
template<class K, class V>
|
||||
LMDBAL::Storage<K, V>::Storage(Base* parent, const std::string& name, Duplicates duplicates):
|
||||
LMDBAL::Storage<K, V>::Storage(Base* parent, const std::string& name, bool duplicates):
|
||||
iStorage(parent, name, duplicates),
|
||||
keySerializer(),
|
||||
valueSerializer(),
|
||||
|
@ -111,18 +111,11 @@ void LMDBAL::Storage<K, V>::addRecord(const K& key, const V& value, TransactionI
|
|||
MDB_val lmdbKey = keySerializer.setData(key);
|
||||
MDB_val lmdbData = valueSerializer.setData(value);
|
||||
|
||||
unsigned int flags;
|
||||
switch (duplicates) {
|
||||
case uniqueKey:
|
||||
flags = MDB_NOOVERWRITE;
|
||||
break;
|
||||
case uniquePair:
|
||||
flags = MDB_NODUPDATA;
|
||||
break;
|
||||
case full:
|
||||
flags = 0;
|
||||
break;
|
||||
}
|
||||
unsigned int flags = 0;
|
||||
if (duplicates)
|
||||
flags |= MDB_NODUPDATA;
|
||||
else
|
||||
flags |= MDB_NOOVERWRITE;
|
||||
|
||||
int rc = mdb_put(txn, dbi, &lmdbKey, &lmdbData, flags);
|
||||
if (rc != MDB_SUCCESS)
|
||||
|
@ -808,7 +801,7 @@ void LMDBAL::Storage<K, V>::discoveredRecord(const K& key, const V& value, Trans
|
|||
* \tparam K type of keys in opening storage
|
||||
*
|
||||
* \param[in] transaction - lmdb transaction to call <a class="el" href="http://www.lmdb.tech/doc/group__mdb.html#gac08cad5b096925642ca359a6d6f0562a">mdb_dbi_open</a>, must be a writable transaction!
|
||||
* \param[in] duplicates - true if you wish to enable duplicates support for the storage
|
||||
* \param[in] duplicates - true if key duplicates are allowed (false by default)
|
||||
*
|
||||
* \returns MDB_SUCCESS if everything went smooth or MDB_<error> -like error code
|
||||
*
|
||||
|
@ -817,12 +810,12 @@ void LMDBAL::Storage<K, V>::discoveredRecord(const K& key, const V& value, Trans
|
|||
* This infrastructure also allowes us to customize mdb_dbi_open call in the future
|
||||
*/
|
||||
template<class K, class V>
|
||||
inline int LMDBAL::iStorage::makeStorage(MDB_txn* transaction, Duplicates duplicates) {
|
||||
inline int LMDBAL::iStorage::makeStorage(MDB_txn* transaction, bool duplicates) {
|
||||
unsigned int flags = MDB_CREATE;
|
||||
if constexpr (std::is_integral<K>::value)
|
||||
flags |= MDB_INTEGERKEY;
|
||||
|
||||
if (duplicates != uniqueKey) {
|
||||
if (duplicates) {
|
||||
flags |= MDB_DUPSORT;
|
||||
|
||||
if constexpr (std::is_scalar<K>::value && std::is_scalar<V>::value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue