summaryrefslogtreecommitdiffstats
path: root/common/storage_lmdb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/storage_lmdb.cpp')
-rw-r--r--common/storage_lmdb.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp
index 851fe36..655f858 100644
--- a/common/storage_lmdb.cpp
+++ b/common/storage_lmdb.cpp
@@ -579,16 +579,18 @@ int DataStore::NamedDatabase::findAllInRange(const QByteArray &lowerBound, const
579 579
580 int numberOfRetrievedValues = 0; 580 int numberOfRetrievedValues = 0;
581 581
582 MDB_val firstKey = { .mv_size = (size_t)lowerBound.size(), .mv_data = (void *)lowerBound.constData() }, 582 MDB_val firstKey = { .mv_size = (size_t)lowerBound.size(), .mv_data = (void *)lowerBound.constData() };
583 idealLastKey = { .mv_size = (size_t)upperBound.size(), .mv_data = (void *)upperBound.constData() }, 583 MDB_val idealLastKey = { .mv_size = (size_t)upperBound.size(), .mv_data = (void *)upperBound.constData() };
584 lastKey = idealLastKey, currentKey; 584 MDB_val lastKey = idealLastKey;
585 MDB_val reference; 585 MDB_val currentKey;
586 MDB_val data;
586 587
587 // Find the first key in the range 588 // Find the first key in the range
588 int rc = mdb_cursor_get(cursor, &firstKey, &reference, MDB_SET_RANGE); 589 int rc = mdb_cursor_get(cursor, &firstKey, &data, MDB_SET_RANGE);
589 590
590 if (rc != MDB_SUCCESS) { 591 if (rc != MDB_SUCCESS) {
591 // Nothing is greater or equal than the lower bound, meaning no result 592 // Nothing is greater or equal than the lower bound, meaning no result
593 mdb_cursor_close(cursor);
592 return 0; 594 return 0;
593 } 595 }
594 596
@@ -596,15 +598,18 @@ int DataStore::NamedDatabase::findAllInRange(const QByteArray &lowerBound, const
596 598
597 // If already bigger than the upper bound 599 // If already bigger than the upper bound
598 if (mdb_cmp(d->transaction, d->dbi, &currentKey, &idealLastKey) > 0) { 600 if (mdb_cmp(d->transaction, d->dbi, &currentKey, &idealLastKey) > 0) {
601 mdb_cursor_close(cursor);
599 return 0; 602 return 0;
600 } 603 }
601 604
602 do { 605 do {
603 const auto currentBAKey = QByteArray::fromRawData((char *)currentKey.mv_data, currentKey.mv_size); 606 const auto currentBAKey = QByteArray::fromRawData((char *)currentKey.mv_data, currentKey.mv_size);
604 const auto currentBAValue = QByteArray::fromRawData((char *)reference.mv_data, reference.mv_size); 607 const auto currentBAValue = QByteArray::fromRawData((char *)data.mv_data, data.mv_size);
605 resultHandler(currentBAKey, currentBAValue); 608 resultHandler(currentBAKey, currentBAValue);
606 } while (mdb_cursor_get(cursor, &currentKey, &reference, MDB_NEXT) == MDB_SUCCESS && 609 } while (mdb_cursor_get(cursor, &currentKey, &data, MDB_NEXT) == MDB_SUCCESS &&
607 mdb_cmp(d->transaction, d->dbi, &currentKey, &idealLastKey) <= 0); 610 mdb_cmp(d->transaction, d->dbi, &currentKey, &idealLastKey) <= 0);
611
612 mdb_cursor_close(cursor);
608} 613}
609 614
610qint64 DataStore::NamedDatabase::getSize() 615qint64 DataStore::NamedDatabase::getSize()