lmdb calls are now compiled into .so
All checks were successful
Main LMDBAL workfow / Archlinux (push) Successful in 41s
All checks were successful
Main LMDBAL workfow / Archlinux (push) Successful in 41s
This commit is contained in:
parent
77ba8f9e7b
commit
6b475f615e
6 changed files with 118 additions and 35 deletions
|
@ -115,7 +115,7 @@ void LMDBAL::Storage<K, V>::addRecord(const K& key, const V& value, TransactionI
|
|||
else
|
||||
flags |= MDB_NOOVERWRITE;
|
||||
|
||||
int rc = mdb_put(txn, dbi, &lmdbKey, &lmdbData, flags);
|
||||
int rc = _mdbPut(txn, lmdbKey, lmdbData, flags);
|
||||
if (rc != MDB_SUCCESS)
|
||||
throwDuplicateOrUnknown(rc, toString(key));
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ bool LMDBAL::Storage<K, V>::forceRecord(const K& key, const V& value, Transactio
|
|||
MDB_val lmdbKey = keySerializer.setData(key);
|
||||
MDB_val lmdbData;
|
||||
|
||||
int rc = mdb_get(txn, dbi, &lmdbKey, &lmdbData);
|
||||
int rc = _mdbGet(txn, lmdbKey, lmdbData);
|
||||
switch (rc) {
|
||||
case MDB_SUCCESS:
|
||||
added = false;
|
||||
|
@ -223,7 +223,7 @@ bool LMDBAL::Storage<K, V>::forceRecord(const K& key, const V& value, Transactio
|
|||
}
|
||||
|
||||
lmdbData = valueSerializer.setData(value);
|
||||
rc = mdb_put(txn, dbi, &lmdbKey, &lmdbData, 0);
|
||||
rc = _mdbPut(txn, lmdbKey, lmdbData);
|
||||
if (rc != MDB_SUCCESS)
|
||||
throwUnknown(rc);
|
||||
}
|
||||
|
@ -314,13 +314,13 @@ void LMDBAL::Storage<K, V>::changeRecord(const K& key, const V& value) {
|
|||
template<class K, class V>
|
||||
void LMDBAL::Storage<K, V>::changeRecord(const K& key, const V& value, TransactionID txn) {
|
||||
MDB_cursor* cursor;
|
||||
int rc = mdb_cursor_open(txn, dbi, &cursor);
|
||||
int rc = _mdbCursorOpen(txn, &cursor);
|
||||
if (rc != MDB_SUCCESS)
|
||||
throwUnknown(rc);
|
||||
|
||||
MDB_val lmdbKey = keySerializer.setData(key);
|
||||
MDB_val lmdbData;
|
||||
rc = mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_SET);
|
||||
rc = _mdbCursorGet(cursor, lmdbKey, lmdbData, MDB_SET);
|
||||
if (rc != MDB_SUCCESS)
|
||||
throwNotFoundOrUnknown(rc, toString(key));
|
||||
|
||||
|
@ -330,21 +330,21 @@ void LMDBAL::Storage<K, V>::changeRecord(const K& key, const V& value, Transacti
|
|||
if (sameSize) { //can compare only if they are the same size
|
||||
firstDifferentByte = memcmp(lmdbData.mv_data, lmdbNewData.mv_data, lmdbData.mv_size);
|
||||
if (firstDifferentByte == 0) { //old and new is the same, nothing to do
|
||||
mdb_cursor_close(cursor);
|
||||
_mdbCursorClose(cursor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int flags = MDB_CURRENT;
|
||||
if (duplicates && (!sameSize || firstDifferentByte < 0)) { //if new value is greater than the old one
|
||||
rc = mdb_cursor_del(cursor, 0); //we need to initiate duplicates sort, for it to be in the correct place
|
||||
rc = _mdbCursorDel(cursor); //we need to initiate duplicates sort, for it to be in the correct place
|
||||
flags = MDB_NODUPDATA;
|
||||
}
|
||||
|
||||
if (rc == MDB_SUCCESS)
|
||||
rc = mdb_cursor_put(cursor, &lmdbKey, &lmdbNewData, flags);
|
||||
rc = _mdbCursorPut(cursor, lmdbKey, lmdbNewData, flags);
|
||||
|
||||
mdb_cursor_close(cursor);
|
||||
_mdbCursorClose(cursor);
|
||||
if (rc != MDB_SUCCESS)
|
||||
throwDuplicateOrUnknown(rc, toString(key));
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ void LMDBAL::Storage<K, V>::getRecord(const K& key, V& value, TransactionID txn)
|
|||
MDB_val lmdbKey = keySerializer.setData(key);
|
||||
MDB_val lmdbData;
|
||||
|
||||
int rc = mdb_get(txn, dbi, &lmdbKey, &lmdbData);
|
||||
int rc = _mdbGet(txn, lmdbKey, lmdbData);
|
||||
if (rc != MDB_SUCCESS)
|
||||
throwNotFoundOrUnknown(rc, toString(key));
|
||||
|
||||
|
@ -594,7 +594,7 @@ bool LMDBAL::Storage<K, V>::checkRecord(const K& key, TransactionID txn) const {
|
|||
MDB_val lmdbKey = keySerializer.setData(key);
|
||||
MDB_val lmdbData;
|
||||
|
||||
int rc = mdb_get(txn, dbi, &lmdbKey, &lmdbData);
|
||||
int rc = _mdbGet(txn, lmdbKey, lmdbData);
|
||||
if (rc == MDB_SUCCESS)
|
||||
return true;
|
||||
|
||||
|
@ -729,11 +729,11 @@ void LMDBAL::Storage<K, V>::readAll(std::map<K, V>& result, TransactionID txn) c
|
|||
MDB_cursor* cursor;
|
||||
MDB_val lmdbKey, lmdbData;
|
||||
|
||||
int rc = mdb_cursor_open(txn, dbi, &cursor);
|
||||
int rc = _mdbCursorOpen(txn, &cursor);
|
||||
if (rc != MDB_SUCCESS)
|
||||
throwUnknown(rc);
|
||||
|
||||
rc = mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_FIRST);
|
||||
rc = _mdbCursorGet(cursor, lmdbKey, lmdbData, MDB_FIRST);
|
||||
while (rc == MDB_SUCCESS) {
|
||||
K key;
|
||||
keySerializer.deserialize(lmdbKey, key);
|
||||
|
@ -741,9 +741,9 @@ void LMDBAL::Storage<K, V>::readAll(std::map<K, V>& result, TransactionID txn) c
|
|||
if (probe.second) //I do this to avoid overwrites in case duplicates are enabled
|
||||
valueSerializer.deserialize(lmdbData, probe.first->second);
|
||||
|
||||
rc = mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_NEXT);
|
||||
rc = _mdbCursorGet(cursor, lmdbKey, lmdbData, MDB_NEXT);
|
||||
}
|
||||
mdb_cursor_close(cursor);
|
||||
_mdbCursorClose(cursor);
|
||||
if (rc != MDB_NOTFOUND)
|
||||
throwUnknown(rc);
|
||||
}
|
||||
|
@ -817,7 +817,7 @@ void LMDBAL::Storage<K, V>::replaceAll(const std::map<K, V>& data, TransactionID
|
|||
lmdbKey = keySerializer.setData(pair.first);
|
||||
lmdbData = valueSerializer.setData(pair.second);
|
||||
|
||||
rc = mdb_put(txn, dbi, &lmdbKey, &lmdbData, MDB_NOOVERWRITE); //TODO may be appending with cursor makes sence here?
|
||||
rc = _mdbPut(txn, lmdbKey, lmdbData, MDB_NOOVERWRITE); //TODO may be appending with cursor makes sence here?
|
||||
if (rc != MDB_SUCCESS)
|
||||
throwUnknown(rc);
|
||||
}
|
||||
|
@ -892,7 +892,7 @@ uint32_t LMDBAL::Storage<K, V>::addRecords(const std::map<K, V>& data, Transacti
|
|||
lmdbKey = keySerializer.setData(pair.first);
|
||||
lmdbData = valueSerializer.setData(pair.second);
|
||||
|
||||
rc = mdb_put(txn, dbi, &lmdbKey, &lmdbData, overwrite ? 0 : MDB_NOOVERWRITE);
|
||||
rc = _mdbPut(txn, lmdbKey, lmdbData, overwrite ? 0 : MDB_NOOVERWRITE);
|
||||
if (rc == MDB_KEYEXIST)
|
||||
throwDuplicate(toString(pair.first));
|
||||
|
||||
|
@ -901,7 +901,7 @@ uint32_t LMDBAL::Storage<K, V>::addRecords(const std::map<K, V>& data, Transacti
|
|||
}
|
||||
|
||||
MDB_stat stat;
|
||||
rc = mdb_stat(txn, dbi, &stat);
|
||||
rc = _mdbStat(txn, stat);
|
||||
if (rc != MDB_SUCCESS)
|
||||
throwUnknown(rc);
|
||||
|
||||
|
@ -971,7 +971,7 @@ void LMDBAL::Storage<K, V>::removeRecord(const K& key) {
|
|||
template<class K, class V>
|
||||
void LMDBAL::Storage<K, V>::removeRecord(const K& key, TransactionID txn) {
|
||||
MDB_val lmdbKey = keySerializer.setData(key);
|
||||
int rc = mdb_del(txn, dbi, &lmdbKey, NULL);
|
||||
int rc = _mdbDel(txn, lmdbKey);
|
||||
if (rc != MDB_SUCCESS)
|
||||
throwNotFoundOrUnknown(rc, toString(key));
|
||||
}
|
||||
|
@ -1071,7 +1071,7 @@ uint32_t LMDBAL::Storage<K, V>::flags() const {
|
|||
uint32_t result;
|
||||
TransactionID txn = beginReadOnlyTransaction();
|
||||
|
||||
int res = mdb_dbi_flags(txn, dbi, &result);
|
||||
int res = _mdbFlags(txn, result);
|
||||
abortTransaction(txn);
|
||||
if (res != MDB_SUCCESS)
|
||||
throwUnknown(res);
|
||||
|
@ -1140,7 +1140,7 @@ inline int LMDBAL::iStorage::makeStorage(MDB_txn* transaction, bool duplicates)
|
|||
flags |= MDB_INTEGERDUP;
|
||||
}
|
||||
|
||||
return mdb_dbi_open(transaction, name.c_str(), flags, &dbi);
|
||||
return _mdbOpen(transaction, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue