1
0
Fork 0
forked from blue/lmdbal

lmdb calls are now compiled into .so

This commit is contained in:
Blue 2023-11-14 20:15:16 -03:00
parent 77ba8f9e7b
commit 6b475f615e
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
6 changed files with 118 additions and 35 deletions

View file

@ -210,7 +210,7 @@ void LMDBAL::Cursor<K, V>::open () {
switch (state) {
case closed: {
TransactionID txn = storage->beginReadOnlyTransaction();
int result = mdb_cursor_open(txn, storage->dbi, &cursor);
int result = storage->_mdbCursorOpen(txn, &cursor);
if (result != MDB_SUCCESS)
storage->throwUnknown(result, txn);
@ -247,7 +247,7 @@ void LMDBAL::Cursor<K, V>::open (const Transaction& transaction) {
TransactionID txn = storage->extractTransactionId(transaction, openCursorMethodName);
switch (state) {
case closed: {
int result = mdb_cursor_open(txn, storage->dbi, &cursor);
int result = storage->_mdbCursorOpen(txn, &cursor);
if (result != MDB_SUCCESS)
storage->throwUnknown(result);
@ -283,14 +283,14 @@ void LMDBAL::Cursor<K, V>::renew () {
storage->ensureOpened(renewCursorMethodName);
switch (state) {
case openedPrivate: {
TransactionID txn = mdb_cursor_txn(cursor);
TransactionID txn = storage->_mdbCursorTxn(cursor);
storage->abortTransaction(txn);
storage->transactionAborted(txn);
[[fallthrough]];
}
case openedPublic: {
TransactionID txn = storage->beginReadOnlyTransaction();
int result = mdb_cursor_renew(txn, cursor);
int result = storage->_mdbCursorRenew(txn, cursor);
if (result != MDB_SUCCESS)
storage->throwUnknown(result, txn);
@ -331,13 +331,13 @@ void LMDBAL::Cursor<K, V>::renew (const Transaction& transaction) {
TransactionID txn = storage->extractTransactionId(transaction, renewCursorMethodName);
switch (state) {
case openedPrivate: {
TransactionID txn = mdb_cursor_txn(cursor);
TransactionID txn = storage->_mdbCursorTxn(cursor);
storage->abortTransaction(txn);
storage->transactionAborted(txn);
[[fallthrough]];
}
case openedPublic: {
int result = mdb_cursor_renew(txn, cursor);
int result = storage->_mdbCursorRenew(txn, cursor);
if (result != MDB_SUCCESS)
storage->throwUnknown(result);
@ -362,13 +362,13 @@ template<class K, class V>
void LMDBAL::Cursor<K, V>::close () {
switch (state) {
case openedPublic: {
mdb_cursor_close(cursor);
storage->_mdbCursorClose(cursor);
state = closed;
} break;
case openedPrivate: {
TransactionID txn = mdb_cursor_txn(cursor);
mdb_cursor_close(cursor);
TransactionID txn = storage->_mdbCursorTxn(cursor);
storage->_mdbCursorClose(cursor);
storage->abortTransaction(txn);
storage->transactionAborted(txn);
@ -608,7 +608,7 @@ bool LMDBAL::Cursor<K, V>::set (const K& key) {
storage->throwCursorNotReady(setMethodName);
MDB_val mdbKey = storage->keySerializer.setData(key);
int result = mdb_cursor_get(cursor, &mdbKey, nullptr, MDB_SET);
int result = storage->_mdbCursorSet(cursor, mdbKey);
if (result == MDB_SUCCESS)
return true;
else if (result == MDB_NOTFOUND)
@ -645,7 +645,7 @@ void LMDBAL::Cursor<K, V>::operateCursorRead(
storage->throwCursorNotReady(methodName);
MDB_val mdbKey, mdbValue;
int result = mdb_cursor_get(cursor, &mdbKey, &mdbValue, operation);
int result = storage->_mdbCursorGet(cursor, mdbKey, mdbValue, operation);
if (result != MDB_SUCCESS)
storage->throwNotFoundOrUnknown(result, operationName);
@ -655,7 +655,7 @@ void LMDBAL::Cursor<K, V>::operateCursorRead(
if (state == openedPrivate)
storage->discoveredRecord(key, value);
else
storage->discoveredRecord(key, value, mdb_cursor_txn(cursor));
storage->discoveredRecord(key, value, storage->_mdbCursorTxn(cursor));
}
#endif //LMDBAL_CURSOR_HPP